From 85a0d6c6f111119855b0e199801a9f71b60f50bf Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Sat, 21 Nov 2026 15:55:13 +0100 Subject: [PATCH] fix: update to @agentclientprotocol/sdk 2.9.1 (#1690) Updates `@agentclientprotocol/sdk` from 2.9.0 to 2.9.1 (schema v2.0.0-beta.3). The release has two changes, and both come from the review for #1687. ## A relative stdio MCP `command` is rejected on v2 ACP v2 requires the `command` of a stdio MCP server to be an absolute path, and an Agent rejects a relative one with `-32602`. SDK 2.9.1 does that in `assertSupportedMcpServers` (agentclientprotocol/typescript-sdk#361), which the adapter already calls for `session/new`, `session/resume` and `session/fork` on v2. So this needs no adapter code. A v2 client that sends a bare command name, such as `npx`, now gets `-32602` with `{ name, command }` before anything is created, resumed or copied. It has to send the full path. v1 does not require an absolute path and is unchanged. The SDK accepts a path that is absolute in POSIX or in Windows syntax, because it does not know which machine the Agent runs on. A path in the other system's syntax passes the check and fails when Claude Code starts the server, like any missing executable. - The existing test of rejected MCP server lists is now an `it.each` with the relative `command` as a second case, over new, resume with and without replay, and fork. - The doc comment of `v1McpServers` and the README's v2 section say it. ## Markdown in descriptions The schema change is description text only: the `description` of an authentication method, a command, a config option and each of its values, a permission request and a subagent may contain Markdown on v2 (agentclientprotocol/agent-client-protocol#2974). The adapter already sends Markdown in some of them, such as the remote login method's ``Run `claude /login` in the terminal``, so nothing changes. ## Tests `npm run build`, `npm run check` and `npm run test:run` pass (4,434 tests). Against the real Claude Code CLI, the whole suite ran with 4,461 passed and one suite not run: the `tsc` step in the `beforeAll` of "ACP subprocess integration" hit its 10 second limit twice, on a machine with a load average above 50. That suite's five tests pass when it runs alone. --- README.md | 4 ++++ package-lock.json | 8 ++++---- package.json | 2 +- src/tests/v2/acp-v2.test.ts | 30 ++++++++++++++++++++---------- src/v1/acp-agent.ts | 2 +- src/v2/session-requests.ts | 4 +++- 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2671fe7d..cb90b1a7 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ with replay, which `replay_complete` ends, `session/close`, `session/prompt`, `s compaction, display terminals for commands, permission requests, elicitation, providers, auth, and [subagents](docs/subagent-sessions.md). Steering is v1 only for now. +On v2, the `command` of a stdio MCP server must be an absolute path, such as `/usr/local/bin/npx`. +`session/new`, `session/resume` and `session/fork` fail with `-32602` for a relative one, such as +`npx`. A v1 client can still send one. + `session/prompt` takes an `idempotencyKey`: a prompt that a client sends again with the same key is inserted once, and the retry gets the first `messageId`. The key is known for as long as Claude Code stores the message, also after a restart. A prompt that Claude Code does not store, such as a diff --git a/package-lock.json b/package-lock.json index 584cefd4..a3bcf1cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.109.0", "license": "Apache-2.0", "dependencies": { - "@agentclientprotocol/sdk": "2.9.0", + "@agentclientprotocol/sdk": "2.9.1", "@anthropic-ai/claude-agent-sdk": "0.3.328", "diff": "9.0.0", "zod": "4.6.7" @@ -38,9 +38,9 @@ } }, "node_modules/@agentclientprotocol/sdk": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-2.9.0.tgz", - "integrity": "sha512-/mc3zQ8C8YwqERefM50/QUxMpbiA7D9UpKoav/P74jF3dJa+j+/fQZCpFsYGbnYzQRJMyQx+nP0zAOVgLCmiBQ==", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-2.9.1.tgz", + "integrity": "sha512-8iJdxGa3SunLfzqLLb3RfQFmr4hnmWeAyeAK6MbkJiXJbrRlMRgKsVnDl/7Hu48yu/30gAlytNDzh5W77rv5SA==", "license": "Apache-2.0", "peerDependencies": { "@modelcontextprotocol/server": "^2.4.0", diff --git a/package.json b/package.json index 663e9f64..e597c093 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "node": ">=22" }, "dependencies": { - "@agentclientprotocol/sdk": "2.9.0", + "@agentclientprotocol/sdk": "2.9.1", "@anthropic-ai/claude-agent-sdk": "0.3.328", "diff": "9.0.0", "zod": "4.6.7" diff --git a/src/tests/v2/acp-v2.test.ts b/src/tests/v2/acp-v2.test.ts index 5913eb91..b966ff73 100644 --- a/src/tests/v2/acp-v2.test.ts +++ b/src/tests/v2/acp-v2.test.ts @@ -615,22 +615,32 @@ describe("ACP v2 sessions", () => { expect(sdk.queryOptions).toHaveLength(0); }); - it("rejects two MCP servers with the same name in new, resume, and fork", async () => { + it.each<{ name: string; mcpServers: v2.McpServer[]; data: Record }>([ + { + name: "two MCP servers with the same name", + mcpServers: [ + { type: "stdio", name: "files", command: "/usr/local/bin/mcp-files" }, + { type: "http", name: "files", url: "https://mcp.example.com/mcp" }, + ], + data: { name: "files" }, + }, + { + name: "a stdio MCP server whose command is not an absolute path", + mcpServers: [{ type: "stdio", name: "files", command: "npx", args: ["mcp-files"] }], + data: { name: "files", command: "npx" }, + }, + ])("rejects $name in new, resume, and fork", async ({ mcpServers, data }) => { const { app, authUpdate } = v2Client(); - const mcpServers: v2.McpServer[] = [ - { type: "stdio", name: "files", command: "/usr/local/bin/mcp-files" }, - { type: "http", name: "files", url: "https://mcp.example.com/mcp" }, - ]; - const duplicate = { code: -32602, data: { name: "files" } }; + const invalid = { code: -32602, data }; await app.connectWith(connectRouter(), async (agent) => { await initializeV2(agent); await expect( agent.request(v2.methods.agent.session.new, { cwd, mcpServers }), - ).rejects.toMatchObject(duplicate); + ).rejects.toMatchObject(invalid); const { sessionId } = await agent.request(v2.methods.agent.session.new, { cwd }); await expect( agent.request(v2.methods.agent.session.resume, { sessionId, cwd, mcpServers }), - ).rejects.toMatchObject(duplicate); + ).rejects.toMatchObject(invalid); await expect( agent.request(v2.methods.agent.session.resume, { sessionId, @@ -638,10 +648,10 @@ describe("ACP v2 sessions", () => { mcpServers, replayFrom: { type: "start" }, }), - ).rejects.toMatchObject(duplicate); + ).rejects.toMatchObject(invalid); await expect( agent.request(v2.methods.agent.session.fork, { sessionId, cwd, mcpServers }), - ).rejects.toMatchObject(duplicate); + ).rejects.toMatchObject(invalid); await authUpdate(1); }); // Only the session without MCP servers started. diff --git a/src/v1/acp-agent.ts b/src/v1/acp-agent.ts index e3000efe..6560fbfc 100644 --- a/src/v1/acp-agent.ts +++ b/src/v1/acp-agent.ts @@ -9470,7 +9470,7 @@ export class ClaudeAcpAgent { * * Call it in the same synchronous step as the handler's `return`: an * `await` between them would let the timer run before the response. The ACP - * SDK (2.9.0) gives a request handler no responder and no after-response + * SDK (2.9.1) gives a request handler no responder and no after-response * hook, so the order rests on two things that its source shows and its API * does not promise. `registerAppRequest` queues the response in the * microtask that follows the handler's return, with no macrotask in diff --git a/src/v2/session-requests.ts b/src/v2/session-requests.ts index 919b1c0a..60984a10 100644 --- a/src/v2/session-requests.ts +++ b/src/v2/session-requests.ts @@ -135,7 +135,9 @@ export function v2AvailableCommands(commands: AvailableCommand[]): v2.AvailableC * list. A request with two servers of the same `name`, or with a transport * that the agent does not advertise in `session.mcp` (such as a custom `_` * type), fails with invalid params (-32602): `sdkMcpServers` would otherwise - * drop the server without telling the client. + * drop the server without telling the client. So does a stdio server whose + * `command` is not an absolute path, such as `npx`, which v2 requires. The + * SDK's `assertSupportedMcpServers` checks all three. */ function v1McpServers(servers: v2.McpServer[] | null | undefined): McpServer[] | undefined { if (servers == null) return undefined;