Initial Checks
Description
If you try to use a tool a which is wrapped and uses from __future__ import annotations setup fails with and InvalidSignature exception e.g.
mcp.server.fastmcp.exceptions.InvalidSignature: Unable to evaluate type annotation ForwardRef("Literal['literal'] | None")
The cause of this is that the global name space used for the lookup is the wrapper namespace and not the original function namespace.
Example Code
from __future__ import annotations
import logfire
from mcp.server.fastmcp import FastMCP
@logfire.instrument
def test_tool(location_type: Literal["literal"] | None = None) -> str:
"""Test tool."""
return f"a is {location_type}"
mcp = FastMCP(
"Wrap test",
tools=[
Tool.from_function(test_tool),
],
)
Python & MCP Python SDK
SDL: 1.14.1
Python: 3.13.7
Reactions are currently unavailable
Initial Checks
Description
If you try to use a tool a which is wrapped and uses from __future__ import annotations setup fails with and InvalidSignature exception e.g.
mcp.server.fastmcp.exceptions.InvalidSignature: Unable to evaluate type annotation ForwardRef("Literal['literal'] | None")The cause of this is that the global name space used for the lookup is the wrapper namespace and not the original function namespace.
Example Code
Python & MCP Python SDK