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;