Skip to content

refactor(cli): squirrel channel on the v2 MCP SDK, drop @modelcontextprotocol/sdk v1 (#570) - #654

Merged
nc9 merged 3 commits into
mainfrom
fix/channel-sdk-v2-570
Oct 11, 2026
Merged

nc9 merged 3 commits into
mainfrom
fix/channel-sdk-v2-570

Conversation

@nc9

@nc9 nc9 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Closes #570

The two boxes left on #570 after #572: the CLI still depended on @modelcontextprotocol/sdk v1, because squirrel channel imported the v1 Server and StdioServerTransport.

Change

  • apps/cli/src/channel/server.ts now uses the v2 low-level Server from @modelcontextprotocol/server, connected straight to StdioServerTransport from @modelcontextprotocol/server/stdio (not serveStdio). It sets supportedProtocolVersions to the 2025-era versions only (CHANNEL_PROTOCOL_VERSIONS). Connected this way, the v2 Server negotiates through initialize and installs no server/discover handler, so the channel keeps the legacy handshake that Claude Code needs to register it. Lifecycle, oninitialized, the custom notifications/claude/channel notification, instructions and experimental["claude/channel"] are unchanged.
  • apps/cli/package.json drops @modelcontextprotocol/sdk ^1.31.0. bun.lock loses it and its HTTP stack (express, hono, cors, and others).
  • Third-party notices: the v2 SDK bundles ajv 8 and a few helpers into its own dist. The generator only walks declared dependencies, so those notices had been coming along by accident through the v1 SDK's declared deps. The generator now finds packages a runtime dependency bundles, from the bundler's node_modules/.pnpm/<name>@<version> source markers. It records them from committed texts under scripts/third-party-embedded/ (taken from the npm tarballs) and fails if one is missing. The notices now list [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] and @cfworker/[email protected].
  • Docs: docs/cli/channel.mdx gets a "Protocol version" section, and docs/cli/mcp.mdx names the channel as the exception to the two-era support. CHANGELOG [Unreleased] has a Changed entry.

Verification

  • tests/channel/server.test.ts and tests/channel/e2e.test.ts now run on the v2 client, 12/12 passing.
    • New test: an auto-negotiating client lands on legacy with the channel capability, and a client pinned to 2026-07-28 is refused.
    • The e2e now uses an auto-negotiating client over real stdio and asserts getProtocolEra() === "legacy". Mutation check: connecting the channel through serveStdio turns it modern, and the e2e fails.
  • tests/mcp/protocol.test.ts and tests/mcp/server.test.ts pass (18), so squirrel mcp still serves both eras.
  • apps/cli: tsgo --noEmit, oxlint and oxfmt --check are clean. notices:check passes (67 packages) and fails when a bundled package's text is missing. make validate in docs passes. bun build --compile succeeds.
  • Two codex passes; the one P2 (the bundled-license gap) is fixed above.

Hold-list note: this removes a runtime dependency (@modelcontextprotocol/sdk) and changes the lockfile, so it needs a human decision before merge. The private gitlink bump that picks this up has to regenerate the root bun.lock.

Skill: no change needed.

@nc9
nc9 marked this pull request as ready for review October 11, 2026 12:51
@claude

claude Bot commented Oct 11, 2026

Copy link
Copy Markdown

Review of #654 (channel moved to the v2 MCP SDK, v1 SDK dropped).

I read the full diff but did not run the tests or the notices generator. The changes look sound.

  • (low) apps/cli/src/channel/server.ts: CHANNEL_PROTOCOL_VERSIONS filters with a string compare, v < "2026-07-28". That works for ISO dates. A later SDK that adds a differently formatted version string would break it silently. The unit test asserts the same invariant, so it would be caught.
  • (low) scripts/generate-third-party-notices.ts: bundled.replace("/", "__") only replaces the first slash. That is fine for scoped names. The regex only matches the @scope+name form and replace("+", "/") is also first-only. Both are fine today.
  • (nit) scripts/generate-third-party-notices.ts: bundledPackages reads every .js/.mjs/.cjs file of every dependency. If this gets slow, restrict it to the dist directories.
  • (nit) apps/cli/tests/channel/server.test.ts: the final expect(connect(...)).rejects.toThrow() is not awaited. Add await so a failure can't slip past the test.

Positives: the e2e test pins getProtocolEra() to legacy with an auto-negotiating client. The generator fails when a bundled package has no committed license text. The docs and CHANGELOG are updated.

@nc9
nc9 force-pushed the fix/channel-sdk-v2-570 branch from 794f1e8 to b22d96b Compare October 11, 2026 13:31
@claude

claude Bot commented Oct 11, 2026

Copy link
Copy Markdown

Review of #654 (channel moved to MCP SDK v2).

No blocking problems found. I read the diff only. I did not run the tests or the notices generator.

  • (low) apps/cli/src/channel/server.ts: CHANNEL_PROTOCOL_VERSIONS filters with a string comparison (v < "2026-07-28"). That works for ISO dates. If a future SDK adds non-date entries, they would be filtered by accident. An explicit denylist, or an assertion that the result is non-empty, would be sturdier. The new unit test does already check that 2025-11-25 is present.
  • (nit) scripts/generate-third-party-notices.ts: bundled.replace("/", "__") and match[1].replace("+", "/") replace only the first occurrence. That is fine for scoped package names, but replaceAll would show the intent better.
  • (nit) scripts/generate-third-party-notices.ts: bundled packages are found by scanning dist files for node_modules/.pnpm/... region comments. This depends on the bundler's comment format. If the format changes, the scan finds nothing and passes quietly. A sanity check that @modelcontextprotocol/server still yields at least one bundled package would catch that.
  • Good: the tests now cover both halves of the contract. An auto-negotiating client lands on the legacy era, and a client pinned to 2026-07-28 is rejected. The e2e test also asserts getProtocolEra() === "legacy".
  • Good: the v1 SDK dependency is removed, and nothing else in the repo still imports @modelcontextprotocol/sdk.
  • Good: the docs for channel and mcp are updated and cross-linked.

🤖 Generated with Claude Code

@nc9

nc9 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Replies to the 13:32 review on b22d96b:

  • (low) CHANNEL_PROTOCOL_VERSIONS filters by string compare: this is deliberate. It matches the SDK's own split: isModernProtocolVersion in @modelcontextprotocol/server is version >= FIRST_MODERN_PROTOCOL_VERSION, the same date-string comparison, and MCP protocol versions are YYYY-MM-DD by spec. The non-empty case is already pinned: tests/channel/server.test.ts asserts the list contains 2025-11-25 and that every entry is before 2026-07-28, and the e2e asserts the live channel lands on the legacy era.
  • (nit) the notices scan going silent if the bundler's marker format changes: this is a fair point, but it's a separate guard, so I've filed it as notices: fail when a known bundling dependency yields no bundled packages #657 and kept it out of this PR to avoid another review round.

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.

feat: move squirrel mcp to MCP protocol 2026-07-28 (SDK v2)

1 participant