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

# Codex

> Connect Corsair to OpenAI's Codex CLI via MCP, or use the Corsair CLI directly.

<Tabs>
  <Tab title="MCP">
    Use `runStdioMcpServer` to expose Corsair as a local MCP server that Codex spawns on demand.

    ## Install

    ```bash theme={null}
    npm install @corsair-dev/mcp
    ```

    ## Create the server script

    ```ts mcp-server.ts theme={null}
    import 'dotenv/config';
    import { runStdioMcpServer } from '@corsair-dev/mcp';
    import { corsair } from './corsair';

    runStdioMcpServer({ corsair }).catch((err) => {
        console.error('[corsair-mcp] Fatal:', err);
        process.exit(1);
    });
    ```

    ## Configure Codex

    Codex reads MCP servers from `~/.codex/config.toml`. Add a `corsair` server:

    ```toml ~/.codex/config.toml theme={null}
    [mcp_servers.corsair]
    command = "npx"
    args = ["tsx", "mcp-server.ts"]
    ```

    If your credentials aren't loaded from a `.env` file, pass them under an `env` table:

    ```toml ~/.codex/config.toml theme={null}
    [mcp_servers.corsair]
    command = "npx"
    args = ["tsx", "mcp-server.ts"]

    [mcp_servers.corsair.env]
    CORSAIR_KEK = "your-key-here"
    ```

    Restart Codex after editing the config. Run `codex mcp list` to confirm `corsair` is registered.

    ## Usage

    Once connected, Codex can call Corsair tools directly:

    ```
    Setup corsair, then list all Slack channels.
    ```

    Codex calls `list_operations` to discover available endpoints, `get_schema` to inspect parameters, then `run_script` to execute.
  </Tab>

  <Tab title="CLI">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @corsair-dev/cli
      ```

      ```bash yarn theme={null}
      yarn add @corsair-dev/cli
      ```

      ```bash pnpm theme={null}
      pnpm install @corsair-dev/cli
      ```

      ```bash bun theme={null}
      bun add @corsair-dev/cli
      ```
    </CodeGroup>

    Copy and paste this prompt into Codex to give it everything it needs to work with Corsair:

    ```
    Run `pnpm corsair` to access Corsair's integrations.
    ```
  </Tab>
</Tabs>
