> For the complete documentation index, see [llms.txt](https://docs.currents.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.currents.dev/ai/connect/codex.md).

# Codex

Connect Codex (the CLI, the IDE extension and the ChatGPT desktop app) to Currents with one command and a browser sign-in

Codex connects to the Currents MCP server at `https://mcp.currents.dev/mcp`. The Codex CLI, the Codex IDE extension and the ChatGPT desktop app read the same configuration, so adding Currents once makes it available in all three.

## Add the server

```bash
codex mcp add currents --url https://mcp.currents.dev/mcp
```

This writes an entry to `~/.codex/config.toml`:

```toml
[mcp_servers.currents]
url = "https://mcp.currents.dev/mcp"
```

To share the server with everyone working in a repository, put the same table in `.codex/config.toml` at the repository root instead. Codex reads project configuration from trusted projects only. The file holds no credential: each person signs in as themselves.

## Sign in

```bash
codex mcp login currents
```

A browser window opens. Sign in to Currents, choose the organization Codex will work in, and approve the permissions it asks for. See [Sign in once](/ai/connect.md#sign-in-once) for what each screen shows.

Codex renews the connection on its own from then on. To revoke it everywhere, remove it under **Account → Connected Applications** in Currents.

## Check the connection

Run `codex mcp list` to see the configured servers, or type `/mcp` inside a `codex` session to see the active ones. Then ask something only Currents can answer:

> Which tests in `<project>` were flakiest on main this week, and why?

## Ask before writes

Every Currents tool says whether it only reads. Have Codex ask you before any tool that does not:

```toml
[mcp_servers.currents]
url = "https://mcp.currents.dev/mcp"
default_tools_approval_mode = "writes"
```

With this, Codex runs the read tools on its own and stops for writes such as `currents-delete-run`, which permanently deletes a run. `enabled_tools` and `disabled_tools` narrow the list further. See the [Codex MCP documentation](https://learn.chatgpt.com/docs/extend/mcp).

## Use an API key instead

For a CI job or anywhere no one can complete the browser sign-in, send a Currents [API key](/dashboard/administration/api-keys.md) from an environment variable:

```bash
codex mcp add currents --url https://mcp.currents.dev/mcp \
  --bearer-token-env-var CURRENTS_API_KEY
```

```toml
[mcp_servers.currents]
url = "https://mcp.currents.dev/mcp"
bearer_token_env_var = "CURRENTS_API_KEY"
```

A key acts as the organization, not as a person. See [Connect with an API key](/ai/connect/remote.md#connect-with-an-api-key) for what a key can reach and how to revoke it.

## Troubleshooting

| What you see                   | What to do                                                                                                  |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| Currents tools fail with `401` | Run `codex mcp login currents`.                                                                             |
| The wrong organization's data  | Revoke the connection in Currents, run `codex mcp login currents` again, and choose the other organization. |

For other errors, see [Troubleshooting](/ai/connect.md#troubleshooting).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.currents.dev/ai/connect/codex.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
