@hanai/mcp-server-searxng
v0.1.0
Published
Self-hosted MCP server that wraps SearXNG's /search API as a single search tool, served over MCP Streamable HTTP.
Readme
@hanai/mcp-server-searxng
A self-hosted MCP server that wraps SearXNG's /search API as a single search
tool, served over MCP Streamable HTTP. Deployable on Bun, Docker, and Cloudflare Workers.
Tool
search — parameters: query (required), categories, engines, language,
pageno, time_range (day|month|year), safesearch (0|1|2). Returns results
as a Markdown list. categories and engines are comma-separated lists.
Configuration
Copy config.example.json to config.json and edit. AppConfig covers both the
upstream SearXNG endpoints and this server's own bearer tokens:
endpoints[]—{ url, headers? }, at least one.headersare sent to that endpoint.mcp.path— optional MCP endpoint path, default/mcp. Use/searxng/mcponly when your gateway forwards that full path to this app; if the gateway strips/searxng, keep the default/mcp.mcp.bearerTokens[]— one or more tokens; any is accepted on the MCP endpoint.mcp.allowedHosts[]— optional. Required for non-localhost deployments (Cloudflare Workers, or any host reached via a real domain/IP): set it to the hostname(s) this server is reached at, otherwise every request is rejected with 403.requestTimeoutMs— optional, default 10000.
SearXNG prerequisite
Every configured endpoint must have json listed under search.formats in its
settings.yml. This server always requests format=json; an endpoint without it
returns 403 on every request.
Deployment note: request-body limits
Bearer auth is this server's primary protection, but the MCP HTTP layer
(createMcpHonoApp) parses a request's JSON body before the bearer-token
check runs. On Bun/VPS there is no built-in body-size limit, so an
unauthenticated client could send a large body that gets buffered and parsed
before being rejected with 401. Put a reverse proxy or platform limit in front
that caps request body size (e.g. Traefik/nginx maxRequestBodyBytes; Cloudflare
Workers enforces its own limits). This matches the intended
self-hosted-behind-a-proxy deployment model.
Run
Bun (local / VPS)
bun install && CONFIG_PATH=./config.json bun run src/entry-bun.ts (port via PORT, default 3000).
Published package CLI:
bunx @hanai/mcp-server-searxng@latest
Docker
docker compose up (mounts ./config.json, runs the published package via bunx).
Cloudflare Workers
bunx wrangler secret put CONFIG_JSON then bunx wrangler deploy.
Development
bun test— run the automated suite.bun run typecheck— type-check withtsc --noEmit.bun run build— bundle the Bun entry todist/entry-bun.js(published asmcp-server-searxng).bun run scripts/manual-search.ts <query>— manual integration check against a real instance.
Verify-before-code rule
Any use of a library/framework/API must be verified against current official docs (via context7) and, for SearXNG behavior, against https://docs.searxng.org/dev/search_api.html before writing code. This applies for the whole lifetime of the project.
