隐私搜索服务

SearXNG MCP Server 是一个为AI助手提供隐私保护的元搜索服务的协议服务器,支持零配置部署和私有实例连接。

  • by tisDDM
  • JavaScript
  • 本地部署
  • 43 星标
  • 更新于
在 GitHub 查看 tisDDM/searxng-mcp

使用说明

SearXNG MCP服务器

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

此项目已弃用。其继任者是 searxNcrawl 在https://github.com/DasDigitaleMomentum/searxNcrawl

已弃用

此存储库已弃用,取而代之的是 searxNcrawl继任者目前确实如此 不 包括循环实例选择(通常不可靠)。如果你提交了一份合适的缺陷报告,可以添加它。

特性

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

CAVEAT-公共实例可能无法用于此目的,并返回“请求失败,状态代码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. 打开克劳德桌面
  2. 前往“设置”>“MCP服务器”
  3. 添加具有以下配置的新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集成

  1. 打开VSCode
  2. 前往“设置”>“扩展”>“Claude”>“MCP设置”
  3. 添加具有以下配置的新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": []
        }
      }
    }
    

与Smolters一起使用

SearXNG MCP可以很容易地与Smolagers集成,Smolagers是一个用于构建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)

可用工具

搜索引擎

使用尊重隐私的元搜索引擎SearXNG进行网络搜索。返回具有可自定义参数的相关web内容。

参数

参数 类型 描述 默认值 必填
query string 搜索查询 - 是
language string 搜索结果的语言代码(例如“en”、“de”、“fr”) “en” 否
time_range string 搜索结果的时间范围。选项:“日”、“周”、“月”、“年” 空 否
categories 字符串数组 要搜索的类别(例如,“常规”、“图像”、“新闻”) null 否
engines 字符串数组 要使用的特定搜索引擎 null 否
safesearch number 安全搜索级别:0(关闭)、1(中等)、2(严格) 1 否
页码 编号 结果页码。必须至少为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检验员测试

npm run inspector

许可证

麻省理工学院