Skip to content

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

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

feat(core): support registerTool/registerResource/registerPrompt in MCP integration#20069
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 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>
@sdk-maintainer-bot sdk-maintainer-bot bot added missing-issue-reference Used for automated community contribution checks. violating-contribution-guidelines Used for automated community contribution checks. labels Apr 1, 2026
@sdk-maintainer-bot
Copy link
Copy Markdown

This PR has been automatically closed. All non-maintainer contributions must reference an existing GitHub issue.

Next steps:

  1. Find or open an issue describing the problem or feature
  2. Discuss the approach with a maintainer in the issue
  3. Once a maintainer has acknowledged your proposed approach, open a new PR referencing the issue

Please review our contributing guidelines for more details.

@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 #20069
  • (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.

@betegon betegon reopened this Apr 1, 2026
@sdk-maintainer-bot
Copy link
Copy Markdown

This PR has been automatically closed. All non-maintainer contributions must reference an existing GitHub issue.

Next steps:

  1. Find or open an issue describing the problem or feature
  2. Discuss the approach with a maintainer in the issue
  3. Once a maintainer has acknowledged your proposed approach, open a new PR referencing the issue

Please review our contributing guidelines for more details.

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

Labels

missing-issue-reference Used for automated community contribution checks. violating-contribution-guidelines Used for automated community contribution checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Server - support new MCP server typescript SDK APIs

1 participant