> ## 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

## Codex Setup

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

```toml theme={null}
[mcp_servers.sgai]
url = "https://mcp.scrapegraphai.com/mcp"
```

<Note>
  The ChatGPT desktop app, Codex CLI, and the Codex IDE extension share the same MCP configuration on a given host, so this only needs to be done once.
</Note>

## Authenticate

```bash theme={null}
codex mcp login sgai
```

Alternatively, restart Codex, run `/mcp`, select `sgai`, and authenticate. Either way a browser window opens: choose **Continue with Google** and sign in with the Google account associated with your ScrapeGraphAI account.

Once the browser shows **Authentication successful. Connected to sgai.**, return to Codex — the tools are ready.

### With an API key instead

Set `SGAI_API_KEY` in your environment and point Codex at it:

```toml theme={null}
[mcp_servers.sgai]
url = "https://mcp.scrapegraphai.com/mcp"
bearer_token_env_var = "SGAI_API_KEY"
```

A request carrying an API key skips the OAuth flow, so there is no `codex mcp login` step.

## Verify

```bash theme={null}
codex mcp get sgai
```

Then ask Codex to run the `credits` tool. A balance response confirms that authentication and tool execution both work.

<Tip>
  See the [tool reference](/services/mcp-server/introduction#available-tools) for everything the server exposes.
</Tip>
