> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex

> Register Cognee MCP with the OpenAI Codex CLI agent.

# Codex Integration

Codex is OpenAI's coding agent with built-in MCP support. You can register Cognee MCP once, then use Cognee memory and retrieval tools directly in your Codex sessions.

<Tip>
  For most users, the [**Cognee memory plugin**](/integrations/codex-integration) is the simpler path — it adds persistent memory with a few commands and no separate MCP server to run. The MCP setup below is for connecting Cognee's full MCP tool set.
</Tip>

## Prerequisites

* Codex CLI installed and authenticated
* Cognee MCP server running (see [Quickstart](/cognee-mcp/mcp-quickstart) or [Local Setup](/cognee-mcp/mcp-local-setup))
* OpenAI API key (for Cognee's LLM operations)

## Setup Steps

<Steps>
  <Step title="Add Cognee MCP Server">
    Choose the command that matches how you started the Cognee MCP server:

    <Tabs>
      <Tab title="Docker (HTTP)">
        Use this if you started the server with Docker:

        ```bash theme={null}
        docker run -e TRANSPORT_MODE=http --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main

        codex mcp add cognee --url http://localhost:8000/mcp
        ```
      </Tab>

      <Tab title="Local (stdio)">
        Use this if you cloned the repository and run from source:

        ```bash theme={null}
        codex mcp add cognee \
          --env LLM_API_KEY="your-openai-key" \
          -- uv --directory /absolute/path/to/cognee-mcp run cognee-mcp
        ```

        Replace:

        * `your-openai-key` with your OpenAI API key
        * `/absolute/path/to/cognee-mcp` with the path to your local `cognee-mcp` directory
      </Tab>
    </Tabs>

    If a `cognee` server entry already exists, remove it first:

    ```bash theme={null}
    codex mcp remove cognee
    ```
  </Step>

  <Step title="Verify Server Registration">
    ```bash theme={null}
    codex mcp list
    ```

    You should see `cognee` in the MCP server list.
  </Step>

  <Step title="Start Codex and Use Cognee Tools">
    ```bash theme={null}
    codex
    ```

    Codex can now call Cognee tools automatically when relevant.

    Example prompts:

    * "Remember this repository note in Cognee: the billing API uses Stripe webhooks for subscription updates"
    * "Recall authentication logic from Cognee before editing this file"
    * "Improve the current Cognee dataset with the architecture notes in this repository"
    * "Use Cognee to find prior decisions about database migrations"
  </Step>
</Steps>

## Where to Use This Configuration

Codex stores MCP server settings in `~/.codex/config.toml` under the `mcp_servers` section. Once added, the Cognee server is available to Codex sessions unless removed or disabled.
You can also configure the mcp server directly in the `config.toml` file.

## Need Help?

<Card title="Join Our Community" icon="discord" href="https://discord.gg/m63hxKsp4p">
  Get support and connect with other developers using Cognee MCP.
</Card>
