Searxng Mcp

io.github.aicrafted由 GitHub 帳號 aicrafted 發布v1.0.0更新於 Oct 24, 2026

MCP server for SearXNG aggregator — web search across multiple engines via Model Context Protocol

概覽

AI 產生的概覽

一個本機 MCP 伺服器,將助理連接到 SearXNG 執行個體,以便跨多個引擎執行彙整網頁搜尋。

可以做什麼
跨多個引擎執行彙整網頁搜尋,可依類別、引擎、語言、頁碼與時間範圍篩選,並可控制安全搜尋,類別包括一般、圖片、影片、新聞、地圖、IT、科學、檔案與社群媒體。取得所連接 SearXNG 執行個體已啟用的類別與引擎清單。透過 stdio、無狀態 HTTP 或 SSE 提供結果,主機、連接埠與 DNS 重綁定允許清單皆可設定。
適用情境
當你已經執行或能夠執行 SearXNG 執行個體,並希望助理透過自己的彙整器而非託管搜尋 API 私密地搜尋網頁時使用,包括新聞、IT、科學或圖片查詢。
執行需求
一個可從伺服器存取且已啟用 JSON 輸出的 SearXNG 執行個體。需要環境變數 SEARXNG_URL(預設 Python 3.10+ 與 pip 相依套件;亦提供容器映像。選用設定包括 MCP_HOST、MCP_PORT、MCP_TRANSPORT、MCP_ALLOWED_HOSTS、MCP_ALLOWED_ORIGINS 與 MCP_DISABLE_DNS_REBINDING_PROTECTION。
安裝前請注意
此伺服器只從 SearXNG 讀取資料,但搜尋請求會經 SearXNG 執行個體及其上游引擎離開你的機器。將 HTTP 或 SSE 綁定到非本機主機,或關閉 DNS 重綁定保護(MCP_DISABLE_DNS_REBINDING_PROTECTION),會暴露此端點;應盡量縮小允許清單。README 指出 files 類別涵蓋種子與檔案搜尋。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Searxng Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

SearXNG MCP Server

A Model Context Protocol (MCP) server that provides web search capabilities by integrating with a SearXNG instance.

Features

  • Web Search: Perform powerful aggregated searches across multiple engines.
  • Discovery: Programmatically retrieve available categories and engines.
  • Stateless HTTP: Compatible with any standard JSON-RPC client.
  • Flexible Configuration: Supports environment variables and command-line arguments.

Example of compose.yml to run SearXNG with MCP server

yaml
services:  searxng:    image: searxng/searxng:latest    ports:      - "${SEARXNG_PORT:-8080}:8080"    volumes:      - "${SEARXNG_VOL_CONFIG:-searxng-config}:/etc/searxng/"      - "${SEARXNG_VOL_DATA:-searxng-data}:/var/cache/searxng/"    restart: always
  searxng-mcp:    image: ghcr.io/aicrafted/searxng-mcp:latest    restart: unless-stopped    depends_on:      # Ensure SearXNG starts before the MCP server      - searxng    environment:      SEARXNG_URL: "${SEARXNG_URL:-http://searxng:8080}"      MCP_HOST: "${MCP_HOST:-127.0.0.1}"      MCP_PORT: "${MCP_PORT:-32123}"      MCP_TRANSPORT: "${MCP_TRANSPORT:-http}"      MCP_ALLOWED_HOSTS: "${MCP_ALLOWED_HOSTS:-localhost:*,127.0.0.1:*}"      MCP_ALLOWED_ORIGINS: "${MCP_ALLOWED_ORIGINS:-http://localhost:*,http://127.0.0.1:*}"      MCP_DISABLE_DNS_REBINDING_PROTECTION: "${MCP_DISABLE_DNS_REBINDING_PROTECTION:-false}"    ports:      - "${MCP_PORT:-32123}:${MCP_PORT:-32123}"
volumes:  searxng-config:  searxng-data:

Important: Enable JSON responses in your SearXNG settings.yml, otherwise the MCP server cannot read search results:

yaml
search:  formats:    - html    - json

Example .env

env
# SearXNG url should be visible by the MCP server inside docker, so use internal service port hereSEARXNG_URL=http://searxng:8080# Public SearXNG portSEARXNG_PORT=8080# Searxng config and data volumes, start with "./" if You want to bind dir instead using volumeSEARXNG_VOL_CONFIG=searxng-configSEARXNG_VOL_DATA=searxng-data
# MCP server host, port and transport ("stdio", "sse", "http")MCP_HOST=127.0.0.1MCP_PORT=32123MCP_TRANSPORT=http
# MCP DNS rebinding protection (see https://github.com/modelcontextprotocol/python-sdk/issues/1798 for details)MCP_ALLOWED_HOSTS=localhost:*,127.0.0.1:*MCP_ALLOWED_ORIGINS=http://localhost:*,http://127.0.0.1:*# MCP_DISABLE_DNS_REBINDING_PROTECTION=true

MCP client config

HTTP transport (recommended)

JSON
{  "mcpServers": {    "searxng": {      "type": "http",      "url": "http://localhost:32123/mcp"    }  }}

SSE transport

JSON
{  "mcpServers": {    "searxng": {      "type": "sse",      "url": "http://localhost:32123/sse"    }  }}

Note: SSE transport uses the /sse endpoint, not /mcp. HTTP transport uses /mcp.

Prerequisites for run from sources

  • Python 3.10+
  • A running SearXNG instance.

Installation

  1. Clone the repository and navigate to the directory.
  2. Install dependencies:
    bash
    pip install -r requirements.txt
  3. Set up your .env file (optional).

Configuration

The server reads configuration from command-line arguments and environment variables. Command-line arguments override the corresponding defaults used at startup.

VariableDefaultDescription
SEARXNG_URLhttp://localhost:8080URL of the SearXNG instance.
SEARXNG_PORT8080Public host port for the SearXNG container in the compose example.
SEARXNG_VOL_CONFIGsearxng-configDocker volume or host path mounted to /etc/searxng/ in the compose example.
SEARXNG_VOL_DATAsearxng-dataDocker volume or host path mounted to /var/cache/searxng/ in the compose example.
MCP_HOST127.0.0.1Host to bind for HTTP/SSE transports. Use 0.0.0.0 in Docker when publishing the port.
MCP_PORT8000Port to bind for HTTP/SSE transports.
MCP_TRANSPORTstdioTransport mode: stdio, http, or sse.
MCP_ALLOWED_HOSTSSDK defaults for localhostComma-separated allowed Host headers for DNS rebinding protection.
MCP_ALLOWED_ORIGINSSDK defaults for localhostComma-separated allowed Origin headers for DNS rebinding protection.
MCP_DISABLE_DNS_REBINDING_PROTECTIONfalseSet to true to disable the SDK DNS rebinding protection.

Usage

Run the server using uv or standard python:

bash
python searxng_mcp.py --transport http --port 32123 --searxng http://searx.lan

Run with Docker

  1. Build the image:

    bash
    docker build -t searxng-mcp .
  2. Run the container:

    bash
    docker run -d \  -p 32123:32123 \  --env-file .env \  --name searxng-mcp \  searxng-mcp

Transport Options

  • stdio: Standard input/output (default for some MCP clients).
  • http: Stateless HTTP (streamable-http).
  • sse: Server-Sent Events.

DNS Rebinding Protection

Recent versions of the MCP Python SDK validate Host and Origin headers for HTTP/SSE transports to protect local servers from DNS rebinding attacks. If you expose the server through Docker, a reverse proxy, or a custom domain and receive 421 Invalid Host Header, configure the allowlist explicitly:

env
MCP_ALLOWED_HOSTS=localhost:*,127.0.0.1:*,mcp.example.com:*MCP_ALLOWED_ORIGINS=http://localhost:*,http://127.0.0.1:*,https://mcp.example.com

For trusted local development or when this validation is handled by another infrastructure layer, you can disable the SDK protection:

env
MCP_DISABLE_DNS_REBINDING_PROTECTION=true

Use disabling sparingly; setting MCP_ALLOWED_HOSTS and MCP_ALLOWED_ORIGINS is the recommended option.


Search Abilities Guide

SearXNG aggregates results from various sources. This guide outlines the capabilities available through the web_search tool.

Search Categories

Categories help refine your search by content type. Use these in the categories parameter (comma-separated).

CategoryDescription
generalDefault web search (Google, Brave, DuckDuckGo, etc.)
imagesImage search results
videosVideo content from YouTube, Vimeo, etc.
newsRecent news articles
mapGeographical and map information
itIT-related searches (StackOverflow, GitHub, etc.)
scienceScientific papers and articles (ArXiv, Google Scholar)
filesTorrent and file searches
social_mediaPosts and profiles from social platforms

Supported Engines

SearXNG can query over 130 engines. Configured engines typically include:

  • Web: Google, Brave, DuckDuckGo, Qwant, Startpage
  • Knowledge: Wikipedia, Wikidata
  • Development: GitHub, StackOverflow, PyPI
  • Social: Reddit, Twitter/X

Advanced Search Parameters

  • categories: Filter by specific types (e.g., news,it).
  • engines: Force specific engines (e.g., google,wikipedia).
  • language: Specify search language (e.g., en, es, fr).
  • pageno: Navigate through multiple pages of results.
  • time_range: Filter by date (day, month, year).
  • safesearch: Control content filtering (0=None, 1=Moderate, 2=Strict).

Programmatic Discovery

Use the web_search_info tool to dynamically retrieve the list of enabled categories and engines from your instance.

Windows Troubleshooting

localhost not reachable while Docker container is running

Symptom: http://localhost:<port>/ returns connection refused or hits the wrong service, but curl from inside the container works fine.

Root cause: WSL2 port relay ghost

WSL2 automatically forwards ports from the Linux VM to the Windows host using wslrelay.exe. When a process inside WSL listens on a port, WSL creates a relay bound to [::1]:<port> (IPv6 loopback) on the Windows side.

When that WSL process stops, wslrelay.exe often does not release the port. The relay entry stays alive as a zombie listener on [::1]:<port>.

Later, when Docker maps a container to the same host port, it binds correctly to 0.0.0.0:<port> — but [::1]:<port> is already taken by the stale relay.

On Windows, localhost resolves to ::1 (IPv6) first. So browser and curl requests to localhost:<port> hit the dead wslrelay.exe entry instead of the Docker container, resulting in a connection error or unexpected response.

Connecting via the explicit IPv4 address 127.0.0.1:<port> bypasses the relay and reaches Docker correctly.

How to diagnose:

powershell
# Check what is listening on the portnetstat -ano | findstr :<port>
# Identify the processesGet-Process -Id <pid1>,<pid2> | Select-Object Id,Name

If you see two entries for the same port — one owned by com.docker.backend and another by wslrelay — this is the problem.

Workarounds:

OptionCommandNotes
Use IPv4 directlyhttp://127.0.0.1:<port>/Immediate, no restart needed
Restart WSLwsl --shutdownKills all stale relays; WSL restarts on next use
Remap Docker portChange host port in docker run -p or docker-compose.ymlAvoids the conflict entirely

Permanent fix:

After wsl --shutdown, restart the Docker container. The relay will no longer exist and localhost:<port> will work normally until the same port is reused inside WSL again.

Prevention:

If you regularly run services on the same port both in WSL and in Docker, prefer one of:

  • Always use Docker for that service, never WSL directly
  • Use different ports for WSL dev and Docker prod instances
  • Add 127.0.0.1:<port>:<port> explicit binding in docker-compose.yml to force IPv4

Related

來源:README.md,提交 8ecbbd3

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分