Repository navigation
feat(cli): move squirrel mcp to MCP SDK v2 for protocol 2026-07-28 - #572
Conversation
Serve over serveStdio so one process answers 2026-07-28 clients (no initialize, server/discover) and 2025-era clients. Drop @modelcontextprotocol/sdk v1. Tool names, descriptions and schemas are unchanged apart from the JSON Schema dialect. Document supported protocol versions. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the diff. CI is green, and
The channel path (a) fixture and the pinned-version refusal test are good coverage for #571. No security concerns: the dependency set shrinks, with express and hono removed. |
Signed-off-by: Nik Cubrilovic <[email protected]>
|
Thanks for the review. Pushed d2a119d for the points below.
Re-ran |
|
Reviewed the diff. The migration is mechanical and consistent: imports moved to
Tests: moving from private |
|
Both lows were already handled in d2a119d.
The two nits (long comment lines in |
What changed and why
squirrel mcpmoves from@modelcontextprotocol/sdkv1 (1.32.1) to the v2 SDK (@modelcontextprotocol/server2.3.1). v1 will not support MCP revision 2026-07-28 (noinitialize,server/discover), and Claude Code's v2 runtime asks stdio servers for that revision by default.runMcpServernow usesserveStdio(() => createMcpServer()), which picks the era from the client's first message and serves 2026-07-28 and 2025-era clients from one process.z.object(...)(v2 requires Standard Schema objects;inputSchema: {}no longer typechecks). Imports moved to@modelcontextprotocol/server. Nothing undersrc/mcpimports v1.@modelcontextprotocol/clientis a dev dependency, used by tests andscripts/mcp-smoke.tsonly._requestHandlers/_registeredToolsnow drive it through a realClientover a linked in-memory transport.docs/cli/mcp.mdx.THIRD_PARTY_NOTICESregenerated (v2 is Apache-2.0; the v1 transitive express/hono deps are gone).The hosted server is migrating separately.
The channel question: path (a)
squirrel channel(#571) must stay on the legacy handshake, because Claude Code refuses to register a channel server that negotiates 2026-07-28. The v2 SDK can do this. A hand-wiredServer+StdioServerTransport(noserveStdio) is 2025-era only. Checked against a real stdio child on v2.3.1 (tests/mcp/protocol.test.ts, fixturetests/mcp/fixtures/legacy-only-server.ts):autonegotiation mode lands on the legacy era (2025-11-25),oninitializedfires, theexperimental["claude/channel"]capability is advertised;Server.notification()andoninitializedexist in v2, which is what feat(cli): add squirrel channel to push cloud audit events into Claude Code #571'ssendChannelEventand poll-loop start use.How #571 should switch after both merge:
Serverfrom@modelcontextprotocol/serverandStdioServerTransportfrom@modelcontextprotocol/server/stdio.server.connect(new StdioServerTransport()). Do not useserveStdiothere: it would also serve 2026-07-28.package.jsonshould depend on@modelcontextprotocol/serverand not re-add@modelcontextprotocol/sdk. Its tests'Client/InMemoryTransportimports move to@modelcontextprotocol/client.Until #571 switches it still imports v1, so whichever merges second needs a trivial rebase of
apps/cli/package.jsonandbun.lock. I did not touch the channel module. The legacy-only test in this PR will fail if a future SDK changes that behavior.Acceptance criteria
squirrel mcpserves a 2026-07-28 client (noinitialize,server/discover) and a 2025-11-25 client from the same binary:tests/mcp/protocol.test.ts("serves a 2025-era client...", "serves a 2026-07-28 client with no initialize", "an auto-negotiating client lands on 2026-07-28", "both eras list identical tools", plus an in-process 2026 tool call).@modelcontextprotocol/sdkv1: removed fromapps/cli/package.jsonandbun.lock;grep -rn modelcontextprotocol/sdk apps/cli/src apps/cli/tests apps/cli/scriptsis empty. The channel can drop it too, see path (a) above.squirrel channelstill negotiates the legacy handshake: not verifiable here, the channel lives in feat(cli): add squirrel channel to push cloud audit events into Claude Code #571. This PR proves the v2 SDK supports it (legacy-only test) and leaves the module alone. To be ticked once feat(cli): add squirrel channel to push cloud audit events into Claude Code #571 switches.scripts/mcp-smoke.tsandtests/mcp/*pass against both protocol versions. The smoke script takes--protocol legacy|2026-07-28; both runs list the same 15 tools andlist_rulesreturns 297. Thequick_checkandaudit_websitecalls return an error in the sandbox (no outbound network), identical in both eras.docs/cli/mcp.mdx, "Supported protocol versions".Tool surface unchanged
I dumped
tools/listfrommain(v1) and from this branch (v2) over stdio. Names, titles, descriptions, input properties,requiredand annotations are identical. Two wire differences come from the SDK, not from this change: the schema dialect is now JSON Schema 2020-12 ($schemawas draft-07, SEP-2106), and v1'sexecution.taskSupport: "forbidden"marker is no longer emitted.Verification
In
apps/cliunless noted:bun run typecheck: cleanbun test tests/mcp/server.test.ts tests/mcp/entity-tools.test.ts tests/mcp/report-tools.test.ts tests/mcp/feedback-tools.test.ts tests/mcp/cloud.test.ts: 72 passbun test tests/mcp/scopes.test.ts tests/mcp/protocol.test.ts tests/cli: 158 passbun scripts/mcp-smoke.ts https://example.com --protocol legacyand--protocol 2026-07-28: as abovebun run lint,bun run format:check: clean;bun run notices:generatecommittedcd docs && make validate: all checks passedShell completions: no CLI surface change, none needed.
Agent skill
Does the squirrelscan agent skill need a change? No. Tool names, descriptions and schemas are unchanged and no commands or flags changed; the skill only restates those.
Risk
Runtime dependency change (SDK major). Clients that only speak the 2025-era handshake are covered by the legacy tests; 2026-07-28 clients by the pinned-era tests.
Refs #570. Deliberately not
Closes: the third criterion stays open until #571 switches to the v2Server.Generated by Claude Code