SearxNG MCP Server
SearxNG MCP 服务器
模型上下文协议 (MCP) 服务器使用 SearxNG 提供网络搜索功能,允许像 Claude 这样的 AI 助手搜索网络。
由人工智能在人类监督下创建——因为有时即使是人工智能也需要有人告诉它什么时候该喝杯咖啡!🤖☕
概述
该项目实现了一个 MCP 服务器,用于连接到尊重隐私的元搜索引擎 SearxNG。该服务器为大型语言模型提供了一种简单高效的方式,可以在不追踪用户的情况下搜索网络。
该服务器专为 LLM 设计,仅包含必要功能,以最大限度地减少上下文窗口的使用。这种精简的方法确保了 LLM 和搜索引擎之间的高效通信,从而为更重要的信息保留了宝贵的上下文空间。
特征
通过 SearxNG 进行注重隐私的网络搜索
用于 LLM 集成的简单 API
与 Claude Desktop 和其他符合 MCP 的客户端兼容
可配置的搜索参数
针对法学硕士 (LLM) 优化的清晰、格式化的搜索结果
Related MCP server: mcp-searxng
与 MCP 兼容应用程序集成
集成示例
使用 pipx 运行(推荐,无需安装)
在您的主目录中创建一个.clauderc文件:
{
"mcpServers": {
"searxng": {
"command": "pipx",
"args": [
"run", "searxng-simple-mcp@latest"
],
"env": {
"SEARXNG_MCP_SEARXNG_URL": "https://your-instance.example.com"
}
}
}
}使用 uvx run(无需安装)
{
"mcpServers": {
"searxng": {
"command": "uvx",
"args": [
"run", "searxng-simple-mcp@latest"
],
"env": {
"SEARXNG_MCP_SEARXNG_URL": "https://your-instance.example.com"
}
}
}
}使用 Python 和 pip(需要安装)
{
"mcpServers": {
"searxng": {
"command": "python",
"args": ["-m", "searxng_simple_mcp.server"],
"env": {
"SEARXNG_MCP_SEARXNG_URL": "https://your-instance.example.com"
}
}
}
}与 Docker 一起使用(无需安装)
{
"mcpServers": {
"searxng": {
"command": "docker",
"args": [
"run", "--rm", "-i", "--network=host",
"-e", "SEARXNG_MCP_SEARXNG_URL=http://localhost:8080",
"ghcr.io/sacode/searxng-simple-mcp:latest"
]
}
}
}**注意:**在 MCP 服务器中使用 Docker 时:
必须使用
args数组中的-e标志直接传递环境变量,因为env对象未正确传递给 Docker 容器。如果您需要访问在 localhost 上运行的 SearxNG 实例(例如, http://localhost:8080 ),则必须使用
--network=host标志允许容器访问主机网络。否则,容器内的 “localhost” 将指向容器本身,而不是您的主机。当使用
--network=host时,不需要端口映射(-p)并且会被忽略,因为容器直接共享主机的网络堆栈。
配置
使用环境变量配置服务器:
环境变量 | 描述 | 默认值 |
SEARXNG_MCP_SEARXNG_URL | 要使用的 SearxNG 实例的 URL | |
SEARXNG_MCP_TIMEOUT | HTTP 请求超时(秒) | 10 |
SEARXNG_MCP_DEFAULT_RESULT_COUNT | 默认返回结果数 | 10 |
SEARXNG_MCP_DEFAULT_LANGUAGE | 结果的语言代码(例如“en”、“ru”、“all”) | 全部 |
SEARXNG_MCP_DEFAULT_FORMAT | 结果的默认格式('text','json') | 文本 |
SEARXNG_MCP_LOG_LEVEL | 日志级别(例如,“DEBUG”、“INFO”、“WARNING”、“ERROR”、“CRITICAL”) | 错误 |
传输协议 | 传输协议(“stdio”或“sse”) | 标准输入输出 |
**注意:**设置高于 ERROR 的日志级别(例如 DEBUG 或 INFO)可能会因通信通道中的输出过多而破坏与某些应用程序的集成。
如果您不想托管自己的实例,可以在https://searx.space上找到公共 SearxNG 实例列表。
安装和使用
先决条件
Python 3.10 或更高版本
SearxNG 实例(公共或自托管)
选项 1:无需安装即可运行(推荐)
使用此服务器的最简单方法是使用 pipx 或 uvx,它允许您运行该包而无需永久安装它:
# Using pipx
pip install pipx # Install pipx if you don't have it
pipx run searxng-simple-mcp
# OR using uvx
pip install uvx # Install uvx if you don't have it
uvx run searxng-simple-mcp您可以直接传递配置选项:
# Using pipx with custom SearxNG instance
pipx run searxng-simple-mcp --searxng-url https://your-instance.example.com选项 2:从 PyPI 或源代码安装
对于更永久的安装:
# From PyPI using pip
pip install searxng-simple-mcp
# OR using uv (faster installation)
pip install uv
uv pip install searxng-simple-mcp
# OR from source
git clone https://github.com/Sacode/searxng-simple-mcp.git
cd searxng-simple-mcp
pip install uv
uv pip install -e .安装后,您可以使用以下命令运行服务器:
# Run directly after installation
python -m searxng_simple_mcp.server
# OR with configuration options
python -m searxng_simple_mcp.server --searxng-url https://your-instance.example.com选项 3:Docker
如果您更喜欢使用 Docker:
# Pull the Docker image
docker pull ghcr.io/sacode/searxng-simple-mcp:latest
# Run the container with default settings (stdio transport)
docker run --rm -i ghcr.io/sacode/searxng-simple-mcp:latest
# Run with environment file for configuration
docker run --rm -i --env-file .env ghcr.io/sacode/searxng-simple-mcp:latest
# Run with SSE transport (starts HTTP server on port 8000)
docker run -p 8000:8000 -e TRANSPORT_PROTOCOL=sse ghcr.io/sacode/searxng-simple-mcp:latest
# Building locally
docker build -t searxng-simple-mcp:local .
docker run --rm -i searxng-simple-mcp:local
# Using Docker Compose
docker-compose up -d有关完整的 Docker 使用信息,请参阅下面的Docker 配置部分。
传输协议
MCP 服务器支持两种传输协议:
STDIO (默认):用于 CLI 应用程序和直接集成
所有示例中均默认使用
适合与 Claude Desktop 和其他符合 MCP 的客户端集成
未启动 HTTP 服务器
SSE (服务器发送事件):适用于基于 Web 的客户端和基于 HTTP 的集成
启动客户端可以连接的 HTTP 服务器
对于需要实时更新的 Web 应用程序和服务很有用
使用 Docker 时需要端口映射
使用 SSE 传输
要使用 SSE 传输协议:
直接执行:
# Set the transport protocol to SSE TRANSPORT_PROTOCOL=sse python -m searxng_simple_mcp.server # Or with FastMCP fastmcp run src/searxng_simple_mcp/server.py --transport sse使用 Docker :
# Run with SSE transport protocol docker run -p 8000:8000 -e TRANSPORT_PROTOCOL=sse -e SEARXNG_MCP_SEARXNG_URL=https://your-instance.example.com ghcr.io/sacode/searxng-simple-mcp:latest使用 Docker Compose (来自包含的
docker-compose.yml):environment: - SEARXNG_MCP_SEARXNG_URL=https://searx.info - SEARXNG_MCP_TIMEOUT=10 - SEARXNG_MCP_MAX_RESULTS=20 - SEARXNG_MCP_LANGUAGE=all - TRANSPORT_PROTOCOL=sse # Transport protocol: stdio or sse
使用 SSE 时,默认情况下可通过 HTTP http://localhost:8000访问服务器。
要从 MCP 客户端连接到 SSE 服务器,请使用如下配置:
{
"mcpServers": {
"searxng": {
"url": "http://localhost:8000",
"transport": "sse"
}
}
}**注意:**并非所有应用程序都支持 SSE 传输协议。使用此传输方式之前,请确保您的 MCP 客户端兼容 SSE。
发展
对于开发和测试:
# Install dependencies
uv pip install -e .
# Run linter and formatter
ruff check .
ruff check --fix .
ruff format .
# Run the server directly
python -m src.searxng_simple_mcp.server
# OR using FastMCP
fastmcp run src/searxng_simple_mcp/server.py # Use stdio transport (default)
fastmcp run src/searxng_simple_mcp/server.py --transport sse # Use sse transport
# Run in development mode (launches MCP Inspector)
fastmcp dev src/searxng_simple_mcp/server.py发布到 PyPI
对于需要将软件包的新版本发布到 PyPI 的维护人员:
# Install development dependencies
npm run install:deps
# Clean, build, and check the package
npm run build:package
npm run check:package
# Publish to PyPI (requires PyPI credentials)
npm run publish:pypi
# Alternatively, use the all-in-one commands to update version and publish
npm run publish:patch # Increments patch version (1.0.1 -> 1.0.2)
npm run publish:minor # Increments minor version (1.0.1 -> 1.1.0)
npm run publish:major # Increments major version (1.0.1 -> 2.0.0)这些命令将:
更新 package.json 和 pyproject.toml 中的版本
清理 dist 目录以删除旧版本
构建包(创建轮子和源分发)
检查包中是否有错误
将包上传到 PyPI
你需要拥有一个 PyPI 帐户并通过 Twine 进行身份验证。你可以通过以下方式设置身份验证:
在你的主目录中创建一个
.pypirc文件使用环境变量(
TWINE_USERNAME和TWINE_PASSWORD)使用 PyPI API 令牌(推荐)
Docker 配置
在 MCP 服务器上使用 Docker 时,请记住以下几点:
与 MCP 客户端集成:使用“与 Docker 一起使用”部分中显示的配置与 Claude Desktop 或其他符合 MCP 的客户端集成。
传输协议:
默认情况下,Docker 容器使用 stdio 传输协议
对于 SSE 传输,请参阅使用 SSE 传输部分
配置选项:
使用环境文件(.env)配置服务器:
docker run --env-file .env ...使用
-e标志传递单个环境变量:docker run -e SEARXNG_MCP_SEARXNG_URL=https://example.com ...请参阅配置部分以了解可用的环境变量
网络:
当您需要访问主机上的服务时,请使用
--network=host将 SSE 服务器暴露到您的网络时使用
-p 8000:8000
包结构
searxng-simple-mcp/
├── src/
│ ├── run_server.py # Entry point script
│ └── searxng_simple_mcp/ # Main package
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker configuration
└── pyproject.toml # Python project configuration贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。
Available Tools
1 toolweb_searchC
Perform a web search using SearxNG and return formatted results.
Results are returned in either text format (human-readable) or JSON format depending on the result_format parameter selected.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query string to look for on the web | |
| result_count | No | Maximum number of results to return | |
| categories | No | Categories to filter by (e.g., 'general', 'images', 'news', 'videos') | |
| language | No | Language code for results (e.g., 'all', 'en', 'ru', 'fr') | all |
| time_range | No | Time restriction for results | |
| result_format | No | Output format - 'text' for human-readable, 'json' for structured data | text |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that results are returned in text or JSON format based on a parameter, which adds some context about output behavior. However, it fails to disclose critical traits such as whether this is a read-only operation, potential rate limits, authentication needs, error handling, or any side effects. For a search tool with zero annotation coverage, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and well-structured, consisting of two sentences that efficiently convey the core functionality and output format options. It avoids unnecessary details and is front-loaded with the main purpose. However, it could be slightly more polished by integrating the format explanation more seamlessly, but overall it's efficient with zero waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (6 parameters, 1 required) and the presence of an output schema (which reduces the need to describe return values in the description), the description is somewhat complete but has gaps. It covers the basic action and output format but lacks usage guidelines, behavioral context, and deeper parameter insights. With no annotations and only partial compensation in the description, it's adequate but not fully comprehensive for effective agent use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, meaning all parameters are well-documented in the input schema itself. The description adds minimal value beyond the schema by briefly mentioning the result_format parameter's effect on output format. However, it doesn't provide additional semantic context, examples, or usage tips for parameters like categories or time_range. Given the high schema coverage, a baseline score of 3 is appropriate as the description doesn't compensate with extra insights.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool performs a web search using SearxNG and returns formatted results. It specifies the action ('perform a web search'), resource ('web'), and output format ('formatted results'), making the purpose explicit. However, it doesn't differentiate from siblings since there are none, so it doesn't reach the highest score of 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It mentions the result_format parameter but doesn't explain when to choose text vs. JSON, nor does it discuss any prerequisites, limitations, or typical use cases. This lack of contextual guidance leaves the agent without direction on optimal usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v1.0.0- Changed
web_search3 fields changed- changed
Input schema / properties / result_format / descriptionPrevious value: -"Output format - 'text' for human-readable or 'json' for structured data"New value: +"Output format - 'text' for human-readable, 'json' for structured data" - removed
Input schema / titleRemoved value: -"web_searchArguments" - changed
Output schema / (root)Previous value: -nullNew value: +{ + "$defs": { + "SearxngResult": { + "description": "Model for a single SearxNG search result.", + "properties": { + "category": { + "title": "Category", + "type": "string" + }, + "content": { + "title": "Content", + "type": "string" + }, + "engine": { + "title": "Engine", + "type": "string" + }, + "engines": { + "items": { + "type": "string" + }, + "title": "Engines", + "type": "array" + }, + "img_src": { + "title": "Img Src", + "type": "string" + }, + "parsed_url": { + "items": { + "type": "string" + }, + "title": "Parsed Url", + "type": "array" + }, + "positions": { + "items": { + "type": "integer" + }, + "title": "Positions", + "type": "array" + }, + "priority": { + "title": "Priority", + "type": "string" + }, + "publishedDate": { + "default": null, + "title": "Publisheddate" + }, + "score": { + "title": "Score", + "type": "number" + }, + "template": { + "title": "Template", + "type": "string" + }, + "thumbnail": { + "default": null, + "title": "Thumbnail" + }, + "title": { + "title": "Title", + "type": "string" + }, + "url": { + "title": "Url", + "type": "string" + } + }, + "required": [ + "url", + "title", + "content", + "engine", + "template", + "parsed_url", + "img_src", + "priority", + "engines", + "positions", + "score", + "category" + ], + "title": "SearxngResult", + "type": "object" + } + }, + "properties": { + "result": { + "anyOf": [ + { + "type": "string" + }, + { + "items": { + "$ref": "#/$defs/SearxngResult" + }, + "type": "array" + } + ], + "title": "Result" + } + }, + "required": [ + "result" + ], + "title": "_WrappedResult", + "type": "object", + "x-fastmcp-wrap-result": true +}
1 tool update
- First observed
web_search
TDQS
Scored across 1 tool
With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool 'web_search' has a clearly defined and distinct purpose.
Since there is only one tool, naming consistency is inherently perfect. The tool name 'web_search' follows a clear verb_noun pattern and is descriptive.
A single tool is too few for a server named 'SearxNG MCP Server', which suggests a broader search functionality. While web search is core, the scope feels thin without additional tools like image_search, news_search, or configuration options.
The tool surface is severely incomplete for a search server. It only covers basic web search, missing obvious functionalities such as image search, news search, or advanced search parameters that would be expected from a search engine integration.
Maintenance
Related MCP Connectors
Provides AI assistants with access to Seltz's powerful Web Search capabilities.
Web search, agentic search, news, page retrieval, sitemaps, and trending topics through Search1API.
Search Google straight from your AI agent. Web results, images, videos, news, products, scholarly ar
The best web search for your AI Agent
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables web search, image search, and news search through a self-hosted SearXNG instance. Provides privacy-focused meta-search capabilities aggregating results from multiple search engines.3153 npm1MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to perform web searches and read URL content via a SearXNG instance.218 npmMIT
- FlicenseNot gradedqualityDmaintenanceProvides free web search, content fetching, image search, and deep research via SearXNG, no API keys required.-
- FlicenseNot gradedqualityDmaintenanceProvides fast, self-hosted web search and reliable web scraping using SearXNG and Crawl4AI, integrated as MCP tools for Claude Code.47-