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

# OpenAI Codex

> Connect Leeroopedia MCP to OpenAI Codex CLI

## Prerequisites

* [uv](https://docs.astral.sh/uv/) (recommended) or pip
* A Leeroopedia API key. Get one at [app.leeroopedia.com](https://app.leeroopedia.com)

## Setup

<Steps>
  <Step title="Add MCP server">
    **Option A: CLI command (recommended)**

    ```bash theme={null}
    codex mcp add leeroopedia --env LEEROOPEDIA_API_KEY=kpsk_your_key_here -- uvx leeroopedia-mcp
    ```

    **Option B: Edit `~/.codex/config.toml` directly**

    ```toml theme={null}
    [mcp_servers.leeroopedia]
    command = "uvx"
    args = ["leeroopedia-mcp"]

    [mcp_servers.leeroopedia.env]
    LEEROOPEDIA_API_KEY = "kpsk_your_key_here"
    ```

    <Note>
      `uvx` auto-downloads and runs the package. No `pip install` needed. It also auto-updates to the latest version.
    </Note>

    <Note>
      **Getting `spawn uvx ENOENT`?** Codex can't find `uvx` in its PATH. Run `which uvx` (or `where uvx` on Windows) in your terminal to get the full path, then replace `"uvx"` with it in your config (e.g. `command = "/home/username/.local/bin/uvx"`).
    </Note>

    If you don't have `uv`, install manually first:

    ```bash theme={null}
    pip install leeroopedia-mcp
    ```

    Then use `leeroopedia-mcp` as the command:

    ```toml theme={null}
    [mcp_servers.leeroopedia]
    command = "leeroopedia-mcp"

    [mcp_servers.leeroopedia.env]
    LEEROOPEDIA_API_KEY = "kpsk_your_key_here"
    ```
  </Step>

  <Step title="Verify the connection">
    Run `codex mcp list` or type `/mcp` in the Codex TUI. You should see the **leeroopedia** server listed and connected.
  </Step>
</Steps>

## Try It Out

Ask Codex something like:

> "Use leeroopedia to search for best practices for QLoRA fine-tuning."

The agent will call `search_knowledge` and return a synthesized answer with `[PageID]` citations.

You can then follow up with:

> "Get the full page for \[PageID] that was cited."

## Optional: Add the Agent Skill File

You can add an optional skill file that teaches Codex **when and how** to pick the right Leeroopedia tool. This improves tool selection, encourages parallel searches, and provides canonical workflows for common tasks.

Download [`SKILL.md`](https://raw.githubusercontent.com/Leeroo-AI/leeroopedia-mcp/main/SKILL.md) and paste its contents into your project's `AGENTS.md` file (create one if it doesn't exist). Codex reads this file automatically at the start of every session.

<Note>
  This step is optional. The MCP tools work without the skill file. The skill file just helps the agent make better tool choices automatically.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Tools Overview" icon="wrench" href="/docs/tools/overview">
    Learn about all 8 available tools
  </Card>

  <Card title="Environment Variables" icon="gear" href="/docs/environment-variables">
    Configuration reference
  </Card>
</CardGroup>
