Skip to content

mcp.resource doesn't generate correctly description from func.__doc__. #488

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

Open
jingyugao opened this issue Apr 11, 2025 · 0 comments
Open

Comments

@jingyugao
Copy link
Contributor

jingyugao commented Apr 11, 2025

Describe the bug
mcp.resource doesn't generate correctly description from func.doc.
To Reproduce
Steps to reproduce the behavior:

import asyncio
from typing import Any
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("twitter", host="127.0.0.1", port=9999)

@mcp.resource("resource://${file_name}/content")
async def get_file_content(file_name: str):
    """Get the File Content
    """

    return "Hello, world!"


@mcp.resource("resource://files")
async def get_file_list():
    """Get the list of files in the directory.
    return: list of file names
    """
    return ["1.txt","2.txt"]


if __name__ == "__main__":
    resource_templates = asyncio.run(mcp.list_resource_templates())
    print(resource_templates[0].description) # Get the File Content

    resources = asyncio.run(mcp.list_resources())
    print(resources[0].description) # None

Expected behavior
resources[0].description should be func.doc

Screenshots
Not Related

Desktop (please complete the following information):
Not Related

Smartphone (please complete the following information):
Not Related

Additional context
pip Version: 1.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant