Files
codex/codex-rs/codex-mcp
jif c260087efe Avoid blocking EMA auth status checks on account refresh (#56127)
## Why

EMA MCP auth status checks acquired an account grant lease, making status inspection wait for account refresh coordination or an existing lease.

## What changed

Add `AuthManager::account_oauth_grant()` to inspect an owner-checked grant without acquiring the refresh lock. Use it for EMA status checks and share a single lazy read across servers, including missing grants and read errors. Keep refresh exclusion for token exchanges through `lease_account_oauth_grant()`.

## Testing

Add regression coverage for status checks across two EMA servers while an account lease is held. Extend account refresh tests to verify inspection completes with a lease held and refresh queued, and returns no grant after logout.

GitOrigin-RevId: 921214dd552eb216c713596f2737460053a07d08
2026-10-22 09:37:28 +00:00
..

Codex MCP runtime

This crate manages Codex's MCP connections, tool calls, and their captured authority.

Sandbox request metadata

An MCP server advertises the experimental codex/sandbox-state capability to receive sandbox metadata on tool calls. The deprecated capability name codex/sandbox-state-meta opts into the same contract during migration.

Codex supplies these entries in the request's _meta object:

Key Value
codex/sandbox-state Opaque policy to pass to codex sandbox --sandbox-state-json.
codex/sandbox-state-meta An identical copy of that policy under the deprecated name.
codex/sandbox-launcher When available, an object with an absolute codexExecutable path to a verified full Codex CLI on the MCP server's host.

Use the launcher path to invoke sandbox --sandbox-state-json with the entire state value serialized as one argument, followed by -- and the command to run. The state contains neither launcher discovery data nor deprecation messages. Preserve unknown policy fields by forwarding the original value rather than deserializing and reconstructing it. The two state names are aliases, not separate policies; new consumers should prefer codex/sandbox-state.

Launcher metadata is currently available only for local stdio servers. An HTTP endpoint, including loopback, or a remote executor does not establish a shared filesystem with the harness. Codex omits the launcher when its path is unknown, not representable as UTF-8, or fails the cached capability probe. Absence does not authorize a PATH search or unsandboxed fallback. Servers that require a launcher must fail closed or require an explicit operator opt-out.

The state and launcher describe the issuing call. Retain both when starting a long-lived subprocess or caching policy-bound results; reject changed authority before reusing them. Tool arguments supplied by the model are not authority. See sandbox_metadata.rs for the wire types and binding.rs for execution-environment selection.