-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
P3Nice to haves, rare edge casesNice to haves, rare edge casesbugSomething isn't workingSomething isn't workingready for workEnough information for someone to start working onEnough information for someone to start working on
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
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
Metadata
Metadata
Assignees
Labels
P3Nice to haves, rare edge casesNice to haves, rare edge casesbugSomething isn't workingSomething isn't workingready for workEnough information for someone to start working onEnough information for someone to start working on