# Connect Codex

> Let your agent do it: Connect Codex to my remote Hermitbox install through `hermitbox mcp`. Install the Hermitbox CLI on the machine running Codex, start Codex with `HERMITBOX_API_URL` and `HERMITBOX_API_KEY` in its private environment, and merge the page's `[mcp_servers.hermitbox]` table into `~/.codex/config.toml`; its `env_vars` passes the values without storing the key. After a restart, ask for the project's defaults, create a sandbox, run `echo hello` in it and delete it. Never copy the key into the file or this chat. Follow the exact steps in https://docs.hermitbox.dev/v0.3.2/integrations/codex.md.

Codex gets tools to create sandboxes, run commands in them, and snapshot, fork, sleep and
delete them, on a Hermitbox install on another machine, through `hermitbox mcp` over stdio.

On the machine where you ran the installer, skip this page: [Connect your
agent](https://docs.hermitbox.dev/v0.3.2/get-started/agents.md#codex) sets Codex up without a key.

1. Install the [Hermitbox CLI](https://docs.hermitbox.dev/v0.3.2/get-started/cli.md) on the machine running Codex.
2. Start Codex with `HERMITBOX_API_URL` and `HERMITBOX_API_KEY` in its private environment.
3. Merge this into `~/.codex/config.toml` and restart Codex. Ask it for the project's defaults, a
   sandbox, `echo hello` in it and cleanup. Supply an image only for a container default.

```toml
[mcp_servers.hermitbox]
command = "hermitbox"
args = ["mcp"]
env_vars = ["HERMITBOX_API_URL", "HERMITBOX_API_KEY"]
```

`env_vars` passes the named values without storing the key. The [Codex
reference](https://learn.chatgpt.com/docs/extend/mcp?surface=cli) also documents a project
`.codex/config.toml` in trusted projects. Host policy and [tier limits](https://docs.hermitbox.dev/v0.3.2/reference/tiers.md)
stay in force.
