Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@app.list_resource_templates() not available on Python #68

Closed
MarkusPfundstein opened this issue Dec 3, 2024 · 1 comment
Closed

@app.list_resource_templates() not available on Python #68

MarkusPfundstein opened this issue Dec 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@MarkusPfundstein
Copy link

MarkusPfundstein commented Dec 3, 2024

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

@MarkusPfundstein MarkusPfundstein added the bug Something isn't working label Dec 3, 2024
@dsp-ant
Copy link
Member

dsp-ant commented Dec 3, 2024

Thank you for reporting this. This is fixed in modelcontextprotocol/python-sdk#77, which was released as v1.1.0 of the python sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants