Skip to content

Incorrect typing hint for FastMCP.call_tool #1251

Closed

Description

@de-code

Initial Checks

Description

The signature for FastMCP.call_tool:

    async def call_tool(self, name: str, arguments: dict[str, Any]) -> Sequence[ContentBlock] | dict[str, Any]:

i.e. it says the return type is either a sequence of ContentBlock or a dict.

However, it seems to be more like either just a sequence of ContentBlock or a tuple of: sequence of ContentBlock and a dict:

Sequence[ContentBlock] | tuple[Sequence[ContentBlock], dict[str, Any]]

That is because it always passes convert_result=True to self._tool_manager.call_tool (it would be nice if that was exposed as a parameter). And the convert_result result function (in mcp.server.fastmcp.utilities.func_metadata) is implemented like that but doesn't have any useful type hints.

This has changed after version 1.9.4 (i.e. in 1.9.4 it was still just a sequence of ContentBlock).

Example Code

from mcp.server.fastmcp import FastMCP


mcp = FastMCP(name='Example MCP Server')


@mcp.tool()
async def add_numbers(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

...

# Within an async context call:

result = await mcp.call_tool(
    "add_numbers",
    arguments={"a": 1, "b": 2}
)
print('result:', result)

# Output:
result: ([TextContent(type='text', text='3', annotations=None, meta=None)], {'result': 3})

Python & MCP Python SDK

1.12.4

Activity

  1. added
    bugSomething isn't working
    ready for workEnough information for someone to start working on
    P3Nice to haves, rare edge cases
    on Oct 6, 2025
  2. maxisbey commented on Jul 29, 2026

    @maxisbey
    Contributor

    Thanks for the report. Closing this as it's been fixed in v2, which is now released (see #2816). If you still run into this on v2, feel free to reopen.

    AI Disclaimer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesbugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions