Skip to main content
Glama
searxng-mcp

searxng-mcp

by JakePeralta7

searxng-mcp

An MCP server (stdio) for the SearXNG search API. Connect your AI assistant to any SearXNG instance to search the web, images, news and video, discover categories and engines, and fetch autocomplete suggestions through natural language.

Single Python package, one HTTP client created at startup, configuration via environment variables only. Built on the official mcp SDK (high-level server API) and httpx.

Read-only by design. SearXNG exposes a search API, not a write API, so every tool is annotated read-only. Searches leave your instance and reach the upstream engines configured there; use a trusted instance and review its privacy policy. Raw search queries are never written to the server log — only correlation IDs, tool names and safe arguments.

Requirements

SearXNG disables its JSON API by default. Add json to search.formats in the instance's settings.yml and restart SearXNG:

search:
  formats:
    - html
    - json

Without it, search returns a JSON_DISABLED error with instructions. Autocomplete and instance discovery depend on the instance's own configuration and enabled engines.

Related MCP server: mcp-searxng

Configuration

Variable

Required

Default

Description

SEARXNG_URL

yes

—

Instance base URL, e.g. https://searxng.example.com

SEARXNG_API_TOKEN

no

—

Sent as Authorization: Bearer for an authenticating proxy

SEARXNG_USER_AGENT

no

searxng-mcp/<version>

HTTP User-Agent header

SEARXNG_TIMEOUT

no

30

HTTP request timeout, seconds

SEARXNG_TLS_INSECURE

no

false

true disables TLS certificate verification (self-signed)

SEARXNG_LANGUAGE

no

—

Default language when search omits language

SEARXNG_SAFESEARCH

no

—

Default safe-search level (0/1/2) when search omits it

SEARXNG_MAX_RESULTS

no

20

Hard cap, 1–100, on results returned by search

SEARXNG_URL may include a subpath (for example https://example.com/searxng). Missing or invalid required values abort startup with a clear error. Booleans accept true/false/1/0/yes/no/on/off (case-insensitive). .env.example is the canonical list.

Result shapes

search returns a normalized envelope. Results are trimmed to max_results and to the configured cap; the rest of the SearXNG response is preserved:

{
  "query": "rust async",
  "page": 1,
  "results": [
    {
      "title": "Async Rust",
      "url": "https://example.com/async-rust",
      "content": "...",
      "engine": "google",
      "category": "general"
    }
  ],
  "answers": [],
  "infoboxes": [],
  "suggestions": [],
  "corrections": [],
  "unresponsive_engines": [],
  "number_of_results": 0,
  "returned_count": 1,
  "query_id": "abc123def456"
}

page is forwarded to SearXNG as pageno. SearXNG does not expose a reliable total or “has more” flag, so the envelope has no next_page/has_more. unresponsive_engines lists engines that failed during the query. query_id is the correlation ID written to stderr, so a tool call can be lined up with logs.

Discovery tools return compact summaries:

{"categories": ["general", "images", "news"], "count": 3, "query_id": "..."}
{
  "engines": [
    {
      "name": "google",
      "categories": ["general"],
      "enabled": true,
      "shortcut": "go",
      "paging": true,
      "safe_search": true,
      "time_range_support": true
    }
  ],
  "count": 1,
  "query_id": "..."
}

Failures are MCP tool errors with a code prefix: INVALID_INPUT, AUTH_FAILED, FORBIDDEN, JSON_DISABLED, NOT_FOUND, RATE_LIMITED, UPSTREAM_ERROR, BAD_RESPONSE, HTTP_ERROR, CONFIG_ERROR or INTERNAL_ERROR. Credentials are redacted before any message reaches the model.

Tools

Tool

Description

search(query, categories, engines, language, page, time_range, safesearch, max_results)

Search the instance across web, image, news or video results

autocomplete(query)

Get autocomplete suggestions for a partial query

list_categories()

List the search categories exposed by the instance

list_engines(category, enabled_only)

List engines with categories, shortcuts and capabilities

get_instance_info()

Get the version, name, defaults and engine/category counts

health()

Check that the instance is reachable and healthy

Typical flow: call list_categories and list_engines to discover valid names, then pass them to search. Use engines to narrow a noisy query, categories to switch to images/news/video, and max_results to keep the response small.

Example configuration

{
  "mcpServers": {
    "searxng": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/YOURNAME/searxng-mcp", "searxng-mcp"],
      "env": {
        "SEARXNG_URL": "https://searxng.example.com"
      }
    }
  }
}

With Docker, pass secrets through from your environment so they never appear in the config file:

{
  "mcpServers": {
    "searxng": {
      "command": "docker",
      "args": ["run", "-i", "--rm",
        "-e", "SEARXNG_URL",
        "-e", "SEARXNG_API_TOKEN",
        "ghcr.io/YOURNAME/searxng-mcp:latest"]
    }
  }
}

-e VAR without a value passes the variable through from your shell.

Self-signed certificates

Set SEARXNG_TLS_INSECURE=true only for a trusted instance with a self-signed certificate. The flag is applied to the HTTP transport itself, which is what httpx actually consults when a custom transport is supplied.

Development

uv sync --group dev   # install deps into .venv
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pytest -q      # unit tests (httpx mocked, no network)
docker build -t searxng-mcp:dev .

Entrypoint: python -m searxng_mcp (stdio transport only). Logs go to stderr; stdout is MCP stdio only.

Live checks

The repository includes a compose fixture with a deterministic fixture engine, so integration tests do not depend on live upstream search engines:

docker compose up -d --wait
$env:SEARXNG_URL = "http://localhost:8088"
$env:SEARXNG_INTEGRATION = "1"
uv run pytest -q -m integration
docker compose down -v

To check a real instance instead, point SEARXNG_URL at it and choose an engine and query it can serve:

$env:SEARXNG_URL = "https://searxng.example.com"
$env:SEARXNG_TEST_ENGINE = "duckduckgo"
$env:SEARXNG_TEST_QUERY = "openai"
$env:SEARXNG_INTEGRATION = "1"
uv run pytest -q -m integration

Set SEARXNG_TEST_ENGINE to an empty string to let SearXNG choose engines. If the instance uses a self-signed certificate chain, also set SEARXNG_TLS_INSECURE=true for the trusted instance. Public instances may rate-limit or block automated traffic; prefer a self-hosted instance.

Evaluations

evals/searxng.xml contains ten read-only questions over the deterministic corpus served by the compose SearXNG instance. The MCP server connects to that separate instance through SEARXNG_URL; no fake SearXNG is embedded in the server. See evals/README.md for setup.

Releasing

Every push to main runs lint, typecheck, tests, a Docker build and the compose integration suite, then publishes ghcr.io/<owner>/<repo>:<version> + :latest, where <version> is read from version in pyproject.toml. To release, bump the version and merge to main. Git tags are not used.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to perform privacy-respecting web searches through SearXNG, with support for multiple search engines, categories, and advanced filtering options.
      27
      ISC
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to perform web searches and read URL content via a SearXNG instance.
      2
      22 npm
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Exposes SearXNG web search and query autocomplete to AI clients, returning ranked results, instant answers, and suggestions with filters for category, language, time range, engines, page, and safe search. It is distributed via npx and requires a self-hosted SearXNG instance with the JSON format enabled.
      2
      9 npm
      MIT