Skip to content

Commit 6d19e69

Browse files
committed
Allow disabling MCP config filtering
1 parent 196152b commit 6d19e69

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/CodexAcpClient.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ export class CodexAcpClient {
4747
private readonly codexClient: CodexAppServerClient;
4848
private readonly config: JsonObject;
4949
private readonly modelProvider: string | null;
50+
private readonly disableMcpConfigFiltering: boolean;
5051
private gatewayConfig: GatewayConfig | null;
5152
private pendingLoginCompleted: Promise<AccountLoginCompletedNotification> | null = null;
5253
private pendingAccountUpdated: Promise<AccountUpdatedNotification> | null = null;
5354
private readonly sessionNotificationQueues = new Map<string, Promise<void>>();
5455

5556

56-
constructor(codexClient: CodexAppServerClient, codexConfig?: JsonObject, modelProvider?: string) {
57+
constructor(codexClient: CodexAppServerClient, codexConfig?: JsonObject, modelProvider?: string, disableMcpConfigFiltering = false) {
5758
this.codexClient = codexClient;
5859
this.config = codexConfig ?? {};
5960
this.modelProvider = modelProvider ?? null;
61+
this.disableMcpConfigFiltering = disableMcpConfigFiltering;
6062
this.gatewayConfig = null;
6163
}
6264

@@ -314,7 +316,9 @@ export class CodexAcpClient {
314316

315317
// Deduplicates new servers against existing config to prevent Codex from deep-merging
316318
// incompatible field types (e.g., mixing url and stdio schemas).
317-
const existingNames = await this.getConfigMcpServerNames(projectPath);
319+
const existingNames = this.disableMcpConfigFiltering
320+
? new Set<string>()
321+
: await this.getConfigMcpServerNames(projectPath);
318322
const requestedServers = mcpServers.map(mcp => ({
319323
name: sanitizeMcpServerName(mcp.name),
320324
server: mcp,

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function startAcpServer() {
4242
const configString = process.env["CODEX_CONFIG"];
4343
const authRequestString = process.env["DEFAULT_AUTH_REQUEST"];
4444
const modelProvider = process.env["MODEL_PROVIDER"];
45+
const disableMcpConfigFiltering = process.env["DISABLE_MCP_CONFIG_FILTERING"] === "true";
4546
const config = configString ? JSON.parse(configString) : undefined;
4647
const parsedAuthRequest = authRequestString ? JSON.parse(authRequestString) : undefined;
4748
const defaultAuthRequest = parsedAuthRequest && isCodexAuthRequest(parsedAuthRequest) ? parsedAuthRequest : undefined;
@@ -72,7 +73,7 @@ function startAcpServer() {
7273

7374
function createAgent(connection: acp.AgentSideConnection): CodexAcpServer {
7475
const appServerClient = new CodexAppServerClient(codexConnection.connection);
75-
const codexClient = new CodexAcpClient(appServerClient, config, modelProvider);
76+
const codexClient = new CodexAcpClient(appServerClient, config, modelProvider, disableMcpConfigFiltering);
7677
return new CodexAcpServer(connection, codexClient, defaultAuthRequest, () => codexConnection.process.exitCode);
7778
}
7879

0 commit comments

Comments
 (0)