Skip to content

Keep the 1.x handler registration forms as deprecated overloads - #769

Merged
ochafik merged 2 commits into
mainfrom
legacy-schema-overload
Sep 8, 2026
Merged

Keep the 1.x handler registration forms as deprecated overloads#769
ochafik merged 2 commits into
mainfrom
legacy-schema-overload

Conversation

@ochafik

@ochafik ochafik commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #768. Two of the breaks listed in the migration guide were cheap to keep as deprecated compatibility, so this restores them for the 2.x line:

  • setRequestHandler(Schema, handler) / setNotificationHandler(Schema, handler) still work on App and AppBridge as a third, @deprecated overload next to the two 2.x forms. A small helper (src/legacy-handlers.ts) detects the whole-message Zod schema, extracts the method literal, and forwards to the 2.x (method, { params }, handler) form; the legacy handler gets the reassembled { method, params } message and, for requests, a 1.x-shaped extra (signal, requestId, sessionId, _meta, sendRequest, sendNotification, authInfo) built from the 2.x BaseContext. A one-time console.warn points at the new form. The double-registration guard from SDK 2.0 fixups: lockfile, peers, handler guards, docs, wire-compat tests #768 applies to both forms.
  • AppRequest, AppNotification, AppResult come back as deprecated type aliases. 1.x fed them to the SDK's Protocol generics; nothing in 2.x consumes them, but they leaked through the root entry and are free to keep.

Both are marked for removal in 3.0, and the migration guide now says "deprecated" rather than "gone" for these.

Tests: src/legacy-handlers.test.ts covers a custom request and notification through the old form on each class (message shape, extra shape, one-time warning) and that the guard still throws for on*-owned and event-mapped methods. A throwaway consumer file confirms the 1.x form, the 2.x spec form and the 2.x custom form all type-check side by side with the expected extra / ctx types.

+173/−28 in src/, most of it the union aliases.

Consumers on 1.x wrote setRequestHandler(Schema, handler) and
setNotificationHandler(Schema, handler) with a whole-message Zod schema.
SDK 2.0 keys handlers by method name, so App and AppBridge now accept
that form as a third, deprecated overload: a small helper detects the
schema, extracts the method literal, forwards to the 2.x
(method, { params }, handler) form, and hands the legacy handler the
reassembled { method, params } message plus a 1.x-shaped extra
(signal, requestId, sessionId, _meta). A one-time console warning
points at the new form. The double-registration guard applies to both
forms.

The AppRequest, AppNotification and AppResult unions that 1.x fed to
the SDK's Protocol generics come back as deprecated type aliases, since
they leaked through the root entry and cost nothing to keep.

Both go away in 3.0.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Preview

Preview deployments for this PR have been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/ext-apps

npm i https://pkg.pr.new/@modelcontextprotocol/ext-apps@769

@modelcontextprotocol/server-basic-preact

npm i https://pkg.pr.new/@modelcontextprotocol/server-basic-preact@769

@modelcontextprotocol/server-basic-react

npm i https://pkg.pr.new/@modelcontextprotocol/server-basic-react@769

@modelcontextprotocol/server-basic-solid

npm i https://pkg.pr.new/@modelcontextprotocol/server-basic-solid@769

@modelcontextprotocol/server-basic-svelte

npm i https://pkg.pr.new/@modelcontextprotocol/server-basic-svelte@769

@modelcontextprotocol/server-basic-vanillajs

npm i https://pkg.pr.new/@modelcontextprotocol/server-basic-vanillajs@769

@modelcontextprotocol/server-basic-vue

npm i https://pkg.pr.new/@modelcontextprotocol/server-basic-vue@769

@modelcontextprotocol/server-budget-allocator

npm i https://pkg.pr.new/@modelcontextprotocol/server-budget-allocator@769

@modelcontextprotocol/server-cohort-heatmap

npm i https://pkg.pr.new/@modelcontextprotocol/server-cohort-heatmap@769

@modelcontextprotocol/server-customer-segmentation

npm i https://pkg.pr.new/@modelcontextprotocol/server-customer-segmentation@769

@modelcontextprotocol/server-debug

npm i https://pkg.pr.new/@modelcontextprotocol/server-debug@769

@modelcontextprotocol/server-lazy-auth

npm i https://pkg.pr.new/@modelcontextprotocol/server-lazy-auth@769

@modelcontextprotocol/server-map

npm i https://pkg.pr.new/@modelcontextprotocol/server-map@769

@modelcontextprotocol/server-pdf

npm i https://pkg.pr.new/@modelcontextprotocol/server-pdf@769

@modelcontextprotocol/server-scenario-modeler

npm i https://pkg.pr.new/@modelcontextprotocol/server-scenario-modeler@769

@modelcontextprotocol/server-shadertoy

npm i https://pkg.pr.new/@modelcontextprotocol/server-shadertoy@769

@modelcontextprotocol/server-sheet-music

npm i https://pkg.pr.new/@modelcontextprotocol/server-sheet-music@769

@modelcontextprotocol/server-system-monitor

npm i https://pkg.pr.new/@modelcontextprotocol/server-system-monitor@769

@modelcontextprotocol/server-threejs

npm i https://pkg.pr.new/@modelcontextprotocol/server-threejs@769

@modelcontextprotocol/server-transcript

npm i https://pkg.pr.new/@modelcontextprotocol/server-transcript@769

@modelcontextprotocol/server-video-resource

npm i https://pkg.pr.new/@modelcontextprotocol/server-video-resource@769

@modelcontextprotocol/server-wiki-explorer

npm i https://pkg.pr.new/@modelcontextprotocol/server-wiki-explorer@769

commit: 4eab52e

They appear in App's public setRequestHandler / setNotificationHandler
signatures, so TypeDoc's link validation needs them reachable from the
entry point.
@ochafik
ochafik merged commit 218aef1 into main Sep 8, 2026
23 checks passed
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