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

# Connect Codex

Connect the Dapta MCP to Codex. Sign in with your Dapta account with two terminal commands, or add one block with an API key to your Codex config.

Codex can reach Dapta with your Dapta login or with an API key. Signing in is the recommended way for people, and there is nothing to install.

{% hint style="info" %}
**Using the Codex or ChatGPT desktop app?** Follow [Connect ChatGPT](https://docs.dapta.ai/dapta-mcp/setup/connect-chatgpt.md). The steps below are for the Codex CLI.
{% endhint %}

***

## Option A: sign in with your Dapta account

**Step 1:** Add Dapta to Codex. In a terminal, run:

{% code title="terminal" overflow="wrap" %}

```bash
codex mcp add dapta --url https://mcp.dapta.ai/mcp
```

{% endcode %}

***

**Step 2:** Sign in. Run this command, then sign in with your Dapta account in the browser that opens and come back to the terminal:

{% code title="terminal" overflow="wrap" %}

```bash
codex mcp login dapta
```

{% endcode %}

***

**Step 3:** Open Codex and ask, for example:

> **List my agents in Dapta**

If your account has several workspaces, Codex lists them by name and asks which one to work in. To change later, say "switch to \<workspace>".

***

## Option B: API key

Use this for scripts, or when you want the connection fixed to one workspace.

**Step 1:** [Create your API key](https://docs.dapta.ai/dapta-mcp/setup/mint-your-api-key.md). The **Save your new MCP key** dialog shows it once, along with a ready-made Codex block. Copy either one and keep the key somewhere safe.

***

**Step 2:** Open the file `~/.codex/config.toml` and add the block below. Replace `<your-key>` with your key.

{% code title="\~/.codex/config.toml" overflow="wrap" %}

```toml
[mcp_servers.dapta-ai]
url = "https://mcp.dapta.ai/mcp"
http_headers = { "x-api-key" = "<your-key>" }
```

{% endcode %}

If the file does not exist yet, create it. If you already have other `[mcp_servers.*]` entries, add this block alongside them.

***

**Step 3:** Restart Codex so it picks up the new server. Then ask:

> **Who am I in Dapta?**

The key fixes the workspace, so Codex never asks which one to use. There is no extra install step: Codex sees every Dapta tool as soon as it connects.

***

{% hint style="success" %}
**Your data stays safe.** When Codex changes something, it shows you a preview first and waits for your confirmation. Reading information never needs confirmation.
{% endhint %}

{% content-ref url="/pages/y0N0ytQ0C9FIgnF9BZoY" %}
[Verify your connection](https://docs.dapta.ai/dapta-mcp/setup/verify.md)
{% endcontent-ref %}


---

# 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.dapta.ai/dapta-mcp/setup/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.
