This repository was archived by the owner on Apr 8, 2025. It is now read-only.
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
@app.list_resource_templates() not available on Python #68
Closed
Description
Describe the bug
The documentation states here: https://modelcontextprotocol.io/docs/first-server/python that one can expose ResourceTemplates with Python using the @app.list_resource_templates()
decorator.
This does not work and will throw an error on startup:
AttributeError: 'Server' object has no attribute 'list_resource_templates'
To Reproduce
- Add code to
@app.list_resource_templates()
async def list_resource_templates() -> list[ResourceTemplate]:
"""List available resources."""
retur [
ResourceTemplate(
uriTemplate="note://obsidian/{path}",
name="A obsidian note",
description="Obsidian note identified by a path relative to root vault",
mimeType="application/txt"
)
]
- Start server either via uv run or via Claude UI
Expected behavior
Server should start and ResourceTemplates should be exposed to Client
Logs
Traceback (most recent call last):
File "/Users/markus/experiments/claude-mvp/mvp-knowledge-base/.venv/bin/mcp-knowledge-base", line 5, in <module>
from mcp_knowledge_base import main
File "/Users/markus/experiments/claude-mvp/mvp-knowledge-base/src/mcp_knowledge_base/__init__.py", line 1, in <module>
from . import server
File "/Users/markus/experiments/claude-mvp/mvp-knowledge-base/src/mcp_knowledge_base/server.py", line 72, in <module>
@app.list_resource_templates()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Server' object has no attribute 'list_resource_templates'
Additional context