Skip to content

Commit d3ed889

Browse files
yazelinclaude
andcommitted
Fix mcpServers env format for Gemini ACP compatibility
Gemini expects env as array of "KEY=value" strings, not object. Also ensure args and env are always present (empty array if not set). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 697ff2f commit d3ed889

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

nodejs/src/protocols/acp/acp-adapter.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,27 @@ class AcpConnection implements ProtocolConnection {
151151
const config = params as SessionConfig & { workingDirectory?: string };
152152
const acpParams = copilotSessionConfigToAcpParams(config);
153153
// ACP requires cwd and mcpServers (as array)
154+
// Gemini expects env as array of "KEY=value" strings
155+
const mcpServers = acpParams.mcpServers
156+
? Object.entries(acpParams.mcpServers).map(([name, serverConfig]) => {
157+
const envArray: string[] = serverConfig.env
158+
? Object.entries(serverConfig.env).map(
159+
([key, value]) => `${key}=${value}`
160+
)
161+
: [];
162+
return {
163+
name,
164+
command: serverConfig.command,
165+
args: serverConfig.args ?? [],
166+
env: envArray,
167+
};
168+
})
169+
: [];
154170
return {
155171
acpMethod: "session/new",
156172
acpParams: {
157173
cwd: acpParams.cwd || process.cwd(),
158-
mcpServers: acpParams.mcpServers
159-
? Object.entries(acpParams.mcpServers).map(([name, config]) => ({
160-
name,
161-
...config,
162-
}))
163-
: [],
174+
mcpServers,
164175
},
165176
};
166177
}

0 commit comments

Comments
 (0)