Repository navigation
Closed
Closed
Copy link
Description
Stack: SDK V2 + New Spec — 1 of 10 (foundation; do this first).
Migrate the codebase from @modelcontextprotocol/[email protected] to SDK v2, keeping behavior identical against today's (legacy) servers. This is the behavior-neutral base that unblocks every other card in the stack: we're using SDK v2 underneath, with versionNegotiation: 'legacy' so nothing 2026-era goes on the wire yet.
Scope
- Package split:
@modelcontextprotocol/sdk→@modelcontextprotocol/client(Client, transports, OAuth) +@modelcontextprotocol/core(public Zod schemas); stdio transport moves to@modelcontextprotocol/client/stdio(root barrel stays browser-safe).WebSocketClientTransportis removed. - Run the codemod (
npx @modelcontextprotocol/codemod@beta v1-to-v2 .) per client, then hand-fix the rest. - Zod 3 → 4 (
^4.2.0). - Handlers take method strings, not schemas:
client.setRequestHandler('elicitation/create', …). Spec methods drop result schemas fromrequest()/callTool(); the raw "send request" path must pass an explicitResultSchemafrom core. - Error taxonomy rename:
McpError→ProtocolError; newSdkError(string codes:RequestTimeout,ConnectionClosed,EraNegotiationFailed, …);StreamableHTTPError→SdkHttpError(.status). Unknown-tool calls now reject with-32602instead of resolvingisError: true. - Elicitation
modediscriminant: branch onparams.mode === 'url'vs. form;ElicitResult.contentvalues strictlystring | number | boolean | string[]. Protocolbase class no longer exported; useclient.fallbackRequestHandlerfor arbitrary inbound requests.- Tasks note: requestor tasks currently ride
client.experimental.tasks.*(inspectorClient.ts:listRequestorTasks). That surface changes under v2 — keep legacy tasks working here; the modern redesign is card 8. - Set
versionNegotiation: { mode: 'legacy' }explicitly so this card changes no wire behavior.
Key files
core/mcp/inspectorClient.ts, core/mcp/remote/**, core/auth/**, clients/web|cli|tui/package.json, everywhere importing @modelcontextprotocol/sdk/*.
Acceptance
- All three clients behave exactly as today against existing legacy servers.
npm run cigreen (format, lint, build, per-file ≥90 coverage, smoke, storybook).
Ref: specification/v2_new_spec_impact.md §8.1, §9.5(1).
Activity
BobDickinson commentedon Jul 12, 2026
SDK v2 port — lessons from a spike
Notes from an exploratory port of Inspector to
@modelcontextprotocol/client/server/core(legacyversionNegotiation, behavior-neutral). Intended as implementation context for the migration work tracked above.Remove experimental tasks before the codemod
SDK v2 dropped the experimental tasks layer (
client.experimental.tasks.*, task stores, built-in task RPC). Inspector still has a Tasks tab, client task handlers/state, test-server task fixtures, and integration tests on the oldtasks/*wire.On the spike we tried to keep that behavior with local shims. That was the wrong trade: a lot of code, handler typing problems, and an API the SDK and protocol are moving away from anyway. Modern tasks (
io.modelcontextprotocol/tasks) are a separate follow-on.Next time: strip the Tasks UI, client task paths, test-server task fixtures, and related tests first, then run the codemod on a smaller tree. If the goal is to get a clean "legacy" port, having that without the experimental tasks should be fine. We can implement the new tasks extension as part of the future 07-28-2026 work.
Form schemas:
InspectorFormSchema+toFormSchema()Inspector’s web form utilities define a local type called
JsonSchemaType(clients/web/src/utils/jsonUtils.ts) — a subset tuned for whatSchemaFormrenders:enumNames,nullable, simpleproperties/items/oneOf, etc. It is not full Draft 2020-12 and it adds conveniences for the UI.SDK v2 also exports a type named
JsonSchemaType(from@modelcontextprotocol/client, viajson-schema-typed). Same name, different type definition. After the port, protocol objects use the SDK type — e.g.Tool["inputSchema"]is the SDK’sJsonSchemaType, not Inspector’s. The JSON on the wire is often unchanged; TypeScript correctly refuses to assign one to the other.On v1 this was mostly invisible: everything imported from
@modelcontextprotocol/sdkand the local form type could coexist without many boundary collisions. The split packages and SDK’s stricter schema typing surface the clash everywhere a tool schema crosses from MCP types into the form layer (Tools/Apps screens, elicitation panels,toolOutputValidationforoutputSchema).The spike added cast helpers (
asFormSchema,as unknown as JsonSchemaType) at those boundaries. Compiles, but merges two different type stories into one name.Next time:
InspectorFormSchemaso the name collision with the SDK is obvious.JsonSchemaTypefrom@modelcontextprotocol/clientanywhere you are modeling protocol/validation data.toFormSchema(...)— structural narrow from SDK schema fields toInspectorFormSchema | null, not a cast. Callers handlenullwhen the form cannot render a shape.Pick one canonical import for shared protocol symbols (
client, not mixed withserver).MCP Apps: one ext-apps compat module
@modelcontextprotocol/ext-appsstill peers on@modelcontextprotocol/sdkv1; published.d.tsfiles import v1Client/Toolpaths. After the port, Inspector uses v2 types from@modelcontextprotocol/client. Runtime is fine; TypeScript is not.The spike scattered
as unknown asatAppBridgeand helper call sites.Next time: a single compat module in core (bridge construction, UI resource URI from tool metadata, tool result forwarding), tested, with a note to delete when ext-apps#702 lands a v2 peer release.
Manifests — check every workspace
Inspector is fat-root + per-client
node_modules(rootpostinstallinstalls each client). The codemod updates some manifests; verify all of them.ext-appsclients/web,cli,tuiserver+server-legacyfor test-server vitest; web oftenclient+core.core/package.json; resolves from rootclients/launcherAfter edits:
npm installat root, grep for leftover@modelcontextprotocol/sdk, align lockfiles. Keepserver,server-legacy,nodeexternal in CLI/runner bundles.References
Merge pull request #1688 from modelcontextprotocol/v2/sdk-v2-migratio…
cliffhall commentedon Jul 16, 2026
Merged via #1688 (squash into v2/main, commit on v2/main). Auto-close does not fire for PRs targeting v2/main, so closing manually per AGENTS.md.
cliffhall commentedon Jul 16, 2026
Correction to the note above: #1688 was merged with a merge commit (
gh pr merge --merge), not squashed. Auto-close still does not fire for a PR targetingv2/main(non-default branch), which is why this was closed manually per AGENTS.md.SDK v2 migration (behavior-neutral, versionNegotiation: 'legacy') (mo…