feat(core): support registerTool/registerResource/registerPrompt in MCP integration (#20071)
The `@modelcontextprotocol/sdk` introduced `registerTool`, `registerResource`, and `registerPrompt` as a new API in 1.x, and in 2.x these are the *only* methods available — the old `tool`/`resource`/`prompt` names are gone. Before this change, servers using the new API would silently get no instrumentation: `validateMcpServerInstance` would reject them (it only checked for the old names), so `wrapMcpServerWithSentry` would return the unwrapped instance. The cloudflare-mcp e2e app already used `registerTool` and was affected by this. ## Changes - `MCPServerInstance` type now includes optional `registerTool?`, `registerResource?`, `registerPrompt?` alongside the legacy methods (also made legacy ones optional with `@deprecated` tags since 2.x removed them) - `validateMcpServerInstance` now accepts instances with either `tool+resource+prompt+connect` or `registerTool+registerResource+registerPrompt+connect` - `wrapAllMCPHandlers` conditionally wraps whichever set of methods exists on the instance - `captureHandlerError` maps `registerTool` → `tool_execution`, `registerResource` → `resource_execution`, `registerPrompt` → `prompt_execution` - Unit tests added for validation and wrapping of the new method names - `registerTool` handlers added to the node-express, node-express-v5, and tsx-express e2e apps The existing `wrapMethodHandler` logic (intercepts the last argument as the callback) works identically for both old and new signatures, so no changes were needed there. - [ ] Tests added - [ ] Lints and test suite passes Closes #16666 --------- Co-authored-by: claude-sonnet-4-6 <noreply@anthropic.com>
M
Miguel Betegón committed
0f358833243f02afb54fd1ddb3a2d0e66f8d3666
Parent: 750d242
Committed by GitHub <noreply@github.com>
on 4/7/2026, 11:44:46 AM