Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.163.0
What subscription do you have?
Not relevant. This is a local configuration command.
Which model were you using?
Not relevant. The command does not start a model turn.
What platform is your computer?
Linux x86_64
What terminal emulator and version are you using?
zsh 5.9. The terminal does not matter here because the command is non-interactive.
Codex doctor report
Not included because this reproduction uses an isolated CODEX_HOME and does not depend on machine state.
What issue are you seeing?
codex mcp get docs --json omits required when the server is configured with required = true. The command exits successfully and prints the other server settings, so users and scripts cannot determine from this output whether the server is required.
The CLI reference says this command prints the raw config entry: https://learn.chatgpt.com/docs/cli/reference
What steps can reproduce the bug?
Run this with Codex CLI 0.163.0:
test_home="$(mktemp -d)" && printf '%s\n' '[mcp_servers.docs]' 'command = "printf"' 'required = true' > "$test_home/config.toml" && CODEX_HOME="$test_home" codex mcp get docs --jsonThe output is:
{
"name": "docs",
"enabled": true,
"disabled_reason": null,
"transport": {
"type": "stdio",
"command": "printf",
"args": [],
"env": null,
"env_vars": [],
"cwd": null
},
"enabled_tools": null,
"disabled_tools": null,
"startup_timeout_sec": null,
"tool_timeout_sec": null
}required is absent.
What is the expected behavior?
The JSON should include the configured value:
"required": trueAdditional information
McpServerConfig retains this value in codex-rs/config/src/mcp_types.rs:244-248:
codex/codex-rs/config/src/mcp_types.rs
Lines 244 to 248 in 2a77e82
| /// When `true`, `codex exec` exits with an error if this MCP server fails to initialize. | |
| /// With `startup_readiness = "catalog"`, a valid cached catalog can satisfy startup; | |
| /// connection failures are then reported when a tool is invoked. | |
| #[serde(default, skip_serializing_if = "std::ops::Not::not")] | |
| pub required: bool, |
run_get manually builds the JSON object in codex-rs/cli/src/mcp_cmd.rs:999-1012 and does not copy server.required:
codex/codex-rs/cli/src/mcp_cmd.rs
Lines 999 to 1012 in 2a77e82
| let output = serde_json::to_string_pretty(&serde_json::json!({ | |
| "name": get_args.name, | |
| "enabled": server.enabled, | |
| "disabled_reason": server.disabled_reason.as_ref().map(ToString::to_string), | |
| "transport": transport, | |
| "enabled_tools": server.enabled_tools.clone(), | |
| "disabled_tools": server.disabled_tools.clone(), | |
| "startup_timeout_sec": server | |
| .startup_timeout_sec | |
| .map(|timeout| timeout.as_secs_f64()), | |
| "tool_timeout_sec": server | |
| .tool_timeout_sec | |
| .map(|timeout| timeout.as_secs_f64()), | |
| }))?; |
The smallest fix is to add "required": server.required to that object and cover it with an integration test that loads required = true and checks the JSON output.
Activity
akhil9tiet commentedon Oct 22, 2026
I'd like to work on this — please assign it to me.
LeizhenZhang commentedon Oct 26, 2026
Still present on
mainat 970111f (2026-10-23), Linux x86_64, built from source.Exit 0, and the JSON has
name,enabled,disabled_reason,transport,enabled_tools,disabled_tools,startup_timeout_sec,tool_timeout_sec.grep -c requiredon the output gives 0.The root cause in the report is right:
run_getincodex-rs/cli/src/mcp_cmd.rs(lines 999-1012 at 970111f) builds the object by hand and never readsserver.required. The same holds forcodex mcp list --json(run_list, lines 763-775), which also omitsrequired, so a script cannot get the flag from either command.Patch
Regression test
get_json_reports_required_flagincodex-rs/cli/tests/mcp_list.rswrites the config above, runscodex mcp get docs --jsonandcodex mcp list --json, and assertsrequired == truein both.requiredassertion (NonevsSome(Bool(true))).list_and_get_render_expected_outputtest compares the fullmcp list --jsonobject, so its expectation gains"required": false. All 8 tests incli/tests/mcp_list.rspass.