SearXNG MCP Server
一个模型上下文协议(Model Context Protocol)服务器,它使 AI 助手能够使用 SearXNG(一个尊重隐私的元搜索引擎)执行网络搜索。
README
SearXNG MCP 服务器
<p align="center"> <img src="logo.png" alt="SearXNG MCP Logo" width="200" height="200"> </p>
一个模型上下文协议 (MCP) 服务器,使 AI 助手能够使用 SearXNG(一个尊重隐私的元搜索引擎)执行网络搜索。通过自动从 SearX.space 中选择一个随机实例,开箱即用,无需额外部署,同时还支持具有基本身份验证的私有实例。
特性
- 零配置设置:通过使用 SearX.space 中的随机公共实例立即工作
- 私有实例支持:连接到您自己的 SearXNG 实例,可以选择使用基本身份验证
- 使用可自定义的参数执行网络搜索
- 支持多个搜索引擎
- 以隐私为中心搜索结果
- Markdown 格式的搜索结果
- 所有参数都有合理的默认值
警告 - 公共实例可能不适用于此目的,并返回“Request failed with status code 429”
安装
前提条件
- Node.js (v16 或更高版本)
- npm (v7 或更高版本)
- 访问 SearXNG 实例(自托管或公共)
从源代码安装
# 克隆存储库
git clone https://github.com/tisDDM/searxng-mcp.git
cd searxng-mcp
# 安装依赖
npm install
# 构建项目
npm run build
配置
SearXNG MCP 服务器可以使用以下环境变量进行配置:
SEARXNG_URL(可选):您的 SearXNG 实例的 URL(例如,https://searx.example.com)。如果未提供,将自动从 SearX.space 中选择一个随机公共实例,从而使服务器无需额外部署即可使用。USE_RANDOM_INSTANCE(可选):设置为 "false" 以在未提供 URL 时禁用随机实例选择。默认为 "true"。SEARXNG_USERNAME(可选):连接到私有实例时用于基本身份验证的用户名SEARXNG_PASSWORD(可选):连接到私有实例时用于基本身份验证的密码
您可以在项目的根目录中的 .env 文件中设置这些环境变量:
SEARXNG_URL=https://searx.example.com
SEARXNG_USERNAME=your_username
SEARXNG_PASSWORD=your_password
用法
运行服务器
# 如果全局安装
searxngmcp
# 如果从源代码安装
node build/index.js
与 Claude Desktop 集成
- 打开 Claude Desktop
- 转到 Settings > MCP Servers
- 添加一个新的 MCP 服务器,配置如下:
{ "mcpServers": { "searxngmcp": { "command": "searxngmcp", "env": { // 可选:如果未提供,将使用随机公共实例 "SEARXNG_URL": "https://searx.example.com", // 可选:仅当私有实例需要身份验证时才需要 "SEARXNG_USERNAME": "your_username", "SEARXNG_PASSWORD": "your_password" }, "disabled": false, "autoApprove": [] } } }
与 VSCode 中的 Claude 集成
- 打开 VSCode
- 转到 Settings > Extensions > Claude > MCP Settings
- 添加一个新的 MCP 服务器,配置如下:
{ "mcpServers": { "searxngmcp": { "command": "node", "args": ["/path/to/searxng-mcp/build/index.js"], "env": { // 可选:如果未提供,将使用随机公共实例 "SEARXNG_URL": "https://searx.example.com", // 可选:仅当私有实例需要身份验证时才需要 "SEARXNG_USERNAME": "your_username", "SEARXNG_PASSWORD": "your_password" }, "disabled": false, "autoApprove": [] } } }
与 Smolagents 一起使用
SearXNG MCP 可以轻松地与 Smolagents 集成,Smolagents 是一个用于构建 AI 代理的轻量级框架。 这使您可以创建强大的研究代理,可以搜索网络并处理结果:
from smolagents import CodeAgent, LiteLLMModel, ToolCollection
from mcp import StdioServerParameters
# 配置 SearXNG MCP 服务器
server_parameters = StdioServerParameters(
command="node",
args=["path/to/searxng-mcp/build/index.js"],
env={
"SEARXNG_URL": "https://your-searxng-instance.com",
"SEARXNG_USERNAME": "your_username", # 可选
"SEARXNG_PASSWORD": "your_password" # 可选
}
)
# 从 MCP 服务器创建一个工具集合
with ToolCollection.from_mcp(server_parameters) as tool_collection:
# 初始化您的 LLM 模型
model = LiteLLMModel(
model_id="your-model-id",
api_key="your-api-key",
temperature=0.7
)
# 使用搜索工具创建一个代理
search_agent = CodeAgent(
name="search_agent",
tools=tool_collection.tools,
model=model
)
# 使用搜索提示运行代理
result = search_agent.run(
"Perform a search about: 'climate change solutions' and summarize the top 5 results."
)
print(result)
可用工具
searxngsearch
使用 SearXNG(一个尊重隐私的元搜索引擎)执行网络搜索。 返回具有可自定义参数的相关网络内容。
参数
| 参数 | 类型 | 描述 | 默认值 | 必需 |
|---|---|---|---|---|
| query | string | 搜索查询 | - | 是 |
| language | string | 搜索结果的语言代码(例如,“en”、“de”、“fr”) | 'en' | 否 |
| time_range | string | 搜索结果的时间范围。 选项:“day”、“week”、“month”、“year” | null | 否 |
| categories | array of strings | 要搜索的类别(例如,“general”、“images”、“news”) | null | 否 |
| engines | array of strings | 要使用的特定搜索引擎 | null | 否 |
| safesearch | number | 安全搜索级别:0(关闭)、1(中等)、2(严格) | 1 | 否 |
| pageno | number | 结果的页码。 必须至少为 1 | 1 | 否 |
| max_results | number | 要返回的最大搜索结果数。 范围:1-50 | 10 | 否 |
示例
// 示例请求
const result = await client.callTool('searxngsearch', {
query: 'climate change solutions',
language: 'en',
time_range: 'year',
categories: ['general', 'news'],
safesearch: 1,
max_results: 5
});
开发
设置
# 克隆存储库
git clone https://github.com/tisDDM/searxng-mcp.git
cd searxng-mcp
# 安装依赖
npm install
构建
npm run build
监视模式(用于开发)
npm run watch
使用 MCP Inspector 进行测试
npm run inspector
许可证
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。