Skip to content

Fix decorator overload return types for function mode#3258

Merged
jlowin merged 2 commits intomainfrom
fix/decorator-overload-return-types
Feb 21, 2026
Merged

Fix decorator overload return types for function mode#3258
jlowin merged 2 commits intomainfrom
fix/decorator-overload-return-types

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Feb 21, 2026

Closes #3255

The @mcp.tool, @mcp.prompt, and @mcp.resource decorator overloads on FastMCP and LocalProvider still declared FunctionTool, FunctionPrompt, and Resource | ResourceTemplate as their return types — left over from when decorator_mode="object" was the default. Since v3 defaults to "function" mode (decorators return the original function unchanged), type checkers saw these as non-callable objects and flagged any direct call to the decorated function.

The standalone decorators (from fastmcp.tools import tool, etc.) already used a TypeVar F pattern to preserve the original function type. This applies the same pattern to the method decorators:

mcp = FastMCP("demo")

@mcp.tool
def add(a: int, b: int) -> int:
    return a + b

# Type checkers now correctly see `add` as (int, int) -> int
add(a=1, b=2)  # no more type error

@marvin-context-protocol marvin-context-protocol Bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. server Related to FastMCP server implementation or server-side functionality. labels Feb 21, 2026
@jlowin jlowin merged commit bb3e159 into main Feb 21, 2026
10 checks passed
@jlowin jlowin deleted the fix/decorator-overload-return-types branch February 21, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type linter do not see tool functions as callable

1 participant