> For the complete documentation index, see [llms.txt](https://docs.serphouse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.serphouse.com/agent-harnesses/codex-cli.md).

# Codex CLI

Codex CLI is OpenAI's terminal-based AI coding assistant with support for Model Context Protocol (MCP) servers. By connecting the SERPHouse MCP Server, Codex CLI can access live search engine data directly from SERPHouse during conversations.

Once configured, Codex CLI can automatically use SERPHouse tools to perform Google searches, retrieve SERP data, and analyze search results without manually calling the SERPHouse API.

***

### Prerequisites

Before configuring SERPHouse MCP Server, ensure you have:

* Codex CLI installed
* An active SERPHouse account
* A valid SERPHouse API key

***

### Configure the SERPHouse MCP Server

Open your configuration file  `~/.codex/config.toml` and add:

```toml
[mcp_servers.serphouse]
url = "https://mcp.serphouse.com/YOUR_SERPHouse_API_KEY/mcp"
```

Replace `YOUR_SERPHouse_API_KEY` with your actual SERPHouse API key.\
Save the configuration.\
Close the current Codex CLI session, then start a new session.

***

### Verify Configuration

Open a new session and ask:

```
Search Google for "WordPress SEO Plugins".
```

If configured correctly, Codex CLI automatically calls the SERPHouse MCP server.

***

### Using SERPHouse

Once configured, Codex CLI automatically invokes SERPHouse whenever a request requires search engine data.

Example prompts:

```
Search Google for "Laravel Horizon".
```

```
Search Google News for "OpenAI"
```

```
Find the top ranking pages for "technical SEO checklist"
```

```
Search Google Images for "Tesla Model Y"
```

No additional commands are required during normal usage.

***

### Troubleshooting

**SERPHouse server doesn't appear in `/mcp`** — Verify that your `config.toml` file contains valid TOML syntax. Invalid configuration entries are ignored when Codex CLI starts. After making changes, restart Codex CLI to reload the configuration.

**Unable to connect to the MCP server** — Confirm your MCP endpoint is in the format `https://mcp.serphouse.com/YOUR_SERPHouse_API_KEY/mcp` and that your internet connection or firewall is not blocking outbound HTTPS requests.

**401 Unauthorized or Authentication failed** — Verify that your SERPHouse API key is valid and active. Ensure you've replaced `YOUR_SERPHouse_API_KEY` in the endpoint URL with your actual API key. Make sure there are no extra spaces or missing characters in the API key.

**Tools don't appear or fail to execute** — Restart Codex CLI after updating the configuration. MCP servers are loaded when a new session starts.

**Search requests return no results** — Verify that your SERPHouse account has available API credits and that the requested search feature is enabled for your account.

**Still having issues?** — Remove the SERPHouse configuration, add it again, restart Codex CLI, and verify your configuration against the latest documentation.
