Skip to content

feat(compat): add deprecated flat ctx.* getters + RequestHandlerExtra type alias#1902

Draft
felixweinberger wants to merge 2 commits intomainfrom
fweinberger/v2-bc-ctx-flat-getters
Draft

feat(compat): add deprecated flat ctx.* getters + RequestHandlerExtra type alias#1902
felixweinberger wants to merge 2 commits intomainfrom
fweinberger/v2-bc-ctx-flat-getters

Conversation

@felixweinberger
Copy link
Copy Markdown
Contributor

Part of the v2 backwards-compatibility series — see reviewer guide.

v2 nested handler-context fields (extra.signalctx.mcpReq.signal, extra.authInfoctx.http?.authInfo). This adds non-optional @deprecated getters at the old flat locations.

Motivation and Context

v2 nested handler-context fields (extra.signalctx.mcpReq.signal, extra.authInfoctx.http?.authInfo). This adds non-optional @deprecated getters at the old flat locations.

v1 vs v2 pattern & evidence

v1 pattern:

`async (req, extra) => { extra.signal; extra.sendNotification(...); extra.taskStore }`

v2-native:

`async (req, ctx) => { ctx.mcpReq.signal; ctx.mcpReq.notify(...); ctx.task?.store }`

Evidence: GitHub code search: ~1,180 files use extra.signal/extra.sendNotification.

How Has This Been Tested?

  • packages/core/test/shared/protocol.compat.test.ts — getter equivalence + warn-once
  • Integration: validated bump-only against 5 OSS repos via the v2-bc-integration validation branch
  • pnpm typecheck:all && pnpm lint:all && pnpm test:all green

Breaking Changes

None — additive @deprecated shim. Removed in v3.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added or updated documentation as needed

Additional context

Stacks on: C1

… alias

v1 handler signatures read context fields flat (extra.signal, extra.requestId,
extra._meta, extra.authInfo, extra.sendNotification, extra.sendRequest). v2
nests these under ctx.mcpReq / ctx.http.

This adds non-enumerable forwarding getters on the context object so v1 handlers
compile and run unchanged, with a one-time stderr deprecation warning per field.
Also adds the RequestHandlerExtra<R, N> type alias (= ServerContext) so v1 type
imports keep resolving.

All marked @deprecated; removed in v3.
@felixweinberger felixweinberger added the v2-bc v2 backwards-compatibility series label Apr 15, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: 72bae92

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

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core 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

@felixweinberger felixweinberger added this to the v2.0.0-bc milestone Apr 15, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 15, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 72bae92

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

Labels

v2-bc v2 backwards-compatibility series

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant