SearXNG MCP Server

by tisDDM
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Supports configuration via .env files for setting SearXNG URL and optional authentication credentials

  • Provides search results in Markdown format for better readability and structure

  • Enables running as a Node.js-based MCP server that can be integrated with VSCode and other environments

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 桌面
  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": [] } } }

与 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)

可用工具

搜索

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

参数

范围类型描述默认必需的
询问细绳搜索查询-是的
语言细绳搜索结果的语言代码(例如“en”、“de”、“fr”)'en'
时间范围细绳搜索结果的时间范围。选项:‘天’、‘周’、‘月’、‘年’无效的
类别字符串数组搜索类别(例如“一般”、“图片”、“新闻”)无效的
发动机字符串数组要使用的特定搜索引擎无效的
安全搜索数字安全搜索级别:0(关闭)、1(中等)、2(严格)1
页面编号数字结果页码。必须至少为 11
最大结果数字返回的搜索结果的最大数量。范围:1-5010

例子

// 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

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

模型上下文协议服务器使 AI 助手能够使用尊重隐私的元搜索引擎 SearXNG 执行网络搜索。

  1. Features
    1. Installation
      1. Prerequisites
      2. Install from source
    2. Configuration
      1. Usage
        1. Running the server
        2. Integrating with Claude Desktop
        3. Integrating with Claude in VSCode
      2. Usage with Smolagents
        1. Available Tools
          1. searxngsearch
        2. Development
          1. Setup
          2. Build
          3. Watch mode (for development)
          4. Testing with MCP Inspector
        3. License
          ID: tjp57fcil2