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

@mcp.resource with dynamic parameters example don't work #68

Open
CNSeniorious000 opened this issue Dec 9, 2024 · 7 comments
Open

@mcp.resource with dynamic parameters example don't work #68

CNSeniorious000 opened this issue Dec 9, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@CNSeniorious000
Copy link

In the README, there is an example:

@mcp.resource("users://{user_id}/profile")
def get_user_profile(user_id: str) -> str:
    """Dynamic user data"""
    return f"Profile data for user {user_id}"

This don't work

I can't see any resources in the mcp inspector

@github-actions github-actions bot added the bug Something isn't working label Dec 9, 2024
@vemonet
Copy link

vemonet commented Dec 10, 2024

Same for me, I copied the example server from README.md

from fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("Demo")


# Add an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b


# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
    """Get a personalized greeting"""
    return f"Hello, {name}!"


if __name__ == "__main__":
    mcp.run()

Then started the inspector with:

uv run fastmcp dev fastmcp.py

I can see the add tool but I get errors for the resource in Error output from MCP server

[12/10/24 17:30:03] INFO Processing request of type __init__.py:431 ListResourcesRequest 

(btw it's a bit weird that the log is labelled as INFO in the error output, not sure if this is a bug or a feature :) )

In history I have:

resources/list▼
Request:

{
  "method": "resources/list",
  "params": {}
}

Response:

{
  "resources": []
}

@jlowin

@mcp2everything
Copy link

Anyone got a solution to this problem? Thanks.

@gmr
Copy link

gmr commented Jan 3, 2025

It appears to be an issue when there is a parameter for a resource. Resources without parameters appear to work fine.

@micpst
Copy link

micpst commented Jan 10, 2025

This is related to #10, the current version of fastmcp simply doesn't support resource templates listing

@micpst
Copy link

micpst commented Jan 10, 2025

@zzstoatzz thanks my bad, seems to be fixed but not released yet

@ICeZer0
Copy link

ICeZer0 commented Feb 15, 2025

I'm having a similar issue on the official python-sdk. I can't get any resource params to show up in my MCP Inspector, might have to switch to native.

This works fine.

@mcp.resource("config://app")
def get_config() -> str:
    """Static configuration data"""
    return "App configuration here"

Once I add an input param it does not show up as a listed resource

@mcp.resource("users://{hello}/message")
def get_config(hello: str) -> str:
    """dynamic user message"""
    return "Message here {hello}"

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

7 participants