Skip to content

v2 backcompat: server legacy package#2206

Open
KKonstantinov wants to merge 9 commits into
mainfrom
feature/v2-server-legacy-package
Open

v2 backcompat: server legacy package#2206
KKonstantinov wants to merge 9 commits into
mainfrom
feature/v2-server-legacy-package

Conversation

@KKonstantinov
Copy link
Copy Markdown
Contributor

@KKonstantinov KKonstantinov commented May 29, 2026

Add @modelcontextprotocol/server-legacy — a drop-in bridge package that restores the v1 SSE transport and OAuth Authorization Server helpers for users migrating to v2.

Motivation and Context

v2 removed SSEServerTransport (replaced by Streamable HTTP) and restructured the OAuth auth module (error classes, provider interfaces, Express middleware). This package lets existing v1 servers keep working on v2 without rewriting their transport or auth layer immediately.

Supercedes #1908 by @felixweinberger (server-auth-legacy), but broader — bundles both SSE and auth under one package with sub-path exports.

The requireBearerAuth, mcpAuthMetadataRouter, getOAuthProtectedResourceMetadataUrl, and OAuthTokenVerifier exports were added to @modelcontextprotocol/express as backward-compat shims (PR #1907) but are now superseded by @modelcontextprotocol/server-legacy/auth. All consumers updated.

How Has This Been Tested?

162 tests (23 SSE + 139 auth) covering:

  • SSE transport lifecycle (start, send, close, handlePostMessage, DNS rebinding protection)
  • OAuth handlers (authorize, token, register, revoke, metadata)
  • OAuth middleware (bearer auth, client auth, allowed methods)
  • Proxy OAuth provider (authorization, token exchange, refresh, revocation, client registration)

All pass locally. Build produces 18 dist files. Typecheck and lint clean.

Breaking Changes

None — this is an additive package. Existing code is unaffected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

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

Additional context

Sub-path exports:

  • @modelcontextprotocol/server-legacy/sseSSEServerTransport (adapted to v2's Transport interface)
  • @modelcontextprotocol/server-legacy/authmcpAuthRouter, requireBearerAuth, ProxyOAuthServerProvider, OAuth error classes
  • @modelcontextprotocol/server-legacy — re-exports both

Key adaptations from v1:

  • SSE transport constructs a Web Standard Request (v2) instead of v1's RequestInfo
  • send() accepts TransportSendOptions for v2 Transport interface compatibility
  • @modelcontextprotocol/core is bundled inline via tsdown noExternal (same pattern as other packages)
  • Express is an optional peer dependency

Migration docs (docs/migration.md, docs/migration-SKILL.md) updated to reference this package as a bridge path.

  Frozen v1 SSE transport and OAuth Authorization Server helpers for
  migration from v1 to v2. Sub-path exports: ./sse (no Express dep),
  ./auth (Express peer dep), and . (re-exports both).

  Deprecated from day one — will not receive new features.
  Frozen v1 SSE transport and OAuth Authorization Server helpers for
  migration from v1 to v2. Sub-path exports: ./sse (no Express dep),
  ./auth (Express peer dep), and . (re-exports both).

  Deprecated from day one — will not receive new features.
  Frozen v1 SSE transport and OAuth Authorization Server helpers for
  migration from v1 to v2. Sub-path exports: ./sse (no Express dep),
  ./auth (Express peer dep), and . (re-exports both).

  Deprecated from day one — will not receive new features.
@KKonstantinov KKonstantinov requested a review from a team as a code owner May 29, 2026 15:34
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: cc96aa0

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

This PR includes changesets to release 2 packages
Name Type
@modelcontextprotocol/server-legacy Minor
@modelcontextprotocol/codemod Minor

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
Copy link
Copy Markdown

pkg-pr-new Bot commented May 29, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@2206

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2206

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@2206

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server-legacy@2206

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@2206

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2206

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@2206

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@2206

commit: cc96aa0

Comment thread packages/server-legacy/README.md Outdated
  The docs:check step failed because typedoc could not discover entry points
  for the server-legacy package. All other public packages already had a
  typedoc.json — this adds one with the same expand-src configuration.
…ntextprotocol/typescript-sdk into feature/v2-server-legacy-package
…server-legacy

  Instead of removing SSE server and OAuth auth imports with warnings,
  the codemod now moves them to @modelcontextprotocol/server-legacy/sse
  and /auth sub-paths respectively. An info diagnostic is emitted
  suggesting eventual migration to v2 equivalents.
  The requireBearerAuth, mcpAuthMetadataRouter, getOAuthProtectedResourceMetadataUrl,
  and OAuthTokenVerifier exports were added to @modelcontextprotocol/express as
  backward-compat shims (PR #1907) but are now superseded by
  @modelcontextprotocol/server-legacy/auth. All consumers updated.
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