1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Why doesn't MCP server expose my resources?

Discussão em 'Python' iniciado por Stack, Setembro 4, 2025.

  1. Stack

    Stack Membro Participativo

    here's the MCP code I have:

    from mcp.server.fastmcp import FastMCP

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


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


    @mcp.resource("file://data/file.txt")
    def read_file_txt() -> str:
    """Read contents of file.txt from data directory"""
    try:
    with open('/tmp/file.txt', "r") as f:
    return f.read()
    except Exception as e:
    return f"Error reading file: {str(e)}"
    #

    @mcp.prompt()
    def greet_user_prompt(name: str) -> str:
    """Generates a message asking for a greeting"""
    return f"""
    Return a greeting message for a user called '{name}'.
    if the user is called 'Laurent', use a formal style, else use a street style.
    """


    I have this MCP server installed into Claude Desktop.

    • the read_file_txt resource is visible to Claude
    • the greet_user_prompt is visible to Claude
    • the get_greeting resource, mentioned in a whole bunch of tutorials btw, is not visible.

    And it's not just Claude, the MCP dev server also does not see the get_greeting resource.

    So, what am I doing wrong?

    [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página