openai/codex · error · anyhow::Error
No MCP server named '{name}' found.
Error message
No MCP server named '{name}' found. What it means
`codex mcp login <name>` resolves the server by exact key lookup in the configured mcp_servers map before starting the OAuth flow. A missing key bails immediately with the name you passed; nothing is written and no browser flow starts.
Source
Thrown at codex-rs/cli/src/mcp_cmd.rs:545
));
Ok(McpManager::new(plugins_manager))
}
async fn run_login(config: &Config, login_args: LoginArgs) -> Result<()> {
let mcp_manager = load_mcp_manager(config).await?;
let mcp_servers = mcp_manager.configured_servers(config).await;
let LoginArgs {
name,
scopes,
oauth_client_registration,
} = login_args;
let client_registration = oauth_client_registration
.map(McpOAuthClientRegistration::from)
.unwrap_or_default();
let Some(server) = mcp_servers.get(&name) else {
bail!("No MCP server named '{name}' found.");
};
let (url, http_headers, env_http_headers) = match &server.transport {
McpServerTransportConfig::StreamableHttp {
url,
http_headers,
env_http_headers,
..
} => (url.clone(), http_headers.clone(), env_http_headers.clone()),
_ => bail!("OAuth login is only supported for streamable HTTP servers."),
};
// Standalone `mcp login` runs OAuth from the local CLI process; execution
// environment routing belongs to app-server and session MCP flows.
let http_client: Arc<dyn HttpClient> = Arc::new(
RouteAwareHttpClient::new(config.http_client_factory()).with_tls_backend_fallback(),
);
let http_client = apply_http_headers_helper(http_client, server, config.cwd.to_path_buf())View on GitHub (pinned to 339751715c)
Solutions
- List configured servers and copy the exact key: `codex mcp list`.
- Add it first if missing: `codex mcp add <name> --url https://...`, then `codex mcp login <name>`.
- Match the name byte-for-byte — the lookup is case-sensitive.
- Confirm you are running against the right CODEX_HOME/profile.
Example fix
# before codex mcp login contex7 # typo: server is context7 # after codex mcp list # copy the exact name codex mcp login context7 # or add it first if missing: codex mcp add context7 --url https://mcp.context7.com/mcp codex mcp login context7
Defensive patterns
Strategy: validation
Validate before calling
mcp_login() {
local name="$1"
codex mcp list 2>/dev/null | grep -Fw -- "$name" >/dev/null || {
echo "no MCP server named '$name' configured; run: codex mcp add $name --url <url>" >&2
return 2
}
codex mcp login "$name"
} Try / catch
if ! codex mcp login "$name" 2>err.log; then
if grep -q 'No MCP server named' err.log; then
codex mcp list # surface valid names so the caller can retry with the exact key
fi
exit 1
fi Prevention
- Derive server names from `codex mcp list` output rather than docs or memory
- Add and login in the same script so the key cannot drift
- Treat server names as case-sensitive identifiers in automation
When it happens
Trigger: `codex mcp login context7` when no server with that exact key is configured — typo, different casing, server configured in another profile/CODEX_HOME, or never added.
Common situations: Transcribing a name from docs with different casing or spacing; the server was added under a different key via `codex mcp add`; multiple config files or profiles so `codex mcp list` in another environment shows the server; stale tutorials referencing renamed servers.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- command is required
- exactly one of --command or --url must be provided
- `--remote-auth-token-env` is only supported for interactive
- `--strict-config` is not supported for `codex {subcommand}`
- environment variable `{env_var_name}` is not set
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/a734bbe14915878b.
Report an issue: GitHub.