mcp-searxng

mcp-searxng

About 一個用來讓 AI Agent 可透過 SearXNG 服務來搜尋外部網站內容與資訊的 MCP server 。

erhwenkuo

研究与数据
访问服务器

README

mcp-searxng

<p align="center"> <a href="./README.md"><img alt="README in English" src="https://img.shields.io/badge/English-d9d9d9"></a> <a href="./README_TW.md"><img alt="繁體中文文件" src="https://img.shields.io/badge/繁體中文-d9d9d9"></a> </p>

An example of an MCP Server for use by an AI Agent, designed to allow the AI Agent to search for new external information through SearXNG's open-source meta-search engine.

Currently, many search engines other than Google have emerged in the market, attempting to capture market share in areas where Google falls short. For instance, DuckDuckGo emphasizes not tracking users, Ecosia plants trees with every search, and Brave Search aims to harness collective efforts to build a free search engine.

However, the results returned by these engines are often unsatisfactory. Firstly, they don’t crawl as many web pages as Google does; secondly, their support for Chinese is poor. Although they can access some interesting pages that Google doesn’t display, search engines other than Google are still quite difficult to use.

So why not combine the results from multiple search engines!? That’s exactly what a meta-search engine does. SearXNG, an open-source meta-search engine software, can be self-hosted or used via sites provided by enthusiastic community members. For businesses, SearXNG offers a way to maintain privacy and security control while enabling AI Agents to effectively search for the external data they need.

References:

Purpose

This MCP server demonstrates an SSE-based MCP server (integrated with SearXNG and Microsoft's markdownify to extract web pages into Markdown-formatted text) and its operational mode using the MCP Inspector (MCP client).

Runtime Environment

This project uses uv to manage dependencies and the Python runtime environment. If uv is not yet installed, you can follow the installation instructions on the official website.

The following commands are executed in an Ubuntu 24.04 environment. For operations on other operating systems, please adjust accordingly:

$ curl -LsSf https://astral.sh/uv/install.sh | sh

Download source code:

$ git clone https://github.com/erhwenkuo/mcp-searxng.git

$ cd mcp-searxng

$ uv sync

Running the Service

Running the SearXNG Service

First, install Docker on the machine where it will run and perform the related configurations. For detailed information, please refer to: Install Docker Engine on Ubuntu

In the project directory, there is a pre-configured simple SearXNG setup to facilitate testing.

mcp-searxng/searxng-docker/
├── docker-compose.yaml
└── searxng
    ├── settings.yml
    └── uwsgi.ini

Switch to the searxng-docker directory and use Docker Compose to start a SearXNG service:

$ cd searxng-docker
$ docker compose up -d
$ docker compose ps

NAME      IMAGE                              COMMAND                  SERVICE   CREATED          STATUS                    PORTS
searxng   docker.io/searxng/searxng:latest   "/sbin/tini -- /usr/…"   searxng   29 minutes ago   Up 29 minutes (healthy)   0.0.0.0:8888->8080

The test SearXNG service is mapped to the local machine's port: 8888.

Starting the MCP-SEARXNG Service

Method 1. Using uv to start:

Enter the following command to start:

$ uv run server.py --searxng_url="http://localhost:8888"

INFO:     Started server process [219904]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:5488 (Press CTRL+C to quit)

Using Docker to Start

First, build the Docker image:

$ docker build -t mcp-searxng .

Start mcp-searxng. Since the mcp-searxng service is being started using Docker, you cannot use localhost to point to the SearXNG service address when configuring the connection to SearXNG. It is recommended to directly query the local machine's IP address and then use the SEARXNG_URL environment variable for configuration.

The startup parameters below assume the local machine's IP is 192.168.54.88:

$ docker run -d -e SEARXNG_URL="http://192.168.54.88:8888" -p 5488:5488 mcp-searxng

Verifying the Results

First, install Node.js:

# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

# In lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"

# Download and install Node.js:
nvm install 22

# Verify the Node.js version:
node -v # Should print "v22.14.0".
nvm current # Should print "v22.14.0".

# Verify npm version:
npm -v # Should print "10.9.2".

Next, start the MCP Inspector:

$ npx @modelcontextprotocol/inspector

Starting MCP inspector...
Proxy server listening on port 3000

🔍 MCP Inspector is up and running at http://localhost:5173 🚀

Open http://localhost:5173 in your browser and perform the following actions:

  1. Select SSE in the Transport Type dropdown.
  2. Enter the MCP server's address and port in the URL field: http://localhost:5488/sse.
  3. Click Connect. If the status shows "Connected," it means you have successfully connected to the MCP server.
  4. Click the "Tools" tab at the top.
  5. Click the "List Tools" button, and you should see two tools:
    • web_search
    • web_url_read
  6. Click web_search. On the right, you’ll see the tool’s description and parameters. Enter the keyword you want to search for in the query input field, then click the "Run Tool" button.

The effect is shown in the image below:

Test web_url_read:

  • Click web_url_read. On the right, you’ll see the tool’s description and parameters. Enter the URL of the webpage you want to retrieve in the url input field, then click the "Run Tool" button.

Why Use SSE

This means the MCP server can be a process running remotely, and the AI Agent (client) can connect, use, and disconnect from it anytime, anywhere. In other words, an SSE-based server and client can be decoupled processes (potentially even on decoupled nodes).

Compared to the STDIO-based model, where the client spawns the server as a subprocess, this is different and more suitable for "cloud-native" use cases.

MCP Server

server.py is an SSE-based MCP server. By default, the server runs on 0.0.0.0:5488, but it can be configured using command-line arguments, for example:

uv run server.py --host <your host> --port <your port>

Startup Parameters:

Parameter Required Default Type Description
--host No 0.0.0.0 str Host to bind to
--port No 5488 int Port to listen on
--searxng_url No http://localhost:8888 str SearXNG URL to connect to

推荐服务器

Crypto Price & Market Analysis MCP Server

Crypto Price & Market Analysis MCP Server

一个模型上下文协议 (MCP) 服务器,它使用 CoinCap API 提供全面的加密货币分析。该服务器通过一个易于使用的界面提供实时价格数据、市场分析和历史趋势。 (Alternative, slightly more formal and technical translation): 一个模型上下文协议 (MCP) 服务器,利用 CoinCap API 提供全面的加密货币分析服务。该服务器通过用户友好的界面,提供实时价格数据、市场分析以及历史趋势数据。

精选
TypeScript
MCP PubMed Search

MCP PubMed Search

用于搜索 PubMed 的服务器(PubMed 是一个免费的在线数据库,用户可以在其中搜索生物医学和生命科学文献)。 我是在 MCP 发布当天创建的,但当时正在度假。 我看到有人在您的数据库中发布了类似的服务器,但还是决定发布我的。

精选
Python
mixpanel

mixpanel

连接到您的 Mixpanel 数据。从 Mixpanel 分析查询事件、留存和漏斗数据。

精选
TypeScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。

精选
Python
Nefino MCP Server

Nefino MCP Server

为大型语言模型提供访问德国可再生能源项目新闻和信息的能力,允许按地点、主题(太阳能、风能、氢能)和日期范围进行筛选。

官方
Python
Vectorize

Vectorize

将 MCP 服务器向量化以实现高级检索、私有深度研究、Anything-to-Markdown 文件提取和文本分块。

官方
JavaScript
Mathematica Documentation MCP server

Mathematica Documentation MCP server

一个服务器,通过 FastMCP 提供对 Mathematica 文档的访问,使用户能够从 Wolfram Mathematica 检索函数文档和列出软件包符号。

本地
Python
kb-mcp-server

kb-mcp-server

一个 MCP 服务器,旨在实现便携性、本地化、简易性和便利性,以支持对 txtai “all in one” 嵌入数据库进行基于语义/图的检索。任何 tar.gz 格式的 txtai 嵌入数据库都可以被加载。

本地
Python
Research MCP Server

Research MCP Server

这个服务器用作 MCP 服务器,与 Notion 交互以检索和创建调查数据,并与 Claude Desktop Client 集成以进行和审查调查。

本地
Python
Cryo MCP Server

Cryo MCP Server

一个API服务器,实现了模型补全协议(MCP),用于Cryo区块链数据提取。它允许用户通过任何兼容MCP的客户端查询以太坊区块链数据。

本地
Python