Skip to content

Move MCP error hints onto the SDK's server.use('tools/call') middleware once it's stable #27142

Todo

Description

@logaretm

addErrorHints appends the feedback hint by wrapping the SDK's private tools/call handler in server.server._requestHandlers. MCP TypeScript SDK v2 now has public request middleware, server.use(method, middleware) (typescript-sdk#2820, merged 2026-11-18), which can wrap tools/call and replace its result. That's the same job without the private map.

It comes from SEP-3371 (accepted 2026-11-28, not Final), which requires public JSON-RPC middleware in official SDKs.

Blocked until:

  • use() ships in a @modelcontextprotocol/server release (2.4.0 doesn't have it)
  • it is no longer marked experimental (typescript-sdk#3248 tracks the gaps)

Then:

  • On v2 servers, append the hint in a tools/call middleware instead of replacing the entry in _requestHandlers
  • Keep the tool callback record, since middleware doesn't see the thrown error (needed for the 4xx filter) or whether the callback ran (needed to tell input validation errors apart)
  • Keep the current wrapper for SDK v1, which has no use()

The nightly canary on SDK main (#27135) will flag changes around it before a release. Part of #27140.

Activity

  1. self-assigned this
    on Dec 3, 2026
  2. linear-code commented on Dec 3, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions