Skip to content

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

Closed
@jingyugao

Description

@jingyugao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions