---
title: OpenAI Codex CLI | Flyweel Docs
description: "Connect Flyweel MCP to OpenAI Codex CLI: add a server block to ~/.codex/config.toml using the mcp-remote shim, restart Codex and query your ad accounts."
url: "https://www.flyweel.co/docs/mcp/codex-cli"
type: static
generatedAt: "2026-10-07T04:41:33.530Z"
---

![Documentation hero background](https://astro-flyweel-docs.vercel.app/vision-hero.webp)
# OpenAI Codex CLI

To connect Flyweel MCP to **OpenAI Codex CLI**, add a `[mcp_servers.flyweel-mcp-server]` block to `~/.codex/config.toml` using the `mcp-remote` shim. Codex currently supports stdio transport natively; the shim bridges Flyweel’s remote HTTP server to stdio.

---

## Step 1: Get your API token[Link to this section](#step-1-get-your-api-token)

 1. Go to [app.flyweel.co](https://app.flyweel.co)
 1. Open **Settings → API & MCP**
 1. Under **Advanced: use an API key instead**, click **Generate API key** (or **Create Token** to name your own)
 1. Copy the `fwl_…` key once — it won’t be shown again

---

## Step 2: Install mcp-remote (optional)[Link to this section](#step-2-install-mcp-remote-optional)


*Terminal window*

```
npm install -g mcp-remote
```

Or skip the install and let `npx` fetch it on first run (the config below uses `npx -y`).

---

## Step 3: Edit ~/.codex/config.toml[Link to this section](#step-3-edit-codexconfigtoml)

If the file does not exist yet, create it: `mkdir -p ~/.codex && touch ~/.codex/config.toml`.

Add this block:


**

```
[mcp_servers.flyweel-mcp-server]command = "npx"args = [  "-y",  "mcp-remote",  "https://api.flyweel.co/functions/v1/mcp-server/mcp",  "--header",  "X-API-Key: fwl_YOUR_TOKEN_HERE",]
```

Replace `fwl_YOUR_TOKEN_HERE` with your real token.

### Optional: per-tool approvals[Link to this section](#optional-per-tool-approvals)


**

```
[mcp_servers.flyweel-mcp-server.tools.trigger_sync]approval_mode = "approve"
```

Flyweel’s read-only tools (`query_metrics`, `list_ad_accounts`, `get_setup_status`) are safe to auto-approve. Tools that change state (`trigger_sync`, `select_ad_accounts`, `connect_ad_platform`) benefit from an approval prompt.

---

## Step 4: Restart Codex[Link to this section](#step-4-restart-codex)


*Terminal window*

```
codex
```

Codex reads `config.toml` on startup. The `flyweel-mcp-server` server appears in the `/mcp` listing.

---

## Step 5: Test it[Link to this section](#step-5-test-it)

In your Codex session, ask:


**

```
What Google Ads accounts do I have connected to Flyweel?
```

If you see your accounts, the connection is working.

---

## Troubleshooting[Link to this section](#troubleshooting)

### ”Failed to start mcp-remote”[Link to this section](#failed-to-start-mcp-remote)

`npx` cannot find or download `mcp-remote`.

**Fix:** Run `npm install -g mcp-remote`, then change `command` in `config.toml` to `mcp-remote` and drop the `-y`, `mcp-remote` args.

### ”Authentication error”[Link to this section](#authentication-error)

Token is invalid, revoked, or malformed.

**Fix:** Regenerate at [app.flyweel.co](https://app.flyweel.co), then Settings → API & MCP.

### Codex does not list the server[Link to this section](#codex-does-not-list-the-server)

Config file is in the wrong location, or the TOML is malformed.

**Fix:** Run `cat ~/.codex/config.toml` to verify the path and syntax. TOML keys are case-sensitive.

---

## Next Steps[Link to this section](#next-steps)

 - [What can you ask?](/docs/mcp/setup#what-can-you-ask)
 - [Other MCP Clients](/docs/mcp/other)

### Ready to get started?

Start optimizing your ad spend today with Flyweel.
  [Start Free](https://signup.flyweel.co/?variant=control)