Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add type annotations for all server decorators (list_tools, list_resources, read_resource) #1980

Copy link
Copy link
@DaisukeYoda

Description

@DaisukeYoda
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.