diff --git a/registry/coder-labs/modules/codex/README.md b/registry/coder-labs/modules/codex/README.md index 67554aec..b43c6dd2 100644 --- a/registry/coder-labs/modules/codex/README.md +++ b/registry/coder-labs/modules/codex/README.md @@ -116,7 +116,7 @@ module "codex" { ``` > [!NOTE] -> Servers configured through `mcp` or `mcp_config_remote_path` are appended to `~/.codex/config.toml`, so they apply to every Codex session in the workspace. Each remote URL must return a body in Codex's native TOML format with one or more `[mcp_servers.]` sections; entries that don't contain a `[mcp_servers.*]` are rejected with a warning. +> Servers configured through `mcp` or `mcp_config_remote_path` are appended to `~/.codex/config.toml`, so they apply to every Codex session in the workspace. Each remote URL should return a body in Codex's native TOML format, e.g.: > > ```toml > [mcp_servers.my-tool] @@ -125,7 +125,7 @@ module "codex" { > type = "stdio" > ``` > -> A fetch failure (network error, non-2xx response, or invalid body) logs a warning and continues with the remaining URLs. +> Fetch failures (network errors or non-2xx responses) log a warning and the install continues with the remaining URLs. Bodies are appended verbatim without further validation, so make sure the URL returns valid Codex TOML. ### Serialize a downstream `coder_script` after the install pipeline diff --git a/registry/coder-labs/modules/codex/main.test.ts b/registry/coder-labs/modules/codex/main.test.ts index 573643e8..7125efbe 100644 --- a/registry/coder-labs/modules/codex/main.test.ts +++ b/registry/coder-labs/modules/codex/main.test.ts @@ -505,65 +505,6 @@ describe("codex", async () => { expect(configToml).toContain('command = "remote-mcp-cmd"'); }); - test("mcp-config-remote-path-invalid-toml", async () => { - const projectDir = "/home/coder/project"; - const moduleDir = path.resolve(import.meta.dir); - const state = await runTerraformApply(moduleDir, { - agent_id: "foo", - workdir: projectDir, - install_codex: "false", - mcp_config_remote_path: JSON.stringify(["file:///tmp/invalid-mcp.toml"]), - }); - const scripts = collectScripts(state); - const coderEnvVars = extractCoderEnvVars(state); - - const id = await runContainer("codercom/enterprise-node:latest"); - registerCleanup(async () => { - if (process.env["DEBUG"] === "true" || process.env["DEBUG"] === "1") { - console.log(`Not removing container ${id} in debug mode`); - return; - } - await removeContainer(id); - }); - - await execContainer(id, ["bash", "-c", `mkdir -p '${projectDir}'`]); - await writeExecutable({ - containerId: id, - filePath: "/usr/bin/coder", - content: "#!/bin/bash\nexit 0\n", - }); - await writeExecutable({ - containerId: id, - filePath: "/usr/bin/codex", - content: await Bun.file( - path.join(moduleDir, "testdata", "codex-mock.sh"), - ).text(), - }); - // Fetched body has no [mcp_servers.*] section — the install script should - // reject it rather than appending random content to config.toml. - await execContainer(id, [ - "bash", - "-c", - `cat > /tmp/invalid-mcp.toml <<'EOF'\nnot_a_valid_mcp_section = true\nEOF`, - ]); - - await runScripts(id, scripts, coderEnvVars); - - const installLog = await readFileContainer( - id, - "/home/coder/.coder-modules/coder-labs/codex/logs/install.log", - ); - expect(installLog).toContain( - "Warning: Invalid MCP configuration from 'file:///tmp/invalid-mcp.toml'", - ); - - const configToml = await readFileContainer( - id, - "/home/coder/.codex/config.toml", - ); - expect(configToml).not.toContain("not_a_valid_mcp_section"); - }); - test("custom-config-drops-reasoning-effort", async () => { const baseConfig = [ 'sandbox_mode = "danger-full-access"', diff --git a/registry/coder-labs/modules/codex/scripts/install.sh.tftpl b/registry/coder-labs/modules/codex/scripts/install.sh.tftpl index a99880fd..1920beff 100644 --- a/registry/coder-labs/modules/codex/scripts/install.sh.tftpl +++ b/registry/coder-labs/modules/codex/scripts/install.sh.tftpl @@ -164,10 +164,6 @@ function populate_config_toml() { echo "Warning: Failed to fetch MCP configuration from '$${url}', continuing..." continue } - if ! echo "$${mcp_toml}" | grep -qE '^[[:space:]]*\[mcp_servers\.'; then - echo "Warning: Invalid MCP configuration from '$${url}' (missing [mcp_servers.*] section), continuing..." - continue - fi printf "Appending MCP servers from %s\n" "$${url}" printf '\n%s\n' "$${mcp_toml}" >> "$${config_path}" done