# Use SimilarIQ with Codex

> Codex connects to SimilarIQ as a streamable HTTP MCP server. Run codex mcp add similariq --url https://similariq.ai/mcp, then codex mcp login similariq to sign in with OAuth, or set a bearer token environment variable in ~/.codex/config.toml. Codex gets ten look-alike research tools. A search costs $0.25; reads and the balance check are free.

Source: https://similariq.ai/integrations/codex · Updated 2026-11-25

## What Codex is and how it handles MCP

Codex is OpenAI's coding agent. It runs in a terminal as Codex CLI, in an IDE extension, and in the ChatGPT desktop app. OpenAI's documentation says those three share MCP configuration for the same Codex host, so a server you add once is available in each without repeating setup.

MCP servers are defined in `~/.codex/config.toml`, with an optional project-scoped `.codex/config.toml` that applies to trusted projects only. Each server is a table named `[mcp_servers.NAME]`. For a streamable HTTP server the required key is `url`, and the docs say such servers support OAuth, including client ID metadata documents and dynamic client registration. SimilarIQ's server at `https://similariq.ai/mcp` is streamable HTTP and stateless, with nothing to install.

## Why give a coding agent look-alike data

Codex is usually pointed at code, but a lot of code exists to move company data around: enrichment jobs, CRM imports, prospecting scripts, internal dashboards. SimilarIQ gives the agent a real data source for one part of that work. Given a domain, it returns up to 100 ranked look-alike companies with a `matchScore`, a relationship `type` (Direct, Indirect, Adjacent or Emerging), a `confidence` score and a `likelyCompetitor` flag.

That helps in two ways. Codex can call the tools while it works, for example to fetch real sample output before writing a parser, so the code matches actual field names. And it can run the research itself and commit the result as a CSV or JSON fixture. The [developers page](https://similariq.ai/roles/developers) covers the wider set of options.

The response shape is small and stable: `rank`, `company`, `domain`, `matchScore`, `type`, `confidence` and `likelyCompetitor`, plus a few fields on the envelope such as `searchId` and `creditsRemaining`. There are no contacts or firmographic fields, so do not let the agent write code that expects them.

## Setup walkthrough

OpenAI's Codex documentation gives a CLI route and a config-file route. Both end in the same place. We did not verify which OpenAI plans include Codex, so check OpenAI's own pricing and help pages for that. You will also need a SimilarIQ account; [registering](https://similariq.ai/register) gives you 2 free searches with no credit card.

To edit the file directly, add a table to `~/.codex/config.toml` with the header `[mcp_servers.similariq]` and one line under it: `url = "https://similariq.ai/mcp"`. With no credential configured, Codex's default auth mode for the server is OAuth.

For key-based auth, the documented keys are `bearer_token_env_var`, `http_headers` and `env_http_headers`. The cleanest is `bearer_token_env_var = "SIMILARIQ_API_KEY"`: Codex reads the key from that environment variable and sends it in the `Authorization` header, which SimilarIQ accepts as a bearer token. To send the `X-API-Key` header instead, use `env_http_headers = { "X-API-Key" = "SIMILARIQ_API_KEY" }`. Both keep the secret out of the file. Avoid the static `http_headers` form for a real key.

One setting deserves attention. The docs give `tool_timeout_sec` a default of 60, and a SimilarIQ search takes roughly 30 to 60 seconds because it is a fresh research pass. Add `tool_timeout_sec = 120` under the same table so a slower search is not cut off.

- Add the server: `codex mcp add similariq --url https://similariq.ai/mcp`.
- Sign in: `codex mcp login similariq`. A browser opens the SimilarIQ sign-in and consent screen. On a machine with no local browser, the docs offer a `--no-browser` flag that prints the authorization URL.
- Confirm it registered with `codex mcp list`.
- Raise the tool timeout in `~/.codex/config.toml` with the `tool_timeout_sec` setting covered in this section.
- Start Codex and ask for a look-alike search. Approve the tool call if Codex prompts you.

## Example tasks to try

Codex sees ten tools. `find_similar_companies` costs 1 credit per search and `start_bulk_search` costs 1 credit per domain. The free eight are `get_bulk_job`, `list_recent_searches`, `get_search_results`, `list_my_companies`, `save_company`, `list_saved_companies`, `create_share_link` and `get_search_balance`. The tasks below mix research with the code work Codex is built for.

- "Run a SimilarIQ search on plaid.com and save the raw JSON to fixtures/plaid.json. Then write a typed parser for it with tests."
- "Check my SimilarIQ balance and stop if it is under 20 credits."
- "Read data/customers.csv, start a bulk search on the domain column, poll the job, and write the merged results to data/lookalikes.csv."
- "Using my most recent search, write a SQL migration and an insert script for a competitors table with one row per result."
- "Add a function to our enrichment service that calls the SimilarIQ search endpoint with retries on 429 and 502, using the key from the environment."
- "List my past searches and tell me which domains in seeds.txt have not been searched yet. Do not run new searches."
- "Build a script that filters a results file to Direct rows with matchScore of at least 75 and confidence of at least 60."

## Controlling spend

SimilarIQ charges $0.0025 per look-alike, so a 100-result search is $0.25. MCP calls, API calls and app searches share one balance at one price. A debugging session with 20 searches costs $5.00. A bulk run of 1,000 domains costs $250, which is why an agent that can start bulk jobs needs limits.

Codex's config gives you several. `disabled_tools` is a deny list, so `disabled_tools = ["start_bulk_search"]` removes the one tool that can spend many credits in a single call. `enabled_tools` is an allow list if you would rather name only the read tools. `default_tools_approval_mode` accepts `auto`, `prompt`, `writes` or `approve`, and there is a per-tool override, so you can require approval for `find_similar_companies` specifically. Setting `enabled = false` switches the server off without deleting it.

On the account side, set a monthly cap, which is a hard ceiling on what your card can be charged, and tell Codex to call the free `get_search_balance` tool before a batch. Re-reading a past search with `get_search_results` is free, so cache by `searchId` and never pay twice for the same domain during development. The [spend controls](https://similariq.ai/features/spend-controls) page has the details.

## End-to-end workflows

**Build an enrichment job against real output.** Ask Codex to run one search, save the response as a fixture, and write the job that reads a domain column, calls the API, and writes results to your database. One paid search gives the agent accurate field names and types. Cost: $0.25. The [CRM enrichment guide](https://similariq.ai/guides/how-to-enrich-a-crm-with-competitor-data) describes the data model that usually sits behind this.

**Research task with a committed artifact.** Give Codex a list of seed domains and ask for a bulk search, a deduplicated CSV, and a short README explaining the columns. Ten seeds cost $2.50. Because the result is a file in the repo, a reviewer can see exactly what the agent produced.

**Move from agent to script.** Once the prompt works, have Codex replace itself with a deterministic script using the Node or Python SDK or the CLI, for example `similariq bulk domains.txt --wait --out results.csv`. Scheduled jobs are easier to reason about without a model in the loop. See [SDKs and CLI](https://similariq.ai/sdk).

## Troubleshooting

If Codex does not list the SimilarIQ tools, run `codex mcp list` and check the table name and `url` in `config.toml`. Project-scoped config only loads for trusted projects, so a server defined in `.codex/config.toml` will be missing in an untrusted directory. If a search appears to hang and then fails at about a minute, the tool timeout is the cause; raise `tool_timeout_sec`. For expired or revoked sign-ins, run `codex mcp login similariq` again.

SimilarIQ status codes tell you the rest. 401 means a bad or missing key, often because the environment variable named in `bearer_token_env_var` is not set in the shell that launched Codex. 402 means the balance is out of credits. 429 means the rate limiter is smoothing a burst; back off or use a bulk job. 502 means the search failed, the credit was refunded automatically and a retry is safe.

## Security practices

Use OAuth on a workstation and environment-variable keys in automation. OpenAI's docs note that Codex saves OAuth client secrets in `config.toml` when you configure a pre-registered client, and advise keeping that file private. SimilarIQ does not need a pre-registered client, so there should be no secret in the file at all if you follow the steps above.

Do not commit a project-scoped config that contains a literal key. Create a separate SimilarIQ key for each environment so you can revoke one without breaking the others; a key is shown once at creation. Keep approvals on for tools that spend credits, and remember that `create_share_link` makes a public read-only URL. SimilarIQ has no published security certifications, so run your own vendor review where required.

## Frequently asked questions

### How do I add SimilarIQ to Codex?

Run `codex mcp add similariq --url https://similariq.ai/mcp`, then `codex mcp login similariq` to complete OAuth in your browser. Or add a `[mcp_servers.similariq]` table with a `url` line to `~/.codex/config.toml`.

### Can Codex use an API key in place of OAuth?

Yes. Set `bearer_token_env_var = "SIMILARIQ_API_KEY"` in the server table and export the key in your shell. SimilarIQ accepts the key as a bearer token or in an `X-API-Key` header, which you can send with `env_http_headers`.

### Why do SimilarIQ searches time out in Codex?

Codex's documented default for `tool_timeout_sec` is 60 seconds, and a SimilarIQ search takes roughly 30 to 60 seconds. Set `tool_timeout_sec = 120` in the server's table. If a search does fail with a 502, the credit is refunded.

### Does the same setup work in the Codex IDE extension?

OpenAI's documentation says the ChatGPT desktop app, Codex CLI and IDE extension share MCP configuration for the same Codex host. Add SimilarIQ once and it should be available in each.

### What does it cost to run SimilarIQ from Codex?

$0.25 per search, which is 100 look-alikes at $0.0025 each. Eight of the ten tools are free, including reading past results. There is no separate API plan; see [pricing](https://similariq.ai/pricing).

### Should Codex call the MCP server or the REST API?

Use MCP when Codex itself needs the data while it works. Use the [REST API](https://similariq.ai/api) or an SDK in the code Codex writes for you, because production code should not depend on an agent session. One `sk-live-` key works for both.
