@devries-cameron20 / t3code-1 / commits / 3f1b132e97
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(acp): give Command Code T3's MCP endpoint over HTTP (#34004)

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>

ajinkyajacob committed Nov 15, 2026 at 10:10 UTC 3f1b132e970f698562b1a12749b94f8ac8fc1e0d
5 files changed +169 -3
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
+33 -1
@@ -1259,7 +1259,7 @@ describe("AcpRegistryAdapterV2", () => {
1259 }).pipe(Effect.provide(layerTest)),
1260 );
1261
1262 - it.effect("gives Copilot T3's MCP server over HTTP when it advertises HTTP", () =>
1262 + it.effect("gives HTTP-capable agents T3's MCP server over HTTP", () =>
1263 Effect.gen(function* () {
1264 const selfInvocation = yield* resolveSelfInvocation();
1265 const mockAgentPath = yield* (yield* Path.Path).fromFileUrl(
@@ -1345,6 +1345,14 @@ describe("AcpRegistryAdapterV2", () => {
1345 };
1346 return { new: sent("session/new"), load: sent("session/load") };
1347 });
1348 + const plainHttp = (authorization: string) => [
1349 + {
1350 + type: "http",
1351 + name: "t3-code",
1352 + url: endpoint,
1353 + headers: [{ name: "Authorization", value: authorization }],
1354 + },
1355 + ];
1356 const http = (authorization: string) => [
1357 {
1358 type: "http",
@@ -1389,6 +1397,30 @@ describe("AcpRegistryAdapterV2", () => {
1397 new: stdio("Bearer opened-token"),
1398 load: stdio("Bearer rotated-token"),
1399 });
1400 + // Command Code cannot start the stdio bridge on Windows: it spawns MCP commands through
1401 + // cmd.exe, which splits the unquoted T3 executable path at the space.
1402 + const commandCode = {
1403 + source: "local",
1404 + commandPath: "C:\\tools\\cmdc.exe",
1405 + commandArgs: ["acp"],
1406 + };
1407 + // Command Code is not Copilot: no deferred tool-exposure header.
1408 + assert.deepEqual(yield* sessionMcpServers(commandCode, { T3_ACP_MCP_HTTP: "1" }), {
1409 + new: plainHttp("Bearer opened-token"),
1410 + load: plainHttp("Bearer rotated-token"),
1411 + });
1412 + assert.deepEqual(yield* sessionMcpServers(commandCode), {
1413 + new: stdio("Bearer opened-token"),
1414 + load: stdio("Bearer rotated-token"),
1415 + });
1416 + // Any other local agent keeps the stdio bridge.
1417 + assert.deepEqual(
1418 + yield* sessionMcpServers(
1419 + { source: "local", commandPath: "C:\\tools\\node.exe", commandArgs: ["agent.mjs"] },
1420 + { T3_ACP_MCP_HTTP: "1" },
1421 + ),
1422 + { new: stdio("Bearer opened-token"), load: stdio("Bearer rotated-token") },
1423 + );
1424 }).pipe(Effect.provide(layerTest)),
1425 );
1426
packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+49
@@ -23,6 +23,7 @@ import * as ChildProcess from "effect/process/ChildProcess";
23 import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
24
25 import * as AcpRegistrySupport from "./AcpRegistrySupport.ts";
26 +import { prefersHttpMcpTransport } from "./mcpTransport.ts";
27 import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
28
29 const registryUrl = "https://registry.test/registry.json";
@@ -336,6 +337,54 @@ describe("AcpRegistrySupport", () => {
337 ),
338 );
339
340 + it.effect("resolves the local Command Code configurations the HTTP selector matches", () =>
341 + Effect.gen(function* () {
342 + const fileSystem = yield* FileSystem.FileSystem;
343 + const cacheDir = yield* fileSystem.makeTempDirectoryScoped({
344 + prefix: "t3-acp-command-code-",
345 + });
346 + const catalog = (executable: string) =>
347 + AcpRegistrySupport.makeAcpRegistryCatalog({
348 + cacheDir,
349 + toolsDir: `${cacheDir}/tools`,
350 + registryUrl,
351 + }).pipe(
352 + Effect.provideService(HostProcess.Platform, "win32"),
353 + Effect.provideService(SpawnExecutableResolution, () => executable),
354 + );
355 +
356 + const bare = decodeAcpRegistrySettings({ source: "local", commandPath: "cmdc" });
357 + expect(prefersHttpMcpTransport(bare)).toBe(true);
358 + expect(
359 + yield* (yield* catalog("C:\\bin\\cmdc.exe")).resolve(bare, "/workspace"),
360 + ).toMatchObject({ spawn: { command: "C:\\bin\\cmdc.exe", shell: false } });
361 + // A bare name that PATHEXT resolves to a batch shim never launches, so the transport it
362 + // selects cannot matter: there is no session to attach MCP servers to.
363 + expect(
364 + yield* (yield* catalog("C:\\bin\\cmdc.cmd")).resolve(bare, "/workspace").pipe(Effect.flip),
365 + ).toMatchObject({ reason: "runner_unavailable" });
366 +
367 + const vendored = decodeAcpRegistrySettings({
368 + source: "local",
369 + commandPath: "node.exe",
370 + commandArgs: [
371 + "C:\\Users\\me\\.t3\\bin\\cmdcode\\node_modules\\command-code\\dist\\index.mjs",
372 + "acp",
373 + ],
374 + });
375 + expect(prefersHttpMcpTransport(vendored)).toBe(true);
376 + expect(
377 + yield* (yield* catalog("C:\\Program Files\\nodejs\\node.exe")).resolve(
378 + vendored,
379 + "/workspace",
380 + ),
381 + ).toMatchObject({ spawn: { command: "C:\\Program Files\\nodejs\\node.exe" } });
382 + }).pipe(
383 + Effect.scoped,
384 + Effect.provide(layerResolver(() => Effect.die("unexpected registry request"))),
385 + ),
386 + );
387 +
388 it.effect("reports missing or non-executable local commands without registry fallback", () =>
389 Effect.gen(function* () {
390 const fileSystem = yield* FileSystem.FileSystem;
packages/provider-acp-registry/src/server/adapter.ts
+7 -2
@@ -17,6 +17,7 @@ import {
17 isCopilotLostSessionError,
18 makeCopilotSubagentRouting,
19 } from "./copilotAcp.ts";
20 +import { prefersHttpMcpTransport } from "./mcpTransport.ts";
21 import { defaultInstanceIdForDriver, ProviderDriverKind } from "@t3tools/contracts";
22 import { readCustomModelEntries } from "@t3tools/shared/model";
23 import { AcpRegistrySettings } from "../settings.ts";
@@ -221,6 +222,11 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
222 }
223 : options;
224 const copilotRouting = isCopilot ? makeCopilotSubagentRouting() : undefined;
225 + // Copilot CLI 1.0.105 rejects stdio MCP servers from the client, and Command Code cannot
226 + // start the stdio bridge on Windows (it spawns MCP commands through cmd.exe, which splits
227 + // the unquoted "T3 Code (Beta).exe" path). Both take T3's MCP endpoint over ACP HTTP.
228 + const useHttpMcpServers =
229 + copilotRouting !== undefined || prefersHttpMcpTransport(options.settings);
230 const flavor: AcpAdapterV2Flavor = {
231 driver: ACP_REGISTRY_PROVIDER,
232 // Cancelling a Copilot prompt also kills the background agents it started.
@@ -268,8 +274,6 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
274 ? {}
275 : {
276 clientCapabilitiesMeta: copilotClientCapabilitiesMeta,
271 - // Copilot CLI 1.0.105 rejects stdio MCP servers from the client.
272 - mcpOverHttp: true,
277 deferMcpTools: true,
278 registerExtensions: copilotRouting.registerExtensions,
279 normalizeSessionUpdate: copilotRouting.normalizeSessionUpdate,
@@ -278,6 +282,7 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
282 // session/new reports a built-in default, not the model Copilot runs (github/copilot-cli#5363).
283 alwaysSetModel: true,
284 }),
285 + mcpOverHttp: useHttpMcpServers,
286 makeRuntime: options.makeRuntime ?? makeAcpRegistryRuntime(runtimeOptions, catalog),
287 ...(runtimeCoordinator === undefined
288 ? {}
packages/provider-acp-registry/src/server/mcpTransport.test.ts new
+53
@@ -0,0 +1,53 @@
1 +import { describe, expect, it } from "@effect/vitest";
2 +import * as Schema from "effect/Schema";
3 +
4 +import { AcpRegistrySettings } from "../settings.ts";
5 +import { prefersHttpMcpTransport } from "./mcpTransport.ts";
6 +
7 +const decodeSettings = Schema.decodeSync(AcpRegistrySettings);
8 +
9 +const local = (commandPath: string, commandArgs: string[] = []) =>
10 + decodeSettings({ source: "local", commandPath, commandArgs });
11 +
12 +describe("prefersHttpMcpTransport", () => {
13 + it("uses HTTP for the vendored Command Code launcher", () => {
14 + expect(
15 + prefersHttpMcpTransport(
16 + local("C:\\Users\\me\\.t3\\bin\\cmdcode\\node.exe", [
17 + "C:\\Users\\me\\.t3\\bin\\cmdcode\\node_modules\\command-code\\dist\\index.mjs",
18 + "acp",
19 + ]),
20 + ),
21 + ).toBe(true);
22 + expect(
23 + prefersHttpMcpTransport(
24 + local("C:\\tools\\node.exe", ["C:\\src\\command-code\\dist\\cli.mjs", "acp"]),
25 + ),
26 + ).toBe(true);
27 + });
28 +
29 + it("uses HTTP for the global Command Code executable", () => {
30 + expect(prefersHttpMcpTransport(local("C:\\tools\\cmdc.exe", ["acp"]))).toBe(true);
31 + expect(prefersHttpMcpTransport(local("/usr/local/bin/cmdc"))).toBe(true);
32 + });
33 +
34 + it("keeps the stdio bridge for a batch shim T3 refuses to launch", () => {
35 + expect(prefersHttpMcpTransport(local("C:\\tools\\cmdc.cmd", ["acp"]))).toBe(false);
36 + });
37 +
38 + it("keeps the stdio bridge for other local agents", () => {
39 + expect(
40 + prefersHttpMcpTransport(
41 + local("C:\\tools\\node.exe", ["C:\\tools\\some-other-agent\\dist\\index.mjs", "acp"]),
42 + ),
43 + ).toBe(false);
44 + expect(prefersHttpMcpTransport(local("C:\\tools\\claude-agent-acp.exe"))).toBe(false);
45 + expect(prefersHttpMcpTransport(local("C:\\tools\\command-code\\runner.mjs"))).toBe(false);
46 + });
47 +
48 + it("keeps the stdio bridge for registry agents", () => {
49 + expect(
50 + prefersHttpMcpTransport(decodeSettings({ source: "registry", agentId: "claude-acp" })),
51 + ).toBe(false);
52 + });
53 +});
packages/provider-acp-registry/src/server/mcpTransport.ts new
+27
@@ -0,0 +1,27 @@
1 +import type { AcpRegistrySettings } from "../settings.ts";
2 +
3 +// AcpRegistrySupport.validateLocalExecutable refuses .cmd/.bat on Windows, so only native
4 +// executables are launchable.
5 +const COMMAND_CODE_EXECUTABLES = /^(?:cmdc|command-code|commandcode)(?:\.exe)?$/iu;
6 +const COMMAND_CODE_ENTRY_POINTS = [
7 + /(?:^|[\\/])node_modules[\\/]command-code[\\/]/iu,
8 + /(?:^|[\\/])command-code[\\/]dist[\\/](?:index|cli)\.mjs$/iu,
9 +];
10 +
11 +/**
12 + * Agents that take T3's MCP endpoint over ACP HTTP: Command Code cannot start the stdio
13 + * bridge on Windows, where it spawns MCP commands through cmd.exe and the unquoted T3
14 + * executable path splits at the space.
15 + */
16 +export function prefersHttpMcpTransport(settings: AcpRegistrySettings): boolean {
17 + if (settings.source !== "local") {
18 + return false;
19 + }
20 + const executable = settings.commandPath.split(/[\\/]/u).pop() ?? "";
21 + return (
22 + COMMAND_CODE_EXECUTABLES.test(executable) ||
23 + settings.commandArgs.some((argument) =>
24 + COMMAND_CODE_ENTRY_POINTS.some((pattern) => pattern.test(argument)),
25 + )
26 + );
27 +}