modelcontextprotocol / modelcontextprotocol/typescript-sdk
Add a high-level MCP operation interceptor seam
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Description
Problem
Frameworks built on the high-level McpServer cannot add operation middleware without replacing SDK-owned handlers or reaching into private registries. Protocol._wrapHandler is too low-level: it runs outside McpServer routing, tool input/output validation, result projection, resource cache hints, and prompt validation.
This prevents a framework from safely wrapping tools/list, tools/call, resource operations, and prompt operations while preserving SDK validation and input_required behavior.
Proposed seam
Add an optional high-level aroundMcpRequest callback to ServerOptions. It should:
- cover the seven primitive operations owned by
McpServer; - run after method-specific routing and input validation;
- run before tool output validation/projection, resource cache-hint attachment, input-required handling, and protocol result validation;
- keep ordinary interceptor errors inside the existing
tools/callisErrorconversion; - derive request/result types from
RequestTypeMapandHandlerResultTypeMap.
The low-level Server should continue to leave directly registered handlers unchanged.
This work needs to stack on #2501 because the consuming framework already uses that coordinated preview for the 2026-07-28 protocol and MCP Apps support.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing McpServer routing and the existing Protocol._wrapHandler path, then inspect ServerOptions, RequestTypeMap, and HandlerResultTypeMap. Compare the seven primitive operations and the validation and error-handling stages described in the issue, while reviewing the coordinated preview in #2501. Done means the high-level seam covers those operations without changing directly registered low-level handlers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100