by fatwang2
Self-hosted search gateway for AI agents. Unified search, news and page extraction with provider fallback. REST API, MCP server and TypeScript library.
# Add to your Claude Code skills
git clone https://github.com/fatwang2/search2aiLast scanned: 11/29/2026
{
"issues": [
{
"type": "npm-audit",
"message": "@hono/node-server: @hono/node-server: `serveStatic` decodes the request path a second time, leading to bypass of middleware on static paths",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "@modelcontextprotocol/sdk: MCP TypeScript SDK: OAuth client could send credentials to an authorization server chosen by the MCP server",
"severity": "high"
},
{
"type": "npm-audit",
"message": "@vitest/mocker: Vitest: Code injection via unauthenticated manual mock registration",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "body-parser: body-parser vulnerable to Denial of Service via trailing bytes after a compressed request body",
"severity": "high"
},
{
"type": "npm-audit",
"message": "fast-uri: fast-uri vulnerable to inconsistent host case normalization via percent-encoded octets",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "hono: hono/jsx renders plain strings unescaped in boundary components, leading to XSS",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "ip-address: ip-address: isInSubnet() and isHostInSubnet() compare addresses of different families as if they shared an address space, allowing an allowlist check to admit an address outside its range",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "miniflare: Vulnerability found",
"severity": "high"
},
{
"type": "npm-audit",
"message": "proxy-addr: proxy-addr vulnerable to IP spoofing via IPv4-mapped IPv6 trust subnet",
"severity": "critical"
},
{
"type": "npm-audit",
"message": "qs: qs : qs.stringify with arrayFormat 'comma' throws an uncaught TypeError on array elements carrying a non-callable own toString (DoS)",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "sharp: sharp: Vulnerabilities in libheif: GHSA-g89c-p67h-r497 and GHSA-2jg2-4ch7-h545",
"severity": "high"
},
{
"type": "npm-audit",
"message": "source-map-js: source-map-js allows event-loop denial of service through indexed source-map section offsets",
"severity": "high"
},
{
"type": "npm-audit",
"message": "undici: undici vulnerable to Denial of Service via unhandled error in WebSocket permessage-deflate decompression",
"severity": "high"
},
{
"type": "npm-audit",
"message": "vite: launch-editor: escapeCmdArgs() omits % escaping on Windows",
"severity": "high"
},
{
"type": "npm-audit",
"message": "vitest: Vulnerability found",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "wrangler: Vulnerability found",
"severity": "high"
},
{
"type": "npm-audit",
"message": "zod: Zod can exhaust memory while validating oversized constrained collections",
"severity": "high"
}
],
"status": "FAILED",
"scannedAt": "2026-11-29T13:01:40.777Z",
"npmAuditRan": true,
"pipAuditRan": true,
"promptInjectionRan": true
}search2ai is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by fatwang2. Self-hosted search gateway for AI agents. Unified search, news and page extraction with provider fallback. REST API, MCP server and TypeScript library. It has 1,287 GitHub stars.
search2ai failed AgentsLLM's automated security scan, which flagged one or more high-severity issues. Review the Security Report section carefully before using it.
Clone the repository with "git clone https://github.com/fatwang2/search2ai" and add it to your Claude Code skills directory (see the Installation section above).
search2ai is primarily written in TypeScript. It is open-source under fatwang2 on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh search2ai against similar tools.
No comments yet. Be the first to share your thoughts!
Requires a passing catalog security scan. Resolve the flagged issues and resubmit to enable featuring.
English · 简体中文
A self-hosted search gateway for AI agents and AI clients.
Connect the search and page extraction services you configure through MCP, an HTTP API, or a JavaScript / TypeScript library. When a provider is rate limited, times out, or fails, the gateway tries the next one in your configured order and reports which service answered and why others failed.
Search endpoints return structured results and page content for your agent or application to use. An optional chat proxy also lets models that support tool calling search the web while answering.
title, url, snippet, and optional fields such as date and content.search, news, and crawl, depending on the configured providers.Looking for hosted search? Search1API is this project's companion hosted service for search, news, and page extraction. Use its API directly or configure it as a search2ai provider. It also offers hosted compatible APIs to help existing integrations switch with minimal changes. The examples below use Search1API; you can choose any other supported provider.
Website · Quick start · Choose an integration · Providers and configuration · HTTP API · API / SDK compatibility · Deployment · Chat proxy · Upgrading · Development and contributing
The local CLI and npm package require Node.js ≥ 22.18. Configure at least one provider that supports the operation you need. In the current version, search requests return 503 when no search provider is configured.
Create .env in your working directory with your search provider key:
SEARCH1API_KEY=your_provider_key
Start a local HTTP service:
npx -y search2ai serve --host 127.0.0.1
Search from another terminal:
curl http://localhost:3014/v1/search \
-H 'Content-Type: application/json' \
-d '{"query":"hono cloudflare workers","max_results":3}'
The response's results contain titles, URLs, and excerpts. This calls only the search provider and needs no model API key. The same service exposes /v1/news, /v1/crawl, and the remote MCP endpoint /mcp.
The CLI reads .env.local and .env from its working directory. Existing environment variables take priority, followed by .env.local, then .env. See .env.template for the full configuration template.
| Your use case | Integration | Who calls the model |
|---|---|---|
| Give AI clients such as Claude Desktop or Cursor search tools | Local or remote MCP | The AI client |
| Supply search data to your agent, script, or backend | HTTP API or library | Your application, if needed |
| Add web access to a chat client with a custom API base URL | Optional chat proxy | search2ai calls your configured model upstream |
For clients using the mcpServers configuration format, add:
{
"mcpServers": {
"search2ai": {
"command": "npx",
"args": ["-y", "search2ai", "mcp"],
"env": {
"SEARCH1API_KEY": "your_provider_key"
}
}
}
}
The client starts search2ai locally and accesses search, news, and crawl over stdio. Each tool needs a configured provider with the corresponding capability. Other MCP clients can use the same command, arguments, and environment variables in their own configuration format.
MCP uses one set of gateway tools with unified parameters and results across backends. Provider-specific compatibility endpoints are for existing HTTP API and SDK integrations; MCP clients use the gateway tools directly.
If you have deployed the HTTP service, connect a client that supports Streamable HTTP to https://your-search2ai-host/mcp. With AUTH_KEYS configured, the client also needs to send Authorization: Bearer <gateway_key>.
Call /v1/search, /v1/news, and /v1/crawl on the standalone service to receive JSON data. See the HTTP API for parameters and responses. The same service can serve applications over REST and AI clients over MCP at the same time.
npm i search2ai
import { createGateway } from 'search2ai/core';
const apiKey = process.env.SEARCH1API_KEY;
if (!apiKey) throw new Error('Set SEARCH1API_KEY before running this example.');
const gateway = createGateway({
providers: {
search1api: { apiKey },
},
});
const { provider, results, warnings } = await gateway.search({
query: 'hono cloudflare workers',
max_results: 3,
});
console.log({ provider, results, warnings });
You can also call gateway.news({ query }) and gateway.crawl({ url }). The library runs in your process, with no separate search gateway service to deploy.
createGateway() accepts explicit configuration. Alternatively, parse settings with configFromEnv(env) or import createGatewayFromEnv(env) from search2ai/hono. Library entry points do not load .env files; your application supplies the environment.
import { Hono } from 'hono';
import { createAppFromEnv } from 'search2ai/hono';
const app = new Hono();
app.route('/search', createAppFromEnv(process.env));
export default app;
This mounts routes such as /search/v1/search, /search/v1/news, /search/v1/crawl, and /search/mcp. The host application supplies the environment; on Workers, use the env passed to the request handler.
For regular chat clients, see the chat proxy.
Configure only the services you want to use. Keys usually come from the provider. SearXNG and self-hosted Firecrawl use your service URL; Jina and Keenable can be explicitly enabled without a key.
| Provider | Search | News | Page extraction | Environment variables |
|---|---|---|---|---|
search1api |
✓ | ✓ | ✓ | SEARCH1API_KEY; optional SEARCH1API_SERVICE selects the underlying engine |
tavily |
✓ | ✓ | ✓ | TAVILY_KEY |
brave |
✓ | ✓ | — | BRAVE_KEY |
exa |
✓ | ✓ | ✓ | EXA_KEY |
serper |
✓ | ✓ | — | SERPER_KEY |
serpapi |
✓ | ✓ | — | SERPAPI_KEY |
google |
✓ | Date-sorted¹ | — | GOOGLE_KEY + GOOGLE_CX |
searxng |
✓ | ✓ | — | SEARXNG_BASE_URL, with JSON output enabled |
outcrawl |
✓ | — | ✓ | OUTCRAWL_KEY |
cloro |
✓ | ✓ | — | CLORO_KEY |
autom |
✓ | ✓ | — | AUTOM_KEY |
keenable |
✓ | — | ✓ | KEENABLE_KEY, or list keenable in SEARCH_SERVICE / CRAWL_SERVICE to use it without a key |
specstream |
✓ | ✓ | ✓ | SPECSTREAM_API_KEY |
sofya |
✓ | ✓ | ✓ | SOFYA_KEY |
jina |
— | — | ✓ | JINA_KEY, or explicitly list jina in CRAWL_SERVICE |
firecrawl |
— | — | ✓ | FIRECRAWL_KEY or a self-hosted FIRECRAWL_BASE_URL |
parallel |
✓ | — | Opt-in | No key; list parallel in SEARCH_SERVICE, and in CRAWL_SERVICE for page extraction |
¹ Google's news operation uses regular search with sort=date, not a dedicated news search endpoint.
All provider key variables above accept a *_API_KEY alias, such as TAVILY_API_KEY. The Google search engine ID also accepts GOOGLE_CSE_ID.
Parallel Search MCP offers free web search in Fast mode with no account or API key. Like jina, it is never selected on its own: nothing reaches Parallel unless you name it. Set SEARCH_SERVICE=parallel to put it in the search chain, and CRAWL_SERVICE=parallel to also use it for page extraction. An installation with no configured provider keeps its existing behavior and returns 503 as before.
For the library, pass it like any other provider: createGateway({ providers: { parallel: {} } }) for search, or { providers: { parallel: { crawl: true } } } for search and page extraction.
Parallel returns ranked excerpts and slices them to max_results; the service controls how many results it supplies. It does not implement news or strict country, language, domain or date filters. Such filter requests return an unsupported provider warning/error rather than silently ignoring the filters. Choose another configured provider when those features are needed. The free service is intended for exploration and light use and has rate limits; failures use the existing error/warning contract.
Search and crawl accept an optional opaque UUID session_id. Reuse the returned ID for related search, extraction, retries and follow-up calls in one conversation or research run. On failure, the library GatewayError.session_id, REST error.session_id and MCP error structured content retain the ID, including when the first call fails; omit it for a new run or reset. Array queries and crawl_results enrichment share the run ID. Do not put personal data in it. Independent calls generate separate IDs even when they share a gateway. The chat proxy returns X-Search2AI-Session-Id; pass it back as search_session_id in later chat requests to continue