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/call isError conversion;
- derive request/result types from
RequestTypeMap and HandlerResultTypeMap.
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.
Problem
Frameworks built on the high-level
McpServercannot add operation middleware without replacing SDK-owned handlers or reaching into private registries.Protocol._wrapHandleris too low-level: it runs outsideMcpServerrouting, 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 andinput_requiredbehavior.Proposed seam
Add an optional high-level
aroundMcpRequestcallback toServerOptions. It should:McpServer;tools/callisErrorconversion;RequestTypeMapandHandlerResultTypeMap.The low-level
Servershould 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.