---
title: Connect Hive to Codex CLI
lastUpdated: '2026-06-03'
nextjs:
  metadata:
    title: "Install Hive in Codex CLI | Crypto MCP Setup"
    description: "Connect Codex CLI to Hive's remote MCP endpoint for live crypto prices, DeFi, wallets, and token security tools."
    alternates:
      canonical: https://www.hiveintelligence.xyz/install/codex
    keywords: "codex cli crypto, openai codex mcp, hive codex, codex mcp server, codex config.toml mcp"
---

**Connect Codex CLI to Hive through `~/.codex/config.toml`.** Use remote HTTP with `bearer_token_env_var` so the Hive key stays in your environment, then start a new Codex session and verify Hive appears in `/mcp`. {% .lead %}

{% ai-doc-actions path="/install/codex" title="Codex CLI Install Guide" /%}

---

## Before you start

1. Codex CLI installed: `npm install -g @openai/codex` (or `bun install -g @openai/codex`). Verify with `codex --version`.
2. A Hive API key from [/dashboard/keys](/dashboard/keys).

Codex stores its config at `~/.codex/config.toml`. Create the file if it doesn't exist.

---

## Option 1: Remote HTTP (recommended)

Codex's `mcp_servers` table speaks streamable HTTP natively when you set `url`. Pair it with `bearer_token_env_var` so your key isn't written to disk.

Export the key in your shell profile (`~/.zshrc`, `~/.bashrc`, or `~/.config/fish/config.fish`):

```bash
export HIVE_API_KEY="your_hive_api_key"
```

Then add this to `~/.codex/config.toml`:

```toml
[mcp_servers.hive]
url = "https://mcp.hiveintelligence.xyz/mcp"
bearer_token_env_var = "HIVE_API_KEY"
```

Codex reads `HIVE_API_KEY` at session start and sends `Authorization: Bearer …` on every request to `mcp.hiveintelligence.xyz`. The remote HTTP path does not run a local Node wrapper or re-download an npm package on each start.

If you prefer to inline the key (not recommended for shared dotfiles), use `http_headers` instead:

```toml
[mcp_servers.hive]
url = "https://mcp.hiveintelligence.xyz/mcp"
http_headers = { Authorization = "Bearer YOUR_HIVE_API_KEY" }
```

## Option 2: Local stdio wrapper

If your machine can't reach `mcp.hiveintelligence.xyz` directly (corporate proxy, air-gapped setup), spawn the wrapper as a subprocess. Requires Node 20+.

```toml
[mcp_servers.hive]
command = "npx"
args = ["-y", "-p", "hive-intelligence@latest", "hive"]
env = { HIVE_API_KEY = "YOUR_HIVE_API_KEY" }
```

The wrapper still authenticates with `Authorization: Bearer` upstream — it's the same auth path, just routed through your local Node.

### Verify it worked

Start a new Codex session:

```bash
codex
```

Then ask:

> *"What is the current price of BTC, ETH, and SOL?"*

Codex should call Hive's `get_price` tool and surface the result inline. If you don't see a tool call, run `/mcp` inside Codex to confirm `hive` is listed and healthy.

{% callout title="Version note" %}
Codex's MCP keys (`url`, `bearer_token_env_var`, `http_headers`, `env`) are recognized by the upstream Codex CLI; the canonical schema lives in the Codex source ([codex-rs/codex-mcp/src/mcp/auth.rs](https://github.com/openai/codex/blob/main/codex-rs/codex-mcp/src/mcp/auth.rs)) and the [Codex config reference](https://developers.openai.com/codex/config-reference). The published [config.md](https://github.com/openai/codex/blob/main/docs/config.md) only shows stdio examples today, but HTTP fields work in current builds — verify with `codex /mcp` after restart.
{% /callout %}

---

## What to ask in Codex

Codex shines at multi-step coding work that needs live data. Try:

- *"Generate a TypeScript client that calls Hive's wallet-balances tool and types the response strictly — no `any`."*
- *"Scan the top 20 DeFi pools on Base by APY, then write a Node script that emails me when a new pool enters the top 5."*
- *"Run a honeypot check on this token before I hardcode the address in `src/contracts.ts`: 0x6B175474E89094C44Da98b954EedeAC495271d0F."*
- *"Pull funding rates for BTC perpetuals across Binance, Bybit, and OKX, then commit a Markdown summary to `docs/funding.md`."*

Codex chains tool calls and file edits in the same turn — you don't need to name specific Hive tools.

---

## Troubleshooting

**`codex: command not found`.** The global install didn't land on your `PATH`. Try `npm root -g` and confirm that directory's `bin` is on `PATH`, or reinstall with `bun install -g @openai/codex`.

**TOML parse error on startup.** Codex prints the line number. Most failures are unquoted strings or a missing `=`. The `[mcp_servers.hive]` table header must come *before* its keys, and string values must be double-quoted.

**`401 Unauthorized` on tool calls.** The `bearer_token_env_var` value points to an env var name — not the key itself. Make sure `echo $HIVE_API_KEY` returns your key in the same shell that launches `codex`. If you used `http_headers`, the format is `Authorization = "Bearer <key>"` with a literal space after `Bearer`.

**`hive` doesn't appear in `/mcp`.** Restart your shell so the exported `HIVE_API_KEY` is visible to Codex. If the table is in `config.toml` but Codex still skips it, check for a typo in the table header — `[mcp_servers.hive]` (singular `hive`) is the server id, and Codex is case-sensitive.

**stdio transport — "npx: command not found".** Install Node 20+ from [nodejs.org](https://nodejs.org), restart Codex.

---

## Other clients

- [Cursor](/install/cursor) — IDE-native crypto queries with an MCP install link
- [Claude Code](/install/claude-code) — `claude mcp add` CLI flow for Anthropic's agent
- [All clients](/install) — full list

---

## Next steps

- [Quick Start](/quick-start) — REST, MCP, and CLI basics
- [Tools Reference](/tools) — every tool Codex can call
- [JavaScript integration](/sdk/javascript) — REST examples and TypeScript adapter notes for code Codex generates
