关于 SearXNG MCP Server
SearXNG MCP Server 是一个 MCP 服务,让 AI 助手通过 SearXNG 元搜索引擎执行网页搜索。它无需额外部署即可使用,默认从 SearX.space 随机选择公共实例,也支持连接带基本认证的私有实例。
主要功能
- 01零配置,默认使用随机公共实例
- 02支持连接私有 SearXNG 实例
- 03可指定语言、时间范围、分类和搜索引擎
- 04结果以 Markdown 格式返回
适用场景
- 01为 AI 助手补充实时网页搜索能力
- 02在私有 SearXNG 实例上进行隐私友好的搜索
- 03按时间范围或新闻分类查找资料
MCP 相关
该项目是一个 MCP 服务,向 MCP 客户端暴露 searxngsearch 工具,用于执行 SearXNG 搜索。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
SearXNG MCP 服务
一种模型上下文协议(MCP)服务,可让 AI 助手使用 SearXNG 执行网页搜索。SearXNG 是一款尊重隐私的元搜索引擎。它开箱即用,无需额外部署:会自动从 SearX.space 随机选择一个实例,同时也支持使用基本身份验证的私有实例。
此项目已弃用,其继任项目是 searxNcrawl,地址为 https://github.com/DasDigitaleMomentum/searxNcrawl
已弃用
此仓库已弃用,后续请使用 searxNcrawl。继任项目目前不包含轮询选择实例的功能(该功能通常不可靠)。如果你提交合适的缺陷报告,可以添加此功能。
功能
- 零配置安装:使用 SearX.space 中的随机公共实例,即可立即使用
- 支持私有实例:连接到你自己的 SearXNG 实例,并可选择启用基本身份验证
- 使用可自定义的参数执行网页搜索
- 支持多个搜索引擎
- 注重隐私的搜索结果
- 使用 Markdown 格式的搜索结果
- 所有参数均设有合理的默认值
注意:公共实例可能无法用于此目的,并返回“Request failed with status code 429”。
安装
前置条件
- Node.js(v16 或更高版本)
- npm(v7 或更高版本)
- 可访问一个 SearXNG 实例(可自托管或使用公共实例)
从源代码安装
# Clone the repository
git clone https://github.com/tisDDM/searxng-mcp.git
cd searxng-mcp
# Install dependencies
npm install
# Build the project
npm run build
配置
可通过以下环境变量配置 SearXNG MCP 服务:
SEARXNG_URL(可选):SearXNG 实例的 URL(例如https://searx.example.com)。如果未提供,将自动从 SearX.space 随机选择一个公共实例,让服务无需额外部署即可使用。USE_RANDOM_INSTANCE(可选):如果未提供 URL,将此项设为 "false" 以禁用随机选择实例。默认值为 "true"。SEARXNG_USERNAME(可选):连接到私有实例时用于基本身份验证的用户名SEARXNG_PASSWORD(可选):连接到私有实例时用于基本身份验证的密码
你可以在项目根目录下的 .env 文件中设置这些环境变量:
SEARXNG_URL=https://searx.example.com
SEARXNG_USERNAME=your_username
SEARXNG_PASSWORD=your_password
使用方法
运行服务
# If installed globally
searxngmcp
# If installed from source
node build/index.js
与 Claude Desktop 集成
- 打开 Claude Desktop
- 前往 Settings > MCP Servers
- 按照以下配置添加新的 MCP 服务:
{ "mcpServers": { "searxngmcp": { "command": "searxngmcp", "env": { // Optional: If not provided, a random public instance will be used "SEARXNG_URL": "https://searx.example.com", // Optional: Only needed for private instances with authentication "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": { // Optional: If not provided, a random public instance will be used "SEARXNG_URL": "https://searx.example.com", // Optional: Only needed for private instances with authentication "SEARXNG_USERNAME": "your_username", "SEARXNG_PASSWORD": "your_password" }, "disabled": false, "autoApprove": [] } } }
与 Smolagents 配合使用
SearXNG MCP 可以轻松集成到 Smolagents 中。Smolagents 是一个用于构建 AI Agent 的轻量级框架。借助它,你可以创建功能强大的研究 Agent,搜索网络并处理搜索结果:
from smolagents import CodeAgent, LiteLLMModel, ToolCollection
from mcp import StdioServerParameters
# Configure the SearXNG MCP server
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", # Optional
"SEARXNG_PASSWORD": "your_password" # Optional
}
)
# Create a tool collection from the MCP server
with ToolCollection.from_mcp(server_parameters) as tool_collection:
# Initialize your LLM model
model = LiteLLMModel(
model_id="your-model-id",
api_key="your-api-key",
temperature=0.7
)
# Create an agent with the search tools
search_agent = CodeAgent(
name="search_agent",
tools=tool_collection.tools,
model=model
)
# Run the agent with a search prompt
result = search_agent.run(
"Perform a search about: 'climate change solutions' and summarize the top 5 results."
)
print(result)
可用工具
searxngsearch
使用 SearXNG 执行网页搜索。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 | 否 |
示例
// Example request
const result = await client.callTool('searxngsearch', {
query: 'climate change solutions',
language: 'en',
time_range: 'year',
categories: ['general', 'news'],
safesearch: 1,
max_results: 5
});
开发
设置
# Clone the repository
git clone https://github.com/tisDDM/searxng-mcp.git
cd searxng-mcp
# Install dependencies
npm install
构建
npm run build
监听模式(用于开发)
npm run watch
使用 MCP Inspector 进行测试
npm run inspector
许可证
MIT
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。