Skip to content

Add high-level MCP operation interceptor seam#2508

Closed
khandrew1 wants to merge 2 commits into
modelcontextprotocol:fweinberger/export-protocolfrom
khandrew1:agent/mcp-operation-interceptor
Closed

Add high-level MCP operation interceptor seam#2508
khandrew1 wants to merge 2 commits into
modelcontextprotocol:fweinberger/export-protocolfrom
khandrew1:agent/mcp-operation-interceptor

Conversation

@khandrew1

Copy link
Copy Markdown

What changed

  • adds SDK-derived McpRequestMethod and AroundMcpRequest public types
  • adds ServerOptions.aroundMcpRequest for the high-level McpServer
  • places the seam around the seven tool/resource/prompt primitive operations
  • keeps routing and input validation before interception, with output validation, projection, cache hints, and protocol validation after it
  • keeps low-level Server.setRequestHandler() behavior unchanged

Why

Frameworks need a supported way to add operation middleware without replacing SDK-owned handlers, duplicating dispatch, parsing HTTP responses, or reaching into private registries. The existing low-level handler wrapper is outside the high-level validation and projection boundaries, so it cannot provide those guarantees.

This PR is intentionally stacked on #2501 because the consuming framework already depends on that coordinated 2026-07-28 preview.

Closes #2507.

Validation

  • pnpm --filter @modelcontextprotocol/server typecheck
  • server lint and Prettier
  • server build and declaration generation
  • full server test suite: 42 files, 453 tests
  • full pre-push build, typecheck, and lint hooks

@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5c6f3df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@modelcontextprotocol/server Minor
@modelcontextprotocol/express Major
@modelcontextprotocol/fastify Major
@modelcontextprotocol/hono Major
@modelcontextprotocol/node Major
@modelcontextprotocol/core Minor
@modelcontextprotocol/client Minor
@modelcontextprotocol/server-legacy Minor
@modelcontextprotocol/codemod Minor
@modelcontextprotocol/core-internal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2508

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2508

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2508

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2508

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2508

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2508

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2508

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2508

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2508

commit: 5c6f3df

@khandrew1 khandrew1 closed this Jul 16, 2026
@khandrew1

Copy link
Copy Markdown
Author

auto slop pr, sorry

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.

1 participant