codex-web-search-mcp
This MCP server provides real-time web search and multi-step deep research using OpenAI Codex's standalone search endpoint, working with any underlying model in Claude Code and consuming zero GPT tokens. Key capabilities:
codex_web_search: Quick single-step searches returning structured answers and a source list (title, URL, summary, ref_id). Filter results by recency (last N days), restrict to specific domains, and control verbosity (short/medium/long).codex_web_research: Iterative deep research by chaining operations: execute search queries, open documents by ref_id (optionally at a line number), find text within documents, and click numbered links—all while maintaining session context across calls (via optionalsession_id).Model-agnostic: Works with any LLM configured in Claude Code (Gemini, OpenRouter, local models, etc.), bypassing limitations of native Anthropic tools.
Reliable: Automatically retries transient network errors (502/503/504) up to two times and provides clear credential error messages.
Simple setup: Requires a valid Codex login (via
codex loginorCODEX_ACCESS_TOKENenvironment variable).
Provides tools for web search and multi-step research using OpenAI Codex's standalone search endpoint, enabling real-time information retrieval and deep research.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codex-web-search-mcpSearch the web for the latest Rust release notes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codex-web-search-mcp
一个模型无关的 MCP (Model Context Protocol) server,把 OpenAI Codex 的独立搜索端点
(chatgpt.com/backend-api/codex/alpha/search)封装成 Claude Code / 任意 MCP 客户端可用的联网搜索工具。
已用 Rust 全量重写为独立二进制(当前 v2.3.1,不再依赖 Node / npx):
后端 OpenAI Codex(免费,只要
codex login登录态);3 个工具:
codex_web_search、codex_web_research、web_fetch;web_fetch自动探测中文编码(GBK/GB2312 等)、跟随 301/302 重定向,避免乱码与空正文;Codex 请求自动重试:对
429/ 服务端5xx/ 网络抖动做指数退避(最多 3 次:500ms、1s);401/403以及其它4xx(如400校验失败)直接友好报错、不重试;Token 自动刷新:收到
401且本机auth.json带有refresh_token时,自动换发新access_token并回写(先备份),免去手动codex login;来源去重 + 按域名聚合:多步
research返回的来源按ref_id/url去重,并按域名分组展示,引用更干净;可分级日志:
--verbose或CODEX_MCP_LOG=debug把请求 URL、HTTP 状态、耗时、重试写到 stderr(绝不污染 MCP 的 stdout 管道);独立二进制,无需 Rust 运行时即可运行(下载预编译 exe 即用)。
灵感与端点实现来自 mateusdcc/pi-gpt-search(MIT)。
解决什么问题
Claude Code 原生的 WebSearch / WebFetch 工具绑定 Anthropic API。一旦把基座模型换成
Gemini、OpenRouter、本地模型等非 Anthropic 模型,这些工具就会失灵。
本工具直连 Codex 的独立搜索端点,与底层模型完全无关——无论客户端用哪个模型, 都能通过 MCP 工具获得实时联网搜索能力,且不消耗 GPT/Codex 的推理 token(只占用账号搜索额度,见下)。
Related MCP server: grok-search-mcp
工作原理
Claude Code / 任意 MCP 客户端(任意模型)
├── codex_web_search(query) # 单步快速搜索
├── codex_web_research(...) # 多步深度研究(search→open→find→click,靠 ref_id 串联)
└── web_fetch(url) # 抓取任意 URL 纯文本(补足搜到却读不到正文的短板)
│
▼
┌─────────────────────┐
│ OpenAI Codex 搜索 │ ───────▶ /backend-api/codex/alpha/search
│ 端点(免费登录态) │
└─────────────────────┘Codex 端点不执行 GPT 推理,只返回结构化搜索结果(零 GPT token)。
model字段仅作为接口要求的标签(固定gpt-4o),不代表实际调用 GPT。search_query/open/find/click都是同一个端点commands里的并列操作,后端靠请求体的 会话id维持上下文,使后续open/find/click能解析上一次搜索返回的ref_id。本 server 在多次 tool call 之间复用同一会话 id,并把ref_id暴露在来源列表里,模型即可多轮编排。引用标记现在返回为
[turn0searchN: 标题 → 域名]形式(旧版是 PUA 私有区字符,已重写清理), 模型可直接拿turn0searchN这种ref_id去做open/click。
依赖与环境
有效的 Codex 登录凭证(必做)——直连 Codex 搜索端点,必须有登录态,否则工具返回清晰报错而非崩溃。 凭证二选一:
方式 1(推荐,零手动配置):
codex login,OAuth 自动把 token 写入~/.codex/auth.json;方式 2(免 auth.json):环境变量
CODEX_ACCESS_TOKEN(可选CODEX_ACCOUNT_ID)。
没有 ChatGPT/Codex 账号、未登录、或会话过期(
401/403)时,工具会返回明确的中文报错,而不是崩溃。
成本与额度提醒:本工具不按 GPT 生成 token 计费——它调用的是 Codex 的
search端点 (/backend-api/codex/alpha/search),而非chat/completions文本生成。但每次搜索都会占用你 ChatGPT/Codex 账号的搜索额度与速率配额(服务端按账号限流,超限返回429)。要点:
需要有效的 ChatGPT/Codex 登录态;免费账号通常可用但频率/总量受限,高频或重度使用建议 Pro/Plus。
它不是「零 OpenAI 资源」:与纯本地 Playwright 类浏览器工具(完全不碰 OpenAI)不同,本工具依赖 OpenAI 搜索后端,每次调用都会消耗对应账号额度。
触发
401/403(凭证过期/权限不足)或429(速率超限)时,重登录或稍后重试即可。
获取 Codex 凭证(必做)
不必手动编写
auth.json:它是codex login的 OAuth 产物,手搓无效。让codex login自动生成,或改用环境变量。
方式 1:codex login(推荐)
npm install -g @openai/codex # 国内: --registry=https://registry.npmmirror.com
codex login # 浏览器走 ChatGPT/OpenAI OAuth登录成功后自动写入 ~/.codex/auth.json(含 tokens.access_token / tokens.account_id)。
server 会自动读取,无需额外配置。
方式 2:环境变量 CODEX_ACCESS_TOKEN(免 auth.json)
# Windows PowerShell
$env:CODEX_ACCESS_TOKEN = "你的token"
$env:CODEX_ACCOUNT_ID = "你的account_id" # 可选
# macOS / Linux
export CODEX_ACCESS_TOKEN="你的token"
export CODEX_ACCOUNT_ID="你的account_id" # 可选凭证过期(
401/403):方式 1 重新codex login;方式 2 换新 token。
安装(开箱即用,推荐)
本项目是独立原生二进制,无需安装 Rust、无需 Node 即可使用。三种拿到二进制的方式:
方式 0(最省事,推荐):一行命令自动安装
macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/dhicoc/codex-web-search-mcp/main/scripts/install.sh | bashWindows(PowerShell):
irm https://raw.githubusercontent.com/dhicoc/codex-web-search-mcp/main/scripts/install.ps1 | iex
脚本会自动识别平台、下载预编译二进制、校验 SHA-256、安装并给出 MCP 配置片段;加
--write-config可顺手生成.mcp.json。方式 A:去 Releases 手动下载预编译文件 —— 下载即用,零依赖。每个 Release 附带
checksums.txt(SHA-256 清单)供校验。各平台文件名见下「配置 MCP · 方式 A」。方式 B:从源码编译(见下「编译(Build)」),产物直接运行。
编译(Build)
Windows(MSVC)
# 本仓库脚本已注入 VS 2023 环境(INCLUDE/LIB 用反斜杠,避开 LNK1181)
bash scripts/build.sh --release
# 产物: target/release/codex-web-search-mcp.exe⚠️ 编译坑(已踩过):MSVC 的
link.exe/cl.exe只认「反斜杠 +C:\盘符」的INCLUDE/LIB路径。用正斜杠/或/c/风格会报LNK1181: 无法打开输入文件“kernel32.lib”。本脚本已处理;若手动编译,务必导出带反斜杠的INCLUDE/LIB并指向 MSVC 的Hostx64/x64/link.exe。
macOS / Linux
cargo build --release
# 产物: target/release/codex-web-search-mcp配置 MCP
方式 A:下载预编译二进制(开箱即用,推荐)
去 Releases 下载与你平台匹配的文件, 放到任意目录即可使用——不需要 Rust、不需要 Node:
平台 | 文件名 |
Windows x64 |
|
Windows ARM64 |
|
macOS(Intel / Apple Silicon 通用) |
|
Linux x64 |
|
Linux ARM64 |
|
MCP 配置(把 command 换成你下载的文件路径):
{
"mcpServers": {
"codex-web-search": {
"command": "C:/path/to/codex-web-search-mcp-win32-x64.exe"
}
}
}macOS / Linux:把
command换成你下载文件的实际路径(如/path/to/codex-web-search-mcp-darwin-universal)。改完重启客户端即可;首次在客户端里查看是否连上(如 Claude Code 的
/mcp)。写入用户级配置(如
~/.claude.json)的mcpServers即对所有项目生效。
方式 B:从源码编译(无预编译 / 想自己构建)
Rust 版是独立二进制,编译一次后直接让客户端 spawn 这个 exe(或 macOS/Linux 下的二进制)即可,不需要 Node。
{
"mcpServers": {
"codex-web-search": {
"command": "C:/path/to/codex-web-search-mcp/target/release/codex-web-search-mcp.exe"
}
}
}macOS / Linux:把
command换成/path/to/codex-web-search-mcp/target/release/codex-web-search-mcp。编译步骤见下「编译(Build)」。
改完重启客户端即可;首次在客户端里查看是否连上(如 Claude Code 的
/mcp)。写入用户级配置(如
~/.claude.json)的mcpServers即对所有项目生效。
可选项:在 MCP 配置的
"env"里加CODEX_ACCESS_TOKEN覆盖凭证(方式 2)。若用codex login,连 exe 路径都不用配 env。
⚠️ 不要用
"command": "cmd", "args": ["/c", ...]—— 会破坏 MCP stdio 管道导致超时 / -32000。
工具一览
codex_web_search(单步搜索)
参数 | 类型 | 说明 |
| string(必填) | 搜索关键词或问题 |
| number | 仅返回最近 N 天内的结果 |
| string[] | 限定搜索域名,如 |
|
| 返回详略程度 |
codex_web_research(多步深度研究)
适合「打开官网文档、长文里找关键段落、跟随链接深挖」的场景。所有操作可在一次调用里组合,
也可分多轮调用(靠自动维持的会话上下文,用上一轮返回的 ref_id 串联)。来源列表里会带
[turn0search0: 标题 → 域名] 这样的标记,模型在后续 open/find/click 里直接引用 turn0search0 即可。
参数 | 类型 | 说明 |
|
| 要执行的搜索查询列表 |
|
| 按 |
|
| 在已打开文档中查找关键词 |
|
| 点击文档内某元素/链接 |
|
| 返回详略程度(默认 |
| string | 可选:覆盖/接续会话 id |
至少提供
search_query/open/find/click中的一项;四项都空会报错。
web_fetch(抓正文)
参数 | 类型 | 说明 |
| string(必填) | 要抓取的网址 |
返回剥离脚本/样式/标签后的纯文本。自动探测 charset 解码 GBK/GB2312 等中文编码,跟随 301/302 重定向,补足「搜到链接却读不到正文、JS 渲染页读不到」的短板。 (注意:纯 JS 动态渲染、需登录的页面仍可能读不到内容,这是服务端 fetch 的能力边界。)
可选环境变量
变量 | 说明 |
| 覆盖 Codex 搜索端点 URL(默认 |
| 覆盖刷新 |
| 覆盖登录凭证(方式 2)。 |
| 设为 |
调试与排错
直接用 initialize / tools/list 在终端手动运行 exe 验证握手;或在客户端里用 /mcp 查看是否连上。
排查网络 / 重试问题时,启动 exe 时加 --verbose(或设 CODEX_MCP_LOG=debug),可在 stderr 看到每次请求的 HTTP 状态、耗时与重试过程。
现象 | 原因 / 解决 |
| 没登录。运行 |
| 会话过期,重新 |
| 稍后重试,或减少调用频率 |
Windows 编译报 |
|
MCP 显示未连接 / | 检查 exe 路径是否正确、JSON 是否合法;确认没用 |
想看请求 / 重试细节 | 启动加 |
与原项目的差异
维度 | pi-gpt-search(原,TS) | 旧版本项目(Node) | 本项目 v2.3.1(Rust 重写) |
语言 | TypeScript | 单文件 Node 脚本 | Rust |
运行依赖 | Node + TS | Node | 无(独立二进制) |
后端 | Codex | Codex | Codex |
工具数 | search/research | 2 | 3(新增 web_fetch) |
引用清理 | PUA 私有区字符 | PUA 私有区字符 | 重写为可读 |
发布(维护者)
二进制由 GitHub Actions 自动构建(.github/workflows/release.yml):打 tag 即跨平台编译,
并在 GitHub Release 附上 5 个平台的原生二进制(codex-web-search-mcp-<platform>)外加
checksums.txt(SHA-256 清单,供安装脚本/用户校验完整性)。用户走「方式 A/方式 0」下载即用,
无需任何 npm 账号。演进方向见 ROADMAP.md。
git tag v2.3.1 && git push origin v2.3.1二进制文件名在 CI 里按平台重命名(
win32-x64/darwin-universal等),与上方「方式 A」表格一致。
Available Tools
2 toolscodex_web_researchA
多步深度研究工具:在 Codex 的联网检索 + 文档浏览引擎上执行「搜索 → 打开文档 → 页内查找 → 点击链接」的迭代研究。所有操作可在一次调用中组合,也可分多轮调用(依靠自动维持的会话上下文,用上一轮返回的 ref_id 串联)。典型流程:先用 search_query 搜索,拿到 ref_id 后用 open(ref_id) 打开权威文档,用 find(ref_id, pattern) 在长文档里定位关键段落,必要时用 click(ref_id, id) 跟随链接。open 返回的文档正文里会内联 [cN: 文本 → 域名] 标记,其中的编号 N 就是可点击元素的 id,直接用于 click({ ref_id, id: N })。返回内容同时含 ref_id 以便后续操作引用。与底层模型无关,适合非 Anthropic 模型下的联网调研。需要有效的 Codex 登录凭证。
| Name | Required | Description | Default |
|---|---|---|---|
| find | No | 在已打开文档中查找关键词(可选)。 | |
| open | No | 按 ref_id 打开文档/页面(可选)。 | |
| click | No | 点击文档内某元素/链接(可选)。 | |
| session_id | No | 可选:覆盖本次研究的会话 id。不传则复用 server 自动维持的会话,从而接续之前搜索得到的 ref_id 上下文。 | |
| search_query | No | 要执行的搜索查询列表(可选,但至少需提供一项操作)。 | |
| response_length | No | 返回内容详略程度(可选,默认 long)。 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden and does so richly. It discloses that operations can be chained using ref_id across calls, that session context is auto-maintained, that open() inlines [cN: text → domain] markers where N is the clickable id, that responses contain ref_id, and that valid Codex login credentials are required. These go far beyond schema details.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a dense paragraph, but every sentence earns its place: purpose, workflow, mechanics, and requirements. It is logically organized and front-loaded with the tool's core purpose. Slightly long, but appropriate given the operational complexity it must convey.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a complex multi-step tool with no output schema, the description covers the workflow and return of ref_id, but does not specify the exact structure of search results or opened document bodies. This is a minor gap; the description is still sufficient for an agent to invoke the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Although schema coverage is 100%, the description adds crucial semantics: it explains the meaning of ref_id as a chaining token, how the click id N is derived from inline markers, and that session_id overrides the auto-maintained session. This makes the parameters actionable beyond their raw names and schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly identifies the tool as a multi-step deep research tool and details the exact operation sequence: '搜索 → 打开文档 → 页内查找 → 点击链接' (search, open, find, click). It names the underlying engine (Codex web retrieval + document browsing) and clearly distinguishes itself from the sibling codex_web_search by emphasizing multi-step research.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It provides a concrete typical workflow (search → open → find → click) and explains that operations can be combined in one call or split across rounds using session context. It mentions suitability for non-Anthropic models, but does not explicitly state when one should choose this tool over codex_web_search or describe exclusions, missing the highest bar.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
codex_web_searchA
通过 OpenAI Codex 的独立搜索端点执行实时联网搜索,返回模型整理的答案文本以及带标题、URL、摘要的来源列表(来源含 ref_id,可用于 codex_web_research 进一步打开/查找)。该工具与底层模型无关——即使 Claude Code 接入的是 Gemini / OpenRouter / 本地模型等非 Anthropic 模型也能正常使用,弥补原生 WebSearch 在非 Anthropic 模型下失效或体验差的短板。需要有效的 Codex 登录凭证(codex login 或 CODEX_ACCESS_TOKEN 环境变量)。
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 搜索关键词或问题。 | |
| domains | No | 限定搜索域名列表,例如 ["github.com", "docs.python.org"](可选)。 | |
| recency | No | 仅返回最近 N 天内的结果(可选)。 | |
| response_length | No | 返回内容详略程度(可选,默认 medium)。 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses authentication requirements, output structure (answer text + sources with ref_id), and model independence. However, it does not mention potential failure modes, rate limits, or result quality nuances, leaving some behavioral details undisclosed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is composed of three sentences, each carrying distinct value: function, use case/motivation, and prerequisites. It is efficiently structured and front-loaded with the core purpose, though slightly longer than the bare minimum.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Without an output schema, the description adequately explains return values (answer text and sources with ref_id). It also covers authentication, model independence, and relationship to the sibling tool, making it contextually complete for a search tool with four parameters and no annotations.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, and the schema already describes all four parameters clearly. The description adds no additional meaning about parameter usage or syntax beyond what the schema provides, so the baseline of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly states the tool performs real-time web search via OpenAI Codex's search endpoint, and clearly differentiates it from the sibling tool by mentioning ref_id for use with codex_web_research. The verb '执行实时联网搜索' is specific and unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly describes when to use this tool: when the underlying model is non-Anthropic and native WebSearch fails or underperforms. It names the alternative (native WebSearch) and the complementary sibling (codex_web_research), providing clear context for selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
2 tool updates
v1.1.0- First observed
codex_web_research - First observed
codex_web_search
TDQS
Each tool has a clear, distinct role: one performs a single web search, the other executes iterative multi-step research. Despite both involving search, the workflow difference is explicitly described, making selection unambiguous.
Both tool names follow the same pattern: codex_ + web_ + action verb (search/research). The naming is consistent and predictable.
With only two tools, the server feels thin even though the domain is narrow. The two tools cover both quick and deep research, but the count is at the borderline for minimal acceptable scope.
The tool set covers single searches and complex research workflows including opening, finding within, and clicking links. Minor gaps exist (e.g., no explicit session management), but the surface is adequate for the stated purpose.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Docs: https://docs.keenable.ai/mcp-server Keenable is a free, remote MCP server that gives agents access to the web index. Search the web with ranked results and date/site filters, then fetch any indexed page as clean markdown. Works out of the box with no account or API key.
Serper MCP — wraps the Serper Google Search API (serper.dev)
Live AI-native web search with citations. One tool for every MCP client. Flat per-request pricing.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server that bridges OpenAI's Agents SDK with Claude Code, enabling web search, file search, and computer use capabilities directly in your development environment.291MIT
- AlicenseNot gradedqualityBmaintenanceMCP server that enables coding agents to search X/Twitter and the web through the local Grok CLI, providing better search results than default Codex or Claude search without requiring an API key.366MIT
- AlicenseAqualityDmaintenanceA zero-dependency MCP server that enables searching and reading local Claude Code and Codex chat sessions, supporting full-text search, grep, and knowledge indexing from chat history.1514MIT
- FlicenseAqualityCmaintenanceAn MCP server that brings Parallel web search and URL extraction to Codex and other Model Context Protocol clients.221-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dhicoc/codex-web-search-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server