feat(core): support registerTool/registerResource/registerPrompt in MCP integration#20070
feat(core): support registerTool/registerResource/registerPrompt in MCP integration#20070
Conversation
…CP integration The @modelcontextprotocol/sdk introduced register* methods alongside the legacy tool/resource/prompt API in 1.x, and made them the only option in 2.x. - MCPServerInstance now accepts both old and new method names - validateMcpServerInstance accepts servers with either API set - wrapAllMCPHandlers instruments whichever methods are present - captureHandlerError maps register* names to the same error categories Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
- Add createMockMcpServerWithRegisterApi() to test utilities - Test validation accepts register*-only servers and rejects invalid ones - Test that registerTool/registerResource/registerPrompt get wrapped - Add registerTool handler to node-express, node-express-v5, tsx-express e2e apps Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
|
This PR has been automatically closed. The referenced issue does not show a discussion between you and a maintainer. To avoid wasted effort on both sides, please discuss your proposed approach in the issue first and wait for a maintainer to respond before opening a PR. Please review our contributing guidelines for more details. |
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧Core
Other
🤖 This preview updates automatically when you update the PR. |
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
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
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.
Closes #16666