fastapi_mcp icon indicating copy to clipboard operation
fastapi_mcp copied to clipboard

[FEAT] Add argument for removing adding response info to tool descriptions

Open jack5github opened this issue 5 months ago • 2 comments

Is your feature request related to a problem? Please describe. Response documentation is automatically added to my tool descriptions when using this package. This has the potential to overload the models I use with irrelevant and repetitive information.

Describe the solution you'd like Add an argument to the FastApiMCP class initialisation that disables this automatic behaviour.

Describe alternatives you've considered Using the standard MCP package's server component on its own proves to be too much of a challenge given my FastAPI-compatible code.

Additional context

jack5github avatar Aug 05 '25 06:08 jack5github

I have the same need! The automatic response information in tool descriptions can consume too much context space.

I've submitted a PR that adds an include_response_info parameter to FastApiMCP. When set to False, it completely removes all response information (including the ### Responses: section) from tool descriptions.

The implementation maintains backward compatibility (defaults to True). This should resolve the issue of response documentation consuming excessive context space.

Edison-A-N avatar Aug 10 '25 07:08 Edison-A-N

Another approach: could we use outputSchema for response_info instead?

p.s. Tool class definition in mcp package


class Tool(BaseMetadata):
    """Definition for a tool the client can call."""

    description: str | None = None
    """A human-readable description of the tool."""
    inputSchema: dict[str, Any]
    """A JSON Schema object defining the expected parameters for the tool."""
    outputSchema: dict[str, Any] | None = None
    """
    An optional JSON Schema object defining the structure of the tool's output
    returned in the structuredContent field of a CallToolResult.
    """
    annotations: ToolAnnotations | None = None
    """Optional additional tool information."""
    meta: dict[str, Any] | None = Field(alias="_meta", default=None)
    """
    See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
    for notes on _meta usage.
    """
    model_config = ConfigDict(extra="allow")

Edison-A-N avatar Aug 13 '25 03:08 Edison-A-N