Skip to content
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
@MarkusPfundstein

Description

@MarkusPfundstein

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

  1. 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"
        )
    ]
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions