Skip to content

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

Closed
betegon wants to merge 2 commits intodevelopfrom
feat/mcp-register-api-support
Closed

feat(core): support registerTool/registerResource/registerPrompt in MCP integration#20070
betegon wants to merge 2 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 since 2.x doesn't have 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

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>
@sdk-maintainer-bot
Copy link
Copy Markdown

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.

@sdk-maintainer-bot sdk-maintainer-bot bot added missing-maintainer-discussion Used for automated community contribution checks. violating-contribution-guidelines Used for automated community contribution checks. labels Apr 1, 2026
@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 #20070
  • (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

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

  • 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.03% +16 B 🔺
@sentry/node 172.13 kB -0.37% -625 B 🔽
@sentry/node - without tracing 96.05 kB +0.05% +40 B 🔺
@sentry/aws-serverless 112.81 kB +0.03% +31 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 8,982 - 10,713 -16%
GET With Sentry 1,812 20% 1,795 +1%
GET With Sentry (error only) 6,147 68% 7,290 -16%
POST Baseline 1,218 - 1,087 +12%
POST With Sentry 602 49% 517 +16%
POST With Sentry (error only) 1,032 85% 941 +10%
MYSQL Baseline 3,189 - 3,677 -13%
MYSQL With Sentry 524 16% 392 +34%
MYSQL With Sentry (error only) 2,614 82% 2,860 -9%

View base workflow run

@JPeer264 JPeer264 removed violating-contribution-guidelines Used for automated community contribution checks. missing-maintainer-discussion Used for automated community contribution checks. labels Apr 1, 2026
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