# Codex

> Register the hosted dFlow MCP server in the OpenAI Codex CLI.

Web page: /docs/mcp/codex/

Codex uses **streamable HTTP** MCP. Register the URL, then run **`codex mcp login`** so OAuth can complete when the server advertises it.

## MCP URL

```
https://k8s.dflow.sh/mcp
```

## Steps

1. **Copy the URL**.
2. Register the server (same as **Dashboard → Agents → Codex**):

```bash
codex mcp add dflow --url https://k8s.dflow.sh/mcp
```

3. Log in for OAuth:

```bash
codex mcp login dflow
```

4. **Sign in** to dFlow and approve **workspace** and scopes. **Deploy is off by default**.
5. You are **done** when tools work.

Syntax for the add command is `codex mcp add <name> --url <url>` per the [OpenAI Codex CLI](https://github.com/openai/codex/blob/main/codex-rs/cli/src/mcp_cmd.rs).

## Turn Deploy on later

Revoke the dashboard grant, run `codex mcp login dflow` again after reconnecting with **Deploy** enabled on consent.

## Troubleshooting

| Symptom | What to do |
| --- | --- |
| **401** | Run `codex mcp login dflow` again or reconnect OAuth; check **Connected agents** for revokes. |
| **Scope error** | Enable **Deploy** on a fresh consent. |
| Login hangs | Confirm the MCP URL is exactly `https://k8s.dflow.sh/mcp` (no trailing path). |
