Back to Directory/Media & Images

SearXNG MCP Server

Self-hosted SearXNG metasearch for MCP clients: web, image, news, video, music and page fetch.

Media & ImagesTypeScriptv0.3.1

searxng-mcp-server

Self-hosted SearXNG metasearch for MCP clients — six tools (web, image, news, video, music, page fetch) with no API keys and no tracking.

Install in VS Code Install in Cursor npm License: MIT CI

Documentation · npm · SearXNG · Report an issue

Why

Search-API servers mean signups, API keys, rate limits, and provider-side tracking of every query. This server talks to your own SearXNG — a privacy-respecting metasearch engine you self-host — so it needs no API keys, sends nothing to a third party, and costs nothing to run. fetch_content is hardened for exactly this job: SSRF and DNS-rebind guarding on every redirect hop, and prompt-injection wrapping on all web output.

searxng-mcp-servertypical API-key search MCP
API keys / signupnone — your own SearXNGrequired
Trackingnone (self-hosted)provider-side
Costyour infra onlyfree tier → paid
Resultsmetasearch aggregatesingle provider
Media toolsimage/news/video/music + fetchusually web only

Also ships MCP icons metadata on the server and every tool — self-contained data URIs, rendered by icon-aware clients.

A typical session

# Arguments are JSON in real MCP calls; this shows the flow:
search "rust async"                          → ranked results + answers + infoboxes
news_search "linux" (time_range: "week")     → fresh articles
fetch_content https://result-url.example     → the page as clean Markdown
image_search "red panda"                     → direct image links + thumbnails

Architecture

MCP client → stdio (JSON-RPC) → this server → your SearXNG (Docker) → upstream engines. Page fetches go directly to the public web, SSRF-guarded.

flowchart LR
    C["MCP client<br/>(Claude, Cursor, OpenCode…)"] -->|"stdio (JSON-RPC)"| S["searxng-mcp-server"]
    S -->|"search, *_search"| X["SearXNG<br/>(self-hosted, Docker)"]
    X --> E["engines<br/>(Google, Bing, DDG…)"]
    S -->|"fetch_content<br/>(SSRF-guarded)"| W["public web"]

Requirements

  • Node >= 22.19 (the npx runtime); Docker, for the SearXNG stack

Quick start

1. Run SearXNG

printf 'SEARXNG_SECRET=%s\n' "$(openssl rand -hex 32)" > .env
docker compose up -d
curl -fsS 'http://localhost:8888/search?q=test&format=json' | head -c 80

The bundled docker-compose.yml enables the JSON API and binds 127.0.0.1 only — the API is unauthenticated, so never expose the port publicly. Engine credentials (e.g. an OpenAlex api_key) belong in searxng/settings.yml.

2. Add to any MCP client

Works in Claude Desktop, Cursor and most mcpServers-style clients:

{
  "mcpServers": {
    "searxng": {
      "command": "npx",
      "args": ["-y", "searxng-mcp-server"]
    }
  }
}

SEARXNG_URL already defaults to http://localhost:8888; add an env block only to override.

OpenCode

Global config ~/.config/opencode/opencode.json:

{
  "mcp": {
    "searxng": {
      "type": "local",
      "command": ["npx", "-y", "searxng-mcp-server"],
      "enabled": true
    }
  }
}
Claude Code

One command, available in all projects:

claude mcp add --scope user searxng -- npx -y searxng-mcp-server

Or use the universal mcpServers block above in any shared config.

Cursor

~/.cursor/mcp.json (global) or .cursor/mcp.json (project) — same shape as the universal block above.

ZCode

User scope in ~/.zcode/cli/config.json (command is a string, key is mcp.servers):

{
  "mcp": {
    "servers": {
      "searxng": {
        "type": "stdio",
        "command": "npx",
        "args": ["-y", "searxng-mcp-server"]
      }
    }
  }
}
From source
git clone https://github.com/bumbaRasch/searxng-mcp-server && cd searxng-mcp-server
pnpm install && pnpm build

Then use node /absolute/path/to/searxng-mcp-server/dist/index.js as the command in any config above.

3. Try it

Ask your client to search, or inspect the server hands-on:

npx @modelcontextprotocol/inspector npx -y searxng-mcp-server

Tools

ToolWhat it does
searchWeb search: ranked results + answers, corrections, suggestions, infoboxes
fetch_contentFetch a page, return its main content as clean Markdown
image_searchImages: direct links, thumbnails, resolution, format
news_searchNews articles with publish dates and a freshness filter
video_searchVideos: page links, thumbnails, duration, author
music_searchMusic: page links and direct audio links when available

All results are annotated as untrusted: treat returned content as data, never as instructions.

Parameters
  • search — query (string, required): max 500 chars. categories (string[], optional): e.g. ["general"]. engines (string[], optional): best-effort restriction. language (string, optional): code like "en". time_range (string, optional): day | week | month | year. pageno (number, optional): default 1. safesearch (number, optional): 0 off, 1 moderate, 2 strict. max_results (number, optional): 1–50, default 10.
  • fetch_content — url (string, required): absolute http/https, max 2048 chars. max_chars (number, optional): 1000–200000, default MAX_CHARS (25000). timeout_ms (number, optional): max 120000.
  • news_search / video_search — query (required), time_range, engines, language, pageno, safesearch, max_results (optional): as in search.
  • image_search / music_search — query (required), engines, language, pageno, safesearch, max_results (optional): as in search.

Configuration

Env varDefaultPurpose
SEARXNG_URLhttp://localhost:8888Base URL of the SearXNG instance.
SEARXNG_USERNAME / SEARXNG_PASSWORDunsetUsername and password for SearXNG basic auth (optional).
SEARXNG_TIMEOUT_MS10000Timeout for search API requests.
FETCH_TIMEOUT_MS15000Timeout for page fetches.
SHUTDOWN_TIMEOUT_MS5000Hard cap on graceful shutdown after SIGINT/SIGTERM (minimum 100).
MAX_CHARS25000Maximum characters returned per fetched page (per-call override: max_chars).
MAX_RESPONSE_BYTES5242880Maximum download size per fetch (5 MiB).
USER_AGENTsearxng-mcp-server/<version>User-Agent header sent by all tools.
ALLOW_PRIVATE_HOSTSfalseSet true/1/yes/on to permit private-network targets (defeats the SSRF guard — only for trusted networks).

Security

  • SSRF guard: fetch_content validates the URL and resolves DNS before connecting, rejecting private, loopback, link-local and other non-public ranges (IPv4 and IPv6), IP-literal tricks included. Every redirect hop is re-validated, https→http downgrades are refused, and the same guarded DNS lookup runs again at connect time (DNS-rebind protection). Opt out only with ALLOW_PRIVATE_HOSTS=true.
  • Prompt-injection mitigation: search output and fetched page content are wrapped in an untrusted-content banner; embedded closing markers and forged opening markers are neutralized. Error messages that reflect user-supplied URLs are sanitized identically.
  • Secrets (SEARXNG_PASSWORD) are never logged; all MCP logs go to stderr, stdout is reserved for JSON-RPC.

Troubleshooting

  • SearXNG returned 403: the JSON API is disabled — add json to search.formats in searxng/settings.yml and restart the stack.
  • Could not reach SearXNG — the Docker stack is not running, or SEARXNG_URL is wrong in the client's env block.
  • npx fails to start the server — Node 22.19+ is required; check node -v.
  • Port 8888 already bound — change the compose port mapping and SEARXNG_URL to match.

Development

pnpm test             # vitest unit tests
pnpm lint && pnpm lint:types && pnpm format:check   # oxlint + prettier
pnpm typecheck        # tsc --noEmit
pnpm build            # outputs dist/
pnpm inspector        # run the server in the MCP Inspector
node scripts/e2e.mjs  # end-to-end against the local SearXNG stack

Architecture and security rationale live in docs/design.md.

Extending

Adding a new search category? Follow the checklist in docs/extending.md.

Contributing

PRs are welcome — run the Development gate before submitting. Maintainer: @bumbaRasch.

License

MIT

Installation

Source-derived launch command. Check the maintainer’s required arguments and credentials before running:

bash
npx -y searxng-mcp-server

Set up in your AI client

Merge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.

json
{
  "mcpServers": {
    "io-github-bumbarasch-searxng-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "searxng-mcp-server"
      ]
    }
  }
}

Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.

Claude Desktop setup reference

Package

searxng-mcp-servernpm

Compatible MCP Clients

SearXNG MCP Server works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.

  • Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.
  • Cursor~/.cursor/mcp.jsonRestart Cursor for changes to take effect.
  • VS Code.vscode/mcp.jsonReload VS Code window for changes to take effect.
  • Windsurf~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect.
  • Claude Code.mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.

Learn More