python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Resource Templates not exposed to Claude UI

Open MarkusPfundstein opened this issue 1 year ago • 0 comments

Describe the bug When registered a resource_template with the python sdk (mcp==1.1.0), the server runs but no resources can be selected in the UI.

To Reproduce Steps to reproduce the behavior:

  1. Add code (see below)
  2. Run server
  3. Open Claude
  4. Try to attach a resource

Expected behavior I would expect to be able to select a resource template.

Screenshots

*** Resource not displayed image

*** Server installed (resource_testing) image

Desktop (please complete the following information):

  • MacOSX
  • Python 3.13
  • mcp 1.1.0

Additional context

This is the code to register the resource templates:

@app.list_resource_templates()
async def list_resource_templates() -> list[ResourceTemplate]:
    return [
        ResourceTemplate(
            uriTemplate=AnyUrl("file://moonshot/posts/{posts}"),
            description="Posts of your moonshot account",
            name="Get posts",
            mimeType="application/json"
        )
    ]

@app.read_resource()
async def read_resource(uri: AnyUrl) -> str:
    logger.error(f"read resource call: {uri}")
    if str(uri).startswith("file://moonshot/posts/"):
        return json.dumps(["post1", "post2", "post3"], indent=2)

    raise ValueError("Resource not found")

MarkusPfundstein avatar Dec 05 '24 08:12 MarkusPfundstein