Skip to content

feat(core): support registerTool/registerResource/registerPrompt in MCP integration#20071

Open
betegon wants to merge 3 commits intodevelopfrom
feat/mcp-register-api-support
Open

feat(core): support registerTool/registerResource/registerPrompt in MCP integration#20071
betegon wants to merge 3 commits intodevelopfrom
feat/mcp-register-api-support

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 1, 2026

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 registerTooltool_execution, registerResourceresource_execution, registerPromptprompt_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

betegon and others added 2 commits April 1, 2026 12:36
…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>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (core) Support registerTool/registerResource/registerPrompt in MCP integration by betegon in #20071
  • (core, node) Portable Express integration by isaacs in #19928
  • (deno) Add denoRuntimeMetricsIntegration by chargome in #20023
  • (deps) Bump @xmldom/xmldom from 0.8.3 to 0.8.12 by dependabot in #20066

Bug Fixes 🐛

  • (aws-serverless) Add timeout to _endSpan forceFlush to prevent Lambda hanging by logaretm in #20064
  • (cloudflare) Ensure every request instruments functions by JPeer264 in #20044
  • (gatsby) Fix errorHandler signature to match bundler-plugin-core API by JPeer264 in #20048

Internal Changes 🔧

Core

  • Extract shared endStreamSpan for AI integrations by nicohrubec in #20021
  • Remove provider-specific AI span attributes in favor of gen_ai attributes in sentry conventions by nicohrubec in #20011

Other

  • Update validate-pr workflow by stephanie-anderson in #20072
  • Remove unused tsconfig-template folder by mydea in #20067

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.65 kB +0.02% +5 B 🔺
@sentry/browser - with treeshaking flags 24.14 kB +0.03% +5 B 🔺
@sentry/browser (incl. Tracing) 42.16 kB +0.02% +7 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.77 kB +0.02% +9 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.94 kB +0.01% +5 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.56 kB +0.01% +5 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.66 kB +0.01% +8 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.92 kB +0.01% +5 B 🔺
@sentry/browser (incl. Feedback) 42.42 kB +0.02% +6 B 🔺
@sentry/browser (incl. sendFeedback) 30.31 kB +0.02% +6 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.29 kB +0.02% +6 B 🔺
@sentry/browser (incl. Metrics) 26.96 kB +0.03% +7 B 🔺
@sentry/browser (incl. Logs) 27.11 kB +0.03% +7 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.78 kB +0.03% +7 B 🔺
@sentry/react 27.41 kB +0.03% +6 B 🔺
@sentry/react (incl. Tracing) 44.48 kB +0.02% +5 B 🔺
@sentry/vue 30.08 kB +0.02% +5 B 🔺
@sentry/vue (incl. Tracing) 44.05 kB +0.02% +8 B 🔺
@sentry/svelte 25.67 kB +0.02% +5 B 🔺
CDN Bundle 28.32 kB +0.03% +6 B 🔺
CDN Bundle (incl. Tracing) 43.11 kB +0.02% +6 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.68 kB +0.02% +4 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 44.16 kB +0.02% +7 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.48 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay) 80.01 kB +0.01% +7 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.05 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.55 kB +0.01% +5 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.58 kB +0.01% +6 B 🔺
CDN Bundle - uncompressed 82.68 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 127.83 kB +0.02% +22 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 86.83 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 131.24 kB +0.02% +22 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 209.81 kB +0.02% +22 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.7 kB +0.01% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 248.1 kB +0.01% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.62 kB +0.01% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 261 kB +0.01% +22 B 🔺
@sentry/nextjs (client) 46.9 kB +0.02% +7 B 🔺
@sentry/sveltekit (client) 42.62 kB +0.02% +7 B 🔺
@sentry/node-core 55.77 kB +0.04% +17 B 🔺
@sentry/node 172.13 kB -0.37% -625 B 🔽
@sentry/node - without tracing 96.05 kB +0.05% +39 B 🔺
@sentry/aws-serverless 112.85 kB +0.07% +77 B 🔺

View base workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

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.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,410 - 11,213 -16%
GET With Sentry 1,673 18% 1,972 -15%
GET With Sentry (error only) 5,990 64% 7,611 -21%
POST Baseline 1,178 - 1,281 -8%
POST With Sentry 597 51% 627 -5%
POST With Sentry (error only) 1,037 88% 1,132 -8%
MYSQL Baseline 3,235 - 3,494 -7%
MYSQL With Sentry 544 17% 456 +19%
MYSQL With Sentry (error only) 2,625 81% 2,814 -7%

View base workflow run

@betegon betegon marked this pull request as ready for review April 1, 2026 12:31
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Call echo-register tool in SSE transport tests across node-express,
node-express-v5, and tsx-express, verifying that tools/call transactions
are recorded for handlers registered via registerTool.

Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
@betegon betegon requested review from JPeer264 and nicohrubec April 1, 2026 13:35
@betegon betegon self-assigned this Apr 1, 2026
@betegon betegon force-pushed the feat/mcp-register-api-support branch from 68356d4 to 8984639 Compare April 1, 2026 19:37
Copy link
Copy Markdown
Member

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition. It would be nice if there would be an additional e2e test that has the v2 of the @modelcontextprotocol/sdk as well. Right now we only test against v1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Server - support new MCP server typescript SDK APIs

2 participants