Summary
Following #1822 and #1826 which addressed call_tool decorator typing, the other server decorators still lack proper type annotations, requiring # type: ignore comments in strict mypy projects.
Affected Decorators
@server.list_tools()
@server.list_resources()
@server.read_resource()
Current Behavior
@server.list_tools() # type: ignore[no-untyped-call, untyped-decorator]
async def list_tools() -> list[Tool]:
...
@server.list_resources() # type: ignore[no-untyped-call, untyped-decorator]
async def list_resources() -> list[Resource]:
...
@server.read_resource() # type: ignore[no-untyped-call, untyped-decorator]
async def read_resource(uri: str) -> str:
...
Running mypy in strict mode produces:
error: Call to untyped function "list_tools" in typed context [no-untyped-call]
error: Untyped decorator makes function "list_tools" untyped [untyped-decorator]
Expected Behavior
All server decorators should preserve type information using ParamSpec (as done for call_tool in #1826), eliminating the need for type: ignore comments.
Environment
- mcp version: 1.26.0
- Python: 3.14
- mypy: strict mode
Related
Summary
Following #1822 and #1826 which addressed
call_tooldecorator typing, the other server decorators still lack proper type annotations, requiring# type: ignorecomments in strict mypy projects.Affected Decorators
@server.list_tools()@server.list_resources()@server.read_resource()Current Behavior
Running mypy in strict mode produces:
Expected Behavior
All server decorators should preserve type information using
ParamSpec(as done forcall_toolin #1826), eliminating the need fortype: ignorecomments.Environment
Related
call_toolcall_tooldecorator #1826 - Fix forcall_tooldecorator