Skip to content

MCP startup suggests codex mcp login for bearer-token auth failures #26760

Open

Description

@sanjumsanthosh

What version of Codex CLI is running?

0.137.0

What subscription do you have?

Enterprise

Which model were you using?

gpt-5.5

What platform is your computer?

Darwin 25.5.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

iTerm2

Codex doctor report

What issue are you seeing?

Codex currently shows misleading remediation for some MCP startup auth failures.

For remote MCP servers configured with bearer_token_env_var, a startup failure that contains Auth required is currently surfaced as:

Codex currently shows misleading remediation for some MCP startup auth failures.

That message reads like an OAuth-login problem, but for bearer-token-configured servers the real issue is more likely that the configured token is missing, expired, invalid, or rejected by the server.

fn mcp_init_error_display(
server_name: &str,
entry: Option<&McpAuthStatusEntry>,
err: &StartupOutcomeError,
) -> String {
if let Some(McpServerTransportConfig::StreamableHttp {
url,
bearer_token_env_var,
http_headers,
..
}) = entry.and_then(|entry| entry.config.as_ref().map(|config| &config.transport))
&& url == "https://api.githubcopilot.com/mcp/"
&& bearer_token_env_var.is_none()
&& http_headers.as_ref().map(HashMap::is_empty).unwrap_or(true)
{
format!(
"GitHub MCP does not support OAuth. Log in by adding a personal access token (https://github.com/settings/personal-access-tokens) to your environment and config.toml:\n[mcp_servers.{server_name}]\nbearer_token_env_var = CODEX_GITHUB_PERSONAL_ACCESS_TOKEN"
)
} else if is_mcp_client_auth_required_error(err) {
format!(
"The {server_name} MCP server is not logged in. Run `codex mcp login {server_name}`."
)
} else if is_mcp_client_startup_timeout_error(err) {
let startup_timeout_secs = match entry {
Some(entry) => match entry
.config
.as_ref()
.and_then(|config| config.startup_timeout_sec)
{
Some(timeout) => timeout,
None => DEFAULT_STARTUP_TIMEOUT,
},
None => DEFAULT_STARTUP_TIMEOUT,
}
.as_secs();
format!(
"MCP client for `{server_name}` timed out after {startup_timeout_secs} seconds. Add or adjust `startup_timeout_sec` in your config.toml:\n[mcp_servers.{server_name}]\nstartup_timeout_sec = XX"
)
} else {
format!("MCP client for `{server_name}` failed to start: {err:#}")
}
}

So any startup error containing Auth required gets mapped to the codex mcp login hint, even when the server is configured to use bearer-token auth.

What steps can reproduce the bug?

  1. Configure a remote MCP server with bearer_token_env_var in ~/.codex/config.toml.
  2. Set that environment variable to a bearer token value.
  3. Make the token invalid for the server, for example by using an expired or rejected token.
  4. Start Codex or trigger MCP server startup.
  5. Observe that Codex reports the server as “not logged in” and suggests codex mcp login instead of pointing to the configured bearer token as the likely source of the failure.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    bug
    on Jun 6, 2026
  2. added
    CLI
    mcp
    auth
    on Jun 6, 2026
  3. xinyu-dev commented on Jun 7, 2026

    @xinyu-dev

    Same here

  4. Necmttn commented on Jun 21, 2026

    @Necmttn

    The remediation branch can probably key off the configured auth mode before looking at the error text.

    If the MCP server has bearer_token_env_var, an Auth required startup failure should name the server and env var, for example:

    MCP server <name> rejected bearer-token auth.
    Check that <ENV_VAR> is set and accepted by the server.
    

    Only servers configured for OAuth should point users at codex mcp login <server>. A regression test can cover the same response body under both auth modes so the generic substring match does not override the configured credential type.


    Generated with ax.

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

    CLIauthbugmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions