Tutorial

How to Add Search to Codex CLI

Codex CLI hallucinates APIs without live docs. Wire in Scavio's MCP server for real-time search during code generation. Step-by-step setup.

OpenAI's Codex CLI is a terminal coding agent that supports MCP servers. Without a search tool, it happily invents function signatures and references libraries that do not exist. Adding Scavio's MCP server fixes this by giving Codex access to live docs, Stack Overflow, GitHub issues, and YouTube transcripts during generation.

Prerequisites

  • Node.js 20+ installed
  • Codex CLI installed via npm install -g @openai/codex
  • A Scavio API key
  • An OpenAI API key configured for Codex

Walkthrough

Step 1: Install Codex CLI

Install OpenAI's terminal coding agent.

Bash
npm install -g @openai/codex

Step 2: Set environment variables

Add both your OpenAI and Scavio keys to your shell profile.

Bash
export OPENAI_API_KEY="sk-..."
export SCAVIO_API_KEY="sk_live_..."

Step 3: Configure Codex MCP servers

Add Scavio to ~/.codex/config.toml under [mcp_servers].

[mcp_servers.scavio]
command = "npx"
args = ["-y", "@scavio/mcp"]

[mcp_servers.scavio.env]
SCAVIO_API_KEY = "${SCAVIO_API_KEY}"

Step 4: Launch Codex

Start Codex and verify the Scavio tools load.

Bash
codex

Step 5: Ask Codex for live doc lookup

Prompt Codex to write code that requires fresh documentation.

Bash
> write a tool call to the latest LangGraph checkpointer API

Python Example

Python
# Codex MCP config lives in TOML. To validate Scavio works independently:
import os, requests
r = requests.post('https://api.scavio.dev/api/v1/search',
    headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
    json={'query': 'langgraph checkpointer api 2026'})
print(r.json()['organic_results'][:3])

JavaScript Example

JavaScript
const res = await fetch('https://api.scavio.dev/api/v1/search', {
  method: 'POST',
  headers: { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ query: 'langgraph checkpointer api 2026' })
});
console.log((await res.json()).organic_results.slice(0, 3));

Expected Output

JSON
Codex calls scavio.search_google with the query, receives the top 10 organic results, and uses them to generate code against the current LangGraph API rather than an outdated version from training data.

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Node.js 20+ installed. Codex CLI installed via npm install -g @openai/codex. A Scavio API key. An OpenAI API key configured for Codex. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Codex CLI hallucinates APIs without live docs. Wire in Scavio's MCP server for real-time search during code generation. Step-by-step setup.