Files
codex/codex-rs/codex-mcp
Jay Chen 66618f0512 Prewarm MCP servers during cloud catalog refresh (#62876)
## Why

A slow cloud skill lookup can delay MCP startup even after the plugin
catalog is ready. If the refresh is canceled while waiting for skills,
it can miss the chance to prewarm those servers before the first turn.

## What changed

Queue MCP prewarm as soon as plugin discovery changes or clears the
catalog. Skill discovery alone leaves the MCP server set unchanged.

At the end of the refresh, queue a retry for eligible MCP startup
failures. If discovery is canceled, check for those failures the next
time the catalog lock is acquired. Reuse pending handshakes and leave
authentication failures and Apps-managed reconnects to their existing
recovery paths.

## Testing

Add regression tests for first-turn tool availability after cancellation,
startup recovery with cloud plugins disabled, and a single retry for a
persistent startup failure.

GitOrigin-RevId: f92162d1629358953d8810d20244e55f07416a01
2026-11-21 00:54:05 +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.