fix(docs): clarify MCP configuration handling and fetch failure logging
This commit is contained in:
parent
b27dabe83f
commit
af2cc72e44
@ -116,7 +116,7 @@ module "codex" {
|
|||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!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.<name>]` 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
|
> ```toml
|
||||||
> [mcp_servers.my-tool]
|
> [mcp_servers.my-tool]
|
||||||
@ -125,7 +125,7 @@ module "codex" {
|
|||||||
> type = "stdio"
|
> 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
|
### Serialize a downstream `coder_script` after the install pipeline
|
||||||
|
|
||||||
|
|||||||
@ -505,65 +505,6 @@ describe("codex", async () => {
|
|||||||
expect(configToml).toContain('command = "remote-mcp-cmd"');
|
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 () => {
|
test("custom-config-drops-reasoning-effort", async () => {
|
||||||
const baseConfig = [
|
const baseConfig = [
|
||||||
'sandbox_mode = "danger-full-access"',
|
'sandbox_mode = "danger-full-access"',
|
||||||
|
|||||||
@ -164,10 +164,6 @@ function populate_config_toml() {
|
|||||||
echo "Warning: Failed to fetch MCP configuration from '$${url}', continuing..."
|
echo "Warning: Failed to fetch MCP configuration from '$${url}', continuing..."
|
||||||
continue
|
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 "Appending MCP servers from %s\n" "$${url}"
|
||||||
printf '\n%s\n' "$${mcp_toml}" >> "$${config_path}"
|
printf '\n%s\n' "$${mcp_toml}" >> "$${config_path}"
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user