Skip to content

codex mcp get --json omits the configured required flag #56057

Open

Description

@mertkayacs

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 --json

The 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": true

Additional information

McpServerConfig retains this value in codex-rs/config/src/mcp_types.rs:244-248:

/// 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:

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

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    mcpIssues related to the use of model context protocol (MCP) servers
    configIssues involving config.toml, config keys, config merging, or config updates
    on Oct 22, 2026
  2. akhil9tiet commented on Oct 22, 2026

    @akhil9tiet

    I'd like to work on this — please assign it to me.

  3. LeizhenZhang commented on Oct 26, 2026

    @LeizhenZhang

    Still present on main at 970111f (2026-10-23), Linux x86_64, built from source.

    printf '%s\n' '[mcp_servers.docs]' 'command = "printf"' 'required = true' > "$CODEX_HOME/config.toml"
    codex mcp get docs --json

    Exit 0, and the JSON has name, enabled, disabled_reason, transport, enabled_tools, disabled_tools, startup_timeout_sec, tool_timeout_sec. grep -c required on the output gives 0.

    The root cause in the report is right: run_get in codex-rs/cli/src/mcp_cmd.rs (lines 999-1012 at 970111f) builds the object by hand and never reads server.required. The same holds for codex mcp list --json (run_list, lines 763-775), which also omits required, so a script cannot get the flag from either command.

    Patch

    --- a/codex-rs/cli/src/mcp_cmd.rs
    +++ b/codex-rs/cli/src/mcp_cmd.rs
    @@ async fn run_list(
                     serde_json::json!({
                         "name": name,
                         "enabled": cfg.enabled,
    +                    "required": cfg.required,
                         "disabled_reason": cfg.disabled_reason.as_ref().map(ToString::to_string),
    @@ async fn run_get(
             let output = serde_json::to_string_pretty(&serde_json::json!({
                 "name": get_args.name,
                 "enabled": server.enabled,
    +            "required": server.required,
                 "disabled_reason": server.disabled_reason.as_ref().map(ToString::to_string),

    Regression test get_json_reports_required_flag in codex-rs/cli/tests/mcp_list.rs writes the config above, runs codex mcp get docs --json and codex mcp list --json, and asserts required == true in both.

    • Before the patch: fails at the required assertion (None vs Some(Bool(true))).
    • After the patch: passes. The existing list_and_get_render_expected_output test compares the full mcp list --json object, so its expectation gains "required": false. All 8 tests in cli/tests/mcp_list.rs pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't workingconfigIssues involving config.toml, config keys, config merging, or config updatesmcpIssues related to the use of model context protocol (MCP) servers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions