> For the complete documentation index, see [llms.txt](https://docs.fastn.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastn.ai/build/building-from-your-ai-agent/mcp-gateway/codex.md).

# Codex

Add fastn to OpenAI Codex with one command, sign in, and build integrations from the Codex CLI or IDE extension.

Codex reads its MCP servers from `~/.codex/config.toml`. The Codex CLI and the Codex IDE extension share that file, so adding fastn once covers both.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fgit-blob-90e1174a016ad18ee0729345de49369a16a70471%2Fmcp-fastn-tab-codex.webp?alt=media" alt="fastn&#x27;s MCP server page with the Codex tile selected, showing the command codex mcp add fastn --url https://mcp.fastn.dev/fastn-workspace, the file ~/.codex/config.toml with an mcp_servers.fastn entry, and a note that the CLI and the VS Code extension read the same file"><figcaption><p>The Codex tile under <strong>Connect AI tools</strong> in fastn has the command and the file.</p></figcaption></figure>

## Add fastn

{% stepper %}
{% step %}

#### Run the command

```
codex mcp add fastn --url https://mcp.fastn.dev/fastn-workspace
```

Codex detects that fastn uses OAuth and starts the sign-in straight away. It prints *Authorize `fastn` by opening this URL in your browser* and opens the page.
{% endstep %}

{% step %}

#### Sign in to fastn

In the browser, sign in to fastn if asked. If you belong to more than one fastn org, pick the workspace Codex works in and click **Connect**. When the terminal prints *Successfully logged in.*, you are done.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fgit-blob-949ea59158c2d1343e8e1b238f204a4c57502181%2Fmcp-codex-choose-workspace.webp?alt=media" alt="fastn&#x27;s page titled Which workspace should Codex (chatgpt.com) use?, with The org selected in fastn chosen, a list of orgs and a Connect button"><figcaption><p><strong>The org selected in fastn</strong> follows whichever org you have open in the fastn dashboard; picking a named org pins Codex to it.</p></figcaption></figure>

If the browser does not open, copy the URL Codex printed. To sign in again later, run `codex mcp login fastn`.
{% endstep %}

{% step %}

#### Check it

```
codex mcp list
```

fastn is listed with **Status** `enabled` and **Auth** `OAuth`:

```
Name   Url                                    Bearer Token Env Var  Status   Auth
fastn  https://mcp.fastn.dev/fastn-workspace  -                     enabled  OAuth
```

{% endstep %}
{% endstepper %}

The command writes this entry to `~/.codex/config.toml`. You can also add it by hand and then run `codex mcp login fastn`:

```
[mcp_servers.fastn]
url = "https://mcp.fastn.dev/fastn-workspace"
```

## Use it

Ask Codex to use fastn by name the first time. For example:

```
codex "Use the fastn MCP server: call its whoami tool and tell me the org name."
```

Codex calls `fastnPlatform__whoami` and answers with the name of the org you picked when signing in. From there, ask for the integration in one sentence. See [Building from your AI agent](https://docs.fastn.ai/build/building-from-your-ai-agent.md) for what happens next.

## Troubleshooting

* **Codex answers from the wrong org.** Run `codex mcp logout fastn`, then `codex mcp login fastn`, and pick the workspace again.
* **fastn's tools are missing in the IDE extension.** The extension reads the same `~/.codex/config.toml`. Restart the extension after adding fastn.


---

# 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.fastn.ai/build/building-from-your-ai-agent/mcp-gateway/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.
