---
title: "Connect Clam to Codex"
description: "One terminal command adds your Shell to Codex. Sign in to Clam, click Allow, and Codex uses your Gmail only as far as your rules allow."
route: /docs/agents/codex
---

# Connect Clam to Codex

One terminal command adds your Shell to Codex. Sign in to Clam, click Allow, and Codex can use your Gmail only as far as the Shell's rules allow. No Shell yet? Start with the [Quickstart](https://useclam.ai/docs/get-started/quickstart).

Codex talks to Clam over MCP, the standard way an AI agent plugs in an outside tool. Each Shell is its own MCP server, so a second Shell installs beside the first.

## Connect Codex

Three ways in. Start with the first; the others are for when it doesn't fit.

### Terminal sign-in (Recommended)

The simplest path: one command, and Codex opens your browser to sign in. Pick this unless your machine has no browser.

1. Paste this in your terminal

   On the Shell's **Install** tab, pick Codex and copy the command under **Sign in from the terminal**. It has your server name and address filled in. Then press Enter.

   ```bash
   codex mcp add <server name> --url <your Shell's address>
   ```

2. Sign in to Clam and Allow

   Your browser opens on Clam, asking to connect your Shell to Codex. Its window is titled "Let ChatGPT use a Shell". Sign in if you need to, then click **Allow**.

Then click **Check connection** on the Install tab.

### Access key

For a machine with no browser, like a server you reach over SSH. The key works only for Codex, and you see it once. Codex reads it from a variable named after the server, so two Shells' keys never overwrite each other.

1. Paste these in your terminal

   Copy the commands under **Use a key** on the Install tab. Copying creates the key and fills it in. Then press Enter. Put the first line in your shell profile too, so a new terminal window keeps the key.

   ```bash
   export <key variable>=<your key>
   codex mcp add <server name> --url <your Shell's address> --bearer-token-env-var <key variable>
   ```

2. Open Codex and run /mcp

   Run `/mcp`. You should see your server in the list.

Then click **Check connection** on the Install tab.

### config.toml file

For anyone who prefers editing the config file by hand. Same result as the terminal sign-in.

1. Add this block to ~/.codex/config.toml

   Anywhere in the file. Create it if it isn't there.

   ```toml
   [mcp_servers.<server name>]
   url = "<your Shell's address>"
   ```

2. Sign in to Clam and Allow

   Start Codex. Your browser opens on Clam, asking to connect your Shell to Codex. Its window is titled "Let ChatGPT use a Shell". Sign in if you need to, then click **Allow**.

Then click **Check connection** on the Install tab.

## Try it

With the starter policy from the Quickstart, ask Codex:

Ask "Summarize the work email I got this week." Codex answers from your work email. Ask "Find my latest bank statement." Clam blocks it, and Codex tells you so. That refusal is Clam working as intended.

If Codex holds other mail tools, name the Shell in the prompt.

## Remove access

Run `codex mcp remove <server name>`, or delete the block from `config.toml`. That only tidies Codex. Clam's removal is the one that counts: on the Install tab, under Connected agents, click **Remove access** for Codex. A sign-in stops at its next request; a key at once. More in [Remove access](https://useclam.ai/docs/trust/remove-access).

## Next steps

- Not in the /mcp list, paused, or lost access? [Common issues & solutions](https://useclam.ai/docs/troubleshooting)
- [Write your own rules](https://useclam.ai/docs/policies/writing-effective-policies)
- [Have Codex ask before it acts](https://useclam.ai/docs/trust/approvals)
