# Codex CLI

> Add DarkCrawl to the Codex CLI so it can read .onion pages for you.

Works with OpenAI Codex CLI

**Hosted**

1. [Get a key](https://darkcrawl.dev/docs/build-with-ai/get-a-key/), then set it in your environment as `DARKCRAWL_API_KEY`. Start Codex from a terminal where it is set.

2. Add the server to `~/.codex/config.toml`. Codex reads the key from the variable named in `bearer_token_env_var`, so the file never holds it.

   ```toml
   [mcp_servers.darkcrawl]
   url = "https://api.darkcrawl.dev/mcp"
   bearer_token_env_var = "DARKCRAWL_API_KEY"
   ```

3. Check it. Ask Codex to list the tools DarkCrawl gives it. You should see the tools on the [MCP page](https://darkcrawl.dev/docs/mcp/).

**On your own server**

1. [Run DarkCrawl](https://darkcrawl.dev/docs/run-it-yourself/) on your own machine. The commands below point at it at `http://127.0.0.1:3002`.

2. Install the `darkcrawl` command with its MCP extra, from the repository root.

   ```bash
   uv tool install --reinstall --python 3.13 '.[mcp]'
   ```

3. Add the server. Run this in a terminal, and put your key in place of `YOUR_API_KEY`. Codex saves the server in `~/.codex/config.toml`.

   ```bash
   codex mcp add darkcrawl --env DARKCRAWL_API_KEY=YOUR_API_KEY -- darkcrawl --url http://127.0.0.1:3002 mcp
   ```

4. Ask Codex to list the tools DarkCrawl gives it. You should see the tools on the [MCP page](https://darkcrawl.dev/docs/mcp/).

OpenAI and Codex are trademarks of OpenAI.
