Skip to content

refactor: upgrade MCP client to SDK v2 packages - #449

Merged
LeXwDeX merged 6 commits into
devfrom
refactor/447-upgrade-mcp-client
Aug 25, 2026
Merged

refactor: upgrade MCP client to SDK v2 packages#449
LeXwDeX merged 6 commits into
devfrom
refactor/447-upgrade-mcp-client

Conversation

@LeXwDeX

@LeXwDeXLeXwDeX commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Closes#447
Closes#448

Why

The MCP ecosystem moved: the 2026-07-28 specification is stateless (no initialize handshake, no Mcp-Session-Id, server/discover era probing), and the TypeScript SDK v2 (@modelcontextprotocol/client@2.0.0) implements it with built-in era negotiation and automatic fallback. We were pinned to @modelcontextprotocol/sdk@1.29.0 (v1, maintenance-only). Rather than building a v1↔v2 bridge process, the SDK's versionNegotiation covers both worlds: one v2 code path, legacy servers transparently supported.

What changed

#447 — SDK v2 migration (behavior-preserving)

  • Dependency swap: @modelcontextprotocol/sdk@modelcontextprotocol/client@2.0.0 + core@2.0.0 (server dev-only for tests); workspace zod ^4.2.0; stale v1 patch entry and patch file removed
  • SSE transport fallback removed from connectRemote — Streamable HTTP failure is terminal
  • Handler registration via method strings (roots/list, elicitation/create, notifications/message, notifications/tools/list_changed); callTool schema-arg drop; test mocks re-pointed to the v2 package root

#448 — configurable 2026-07-28 era negotiation

  • ConfigMCPV1 local/remote entries gain optional protocol: "auto" | "legacy" | "modern" (default auto); JS SDK types regenerated
  • createClient maps it to ClientOptions.versionNegotiation: auto probes server/discover with conservative fallback to the 2025 handshake; legacy skips the probe; modern pins 2026-07-28 with no fallback
  • mcp auth diagnostics mirror the same mapping; elicitation handler verified compatible with 2026-era input_required auto-fulfilment (no code change needed)

Evidence

  • bun typecheck (packages/opencode): exit 0; root turbo typecheck 29/29
  • bun test test/mcp: 92/92 pass (83 migrated + 9 new in protocol.test.ts covering parsing + versionNegotiation mapping)
  • Root bun run lint: 4814 / 4850 warnings (pre-change baseline 4833 → zero new; budget not weakened)
  • test:httpapi: 230 pass / 0 fail / 0 missing; SDK check:generated diff is exactly the +2 protocol? lines
  • DAG workflow dag_fe5fc6f72541xbogE0yDEGwLXU: explore → migrate → era → verify (PASS) → review (PASS, 0 blocking / 7 informational, all informational items addressed in aa3fda5)

Behavior notes (for release notes)

  • SSE-only (pre-2025-03-26) remote servers no longer connect — protocol: "legacy" does not help there; such servers must upgrade to Streamable HTTP
  • v2 removes transparent 404 session recovery: an expired-session POST now surfaces SdkHttpError (CLIENT_HTTP_NOT_IMPLEMENTED, status 404) instead of silently re-initializing; session-recovery.test.ts documents the new contract
  • Follow-up candidates (out of scope): opencode-side transparent session recovery; config_assistant Go JSON schema embed has no freshness gate

@LeXwDeX
LeXwDeX changed the base branch from main to devAugust 25, 2026 13:07
…tiation
- swap @modelcontextprotocol/sdk@1.29.0 for @modelcontextprotocol/client@2.0.0
(+core, server dev-only); workspace zod ^4.2.0; drop stale v1 patch
- remove StreamableHTTP->SSE fallback; Streamable HTTP failure is terminal
- handler registration moved to method strings; oauth-provider types from
client root; test mocks re-pointed to the v2 package root
- ConfigMCPV1 local/remote gain optional protocol: auto|legacy|modern,
mapped to ClientOptions.versionNegotiation (default auto probes
server/discover with 2025 fallback; modern pins 2026-07-28)
- regenerate JS SDK types; mcp auth diagnostics mirror the era mapping
- behavior note: v2 removes transparent 404 session recovery and SSE-only
(pre-2025-03-26) servers no longer connect; protocol: legacy is the
escape hatch
Closes#447Closes#448
@LeXwDeX
LeXwDeX marked this pull request as ready for review August 25, 2026 14:04
@LeXwDeX
LeXwDeX merged commit f1bb127 into devAug 25, 2026
12 checks passed
@LeXwDeX
LeXwDeX deleted the refactor/447-upgrade-mcp-client branch August 25, 2026 15:06
Sign up for freeto 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.

feat: adopt MCP 2026-07-28 protocol with era negotiation refactor: upgrade MCP client to SDK v2 packages

1 participant

@LeXwDeX