openai_websearch
Provides web search and image search capabilities by leveraging OpenAI's native server-side web search via the Codex/ChatGPT Responses API.
Click on "Deploy 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., "@openai_websearch What are the latest breakthroughs in AI?"
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.
openai_websearch
Self-hostable MCP server (official @modelcontextprotocol/sdk) and reusable API client that exposes OpenAI's native server-side web search via the ChatGPT/Codex Responses API.
No API keys required. Authenticate with your ChatGPT account in 3 ways:
Browser OAuth — gets a URL, you click Connect (works on any device)
Device-code flow — URL + code for headless/remote machines (no browser needed)
Existing Codex auth — auto-falls back to
~/.codex/auth.json
Tokens auto-refresh — no manual re-login every few weeks.
Features
Capability | Description |
| Full-text web search with real URLs and citations |
| Image search returning web image URLs and source pages |
Built-in OAuth login |
|
Auto-refreshing tokens |
|
Official MCP SDK |
|
Reusable library | Import in any Node/Bun/Deno project |
Zero API keys | Uses your ChatGPT subscription |
Related MCP server: websearch-mcp
As an MCP server
Install & authenticate
git clone https://github.com/hffmnnj/openai_websearch.git
cd openai_websearch
npm install
# Authenticate (browser flow — prints a URL)
node index.js login
# Or headless (prints URL + code, enter on any device)
node index.js login --device-code
# Check auth status
node index.js auth-statusConfigure your MCP client
{
"mcpServers": {
"openai_websearch": {
"command": "node",
"args": ["/path/to/openai_websearch/index.js"]
}
}
}Tools
Tool | Args | Description |
|
| Text web search with real URLs |
|
| Image search returning URLs + source pages |
As a library (NPM package)
Install
npm install github:hffmnnj/openai_websearchQuick start
import { search, imageSearch } from 'openai_websearch';
// Web search
const results = await search('smart ring market size 2026');
console.log(results.text);
console.log(results.searchQueries); // queries OpenAI actually ran
console.log(results.usage); // token counts
// Image search
const images = await imageSearch('oura ring product photos');
console.log(images.text); // URLs and descriptionsExplicit auth (no Codex, no login prompt — pass tokens directly)
import { createClient } from 'openai_websearch';
const client = createClient({
accessToken: 'eyJhbG...', // JWT from your own OAuth flow
refreshToken: 'rt.1.AAB...', // auto-refreshes when expired
accountId: 'uuid-here',
});
const result = await client.search('test query');Full OAuth in your own code
import { authenticateBrowser, authenticateDeviceCode, createClient } from 'openai_websearch';
// Browser flow
const { tokens, authorizeUrl } = await authenticateBrowser();
// → user opens authorizeUrl, clicks Connect
// Device-code flow (headless)
const { tokens, verificationUrl, userCode } = await authenticateDeviceCode();
// → user visits verificationUrl, enters userCode
// Then use the tokens
const client = createClient({
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token,
});API reference
search(query, opts?) / client.search(query, opts?)
Param | Type | Default | Description |
|
| required | What to search for |
|
|
| Web context to retrieve |
|
|
| OpenAI model |
Returns { text, searchQueries, usage, model }.
createClient(opts?)
Param | Type | Default | Description |
|
|
| Auth file location |
|
| — | Explicit JWT |
|
| — | Auto-refresh when expired |
|
| — | ChatGPT account ID |
|
|
| Fall back to |
|
|
| Default model |
Auth helpers (from openai_websearch/auth)
Export | Description |
| PKCE browser flow, callback on |
| Headless flow, returns URL + code |
| Refresh grant |
| Load/refresh/save token management |
Configuration
Env var | Default | Description |
|
| Auth file path |
|
| Default model |
|
| Fallback Codex auth file |
Requirements
Node.js 18+ (native
fetch), Bun, or DenoA ChatGPT account (free/plus/pro — whatever you have)
No Codex CLI required (unless you want the fallback auth)
How it works
Auth: OAuth2 with PKCE against
auth.openai.com(same client as Codex CLI). Browser flow or device-code flow. Tokens stored locally, refreshed automatically viarefresh_tokengrant.Search: Sends requests to the ChatGPT backend Responses API (
chatgpt.com/backend-api/codex/responses) with theweb_searchtool.MCP: The server uses the official
@modelcontextprotocol/sdk— proper JSON-RPC framing, protocol version negotiation, Zod → JSON Schema derivation, argument validation.
All search runs server-side at OpenAI — same infrastructure that powers ChatGPT's web search.
License
MIT
Available Tools
2 toolsimage_searchImage SearchA
Search the web for images using OpenAI's native web search. Returns image URLs, titles, and source pages.
Returns real image URLs from web pages, not AI-generated images
contextSize controls search depth
Inputs: query (required), model, context_size.
web_searchWeb SearchA
Search the web using OpenAI's native server-side web search. Returns clean, up-to-date results with real URLs and citations. Powered by your ChatGPT/Codex subscription.
contextSize: "low" (fast/cheap), "medium" (balanced, default), "high" (thorough/deep)
All search happens server-side at OpenAI, not locally
Inputs: query (required), model, context_size.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
image_search and web_search are clearly distinct: one retrieves images, the other general web results. The names and descriptions leave no ambiguity about which tool to use for a given query.
Both tools follow the identical <object>_search pattern, creating a predictable and consistent naming convention that aligns with their functions.
With only two tools, the server feels minimal but covers the two primary search needs (general and image). It is borderline because the scope could reasonably include other search types.
The tool surface covers general web search and image search well, but is missing potentially common search types like news or video. Overall, the core search functionality is not left with dead ends.
Related MCP Connectors
Provides AI assistants with access to Seltz's powerful Web Search capabilities.
Web search, scraping, Google Trends and data lookups. Paid per call in USDC on Base via x402.
Web search, page reading and library docs for agents. No key. Routed to the best measured server.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides intelligent web search capabilities using OpenAI's Web Search API with reasoning models. Supports localized results, multiple model options, and automatic source citations for current information retrieval.MIT
- AlicenseAqualityNot gradedmaintenanceEnables web searching via SearXNG, page content extraction with Crawl4AI, and image analysis using vision language models. It provides AI agents with tools for information synthesis and web-based data retrieval through OpenAI-compatible LLM endpoints.3Apache 2.0
- AlicenseAqualityDmaintenanceProvides intelligent web search capabilities using OpenAI's reasoning models, enabling AI assistants to fetch up-to-date information with smart reasoning.1MIT
- AlicenseAqualityBmaintenanceProvides a unified web search tool for AI agents by running multiple search providers concurrently and returning normalized results. It integrates with Claude Code, Codex CLI, OpenCode, and Hermes.1183 PyPI17MIT