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

# Codex

> Configure ScrapeGraph MCP in Codex (remote-first)

## Codex Setup

Use the remote HTTP MCP endpoint (recommended):

```
https://mcp.scrapegraphai.com/mcp
```

Set your ScrapeGraphAI API key in the environment:

```bash theme={null}
export SGAI_API_KEY=YOUR_API_KEY
```

Add the following configuration to `~/.codex/config.toml`:

```toml theme={null}
[mcp_servers.scrapegraph-mcp]
url = "https://mcp.scrapegraphai.com/mcp"
env_http_headers = { "X-API-Key" = "SGAI_API_KEY" }
```

Restart Codex after saving the configuration. Then run `/mcp` in Codex, or use the CLI, to verify the connection:

```bash theme={null}
codex mcp get scrapegraph-mcp
```

### Local (stdio) alternative

If you prefer running locally:

```bash theme={null}
pip install scrapegraph-mcp
codex mcp add scrapegraph-mcp-local \
  --env SGAI_API_KEY=YOUR_API_KEY \
  -- python3 -m scrapegraph_mcp.server
```

<Note>
  The ChatGPT desktop app, Codex CLI, and Codex IDE extension share the same MCP configuration on the same host. On Windows, replace <code>python3</code> with the Python command available on your system.
</Note>
