Skip to content

Codex CLI

Connect OpenAI’s Codex CLI to LatchGate so every tool call goes through the execution security kernel.

  • LatchGate running (latchgate up or production deployment)
  • latchgate-mcp binary on PATH (from GitHub Releases or brew install latchgate-ai/tap/latchgate)
  • Codex CLI installed (npm install -g @openai/codex)
Terminal window
latchgate-mcp install --ide codex

This writes the MCP server entry to ~/.codex/config.toml under [mcp_servers.latchgate]. Restart Codex to pick up the configuration.

Preview first without writing:

Terminal window
latchgate-mcp install --ide codex --dry-run

Note: If you set CODEX_HOME to a custom directory, latchgate-mcp install respects it.

Add to ~/.codex/config.toml:

[mcp_servers.latchgate]
command = "/usr/local/bin/latchgate-mcp"
args = ["serve", "--gate-url", "http://localhost:3000"]
[mcp_servers.latchgate.env]
LATCHGATE_AGENT_ID = "codex"
RUST_LOG = "warn"

Adjust the binary path if installed elsewhere. Use which latchgate-mcp to find it.

Alternatively, use the Codex CLI to register the server:

Terminal window
codex mcp add latchgate \
--env LATCHGATE_AGENT_ID=codex \
--env RUST_LOG=warn \
-- latchgate-mcp serve --gate-url http://localhost:3000
  1. Start LatchGate: latchgate up
  2. Install config: latchgate-mcp install --ide codex
  3. Run codex and use /mcp to confirm latchgate appears.
  4. Ask the agent to perform an HTTP request.
  5. Verify the audit trail: latchgate audit --limit 5
  6. Confirm the full pipeline: lease => policy => WASM sandbox => receipt.

Replace --gate-url with UDS + public base URL for production:

[mcp_servers.latchgate]
command = "/usr/local/bin/latchgate-mcp"
args = ["serve", "--public-base-url", "http://localhost:3000"]
[mcp_servers.latchgate.env]
LATCHGATE_AGENT_ID = "codex"
RUST_LOG = "warn"

For production hardening with UDS transport, see Deployment.