首页
学习
活动
专区
圈层
工具
发布
MCP广场 >详情页
SearXNG模型上下文协议2026-06-051.4K分享添加福利群:解决AI开发者的「MCP实战痛点」
一种模型上下文协议服务器,使人工智能助手能够使用尊重隐私的元搜索引擎 SearXNG 进行网络搜索。
By tisDDM
2026-06-051.4K
github
详情内容

SearXNG MCP 服务器

一个模型上下文协议(MCP)服务器,使AI助手能够使用SearXNG(一种尊重隐私的元搜索引擎)进行网络搜索。通过自动从SearX.space中选择一个随机实例来实现开箱即用,无需额外部署,同时也支持带有基本身份验证的私有实例。

特性

  • 零配置设置:通过使用来自SearX.space的随机公共实例立即工作
  • 私有实例支持:连接到您自己的SearXNG实例,并可选地使用基本身份验证
  • 使用可自定义参数执行网络搜索
  • 支持多个搜索引擎
  • 专注于隐私的搜索结果
  • Markdown格式的搜索结果
  • 所有参数的合理默认值

注意 - 公共实例可能无法用于此目的,并返回“请求失败,状态码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(可选):设置为 "false" 以禁用在未提供URL时的随机实例选择。默认值为 "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集成

  1. 打开Claude Desktop
  2. 转到设置 > MCP 服务器
  3. 添加一个新的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集成

  1. 打开 VSCode
  2. 转到 设置 > 扩展 > Claude > MCP 设置
  3. 添加一个新的 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 中,这是一个用于构建 AI 代理的轻量级框架。这使您能够创建强大的研究代理,这些代理可以搜索网络并处理结果:

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(一种尊重隐私的元搜索引擎)执行网络搜索。返回具有可自定义参数的相关网页内容。

参数

参数 类型 描述 默认值 是否必填
query string 搜索查询 -
language string 搜索结果的语言代码(例如 'en', 'de', 'fr') 'en'
time_range string 搜索结果的时间范围。选项:'day', 'week', 'month', 'year' null
categories 字符串数组 搜索的类别(例如 'general', 'images', 'news') null
engines 字符串数组 使用的具体搜索引擎 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

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档