Brave Search MCP Server

by isaacgounton
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

  • Integrates with Brave Search API to provide real-time search capabilities, allowing queries to be performed and results delivered via Server-Sent Events (SSE)

支持 SSE 的 Brave Search MCP

这是一个模型上下文协议 (MCP) 服务器,提供 Brave Search 功能,并集成了服务器发送事件 (SSE)。它可以部署到 Coolify 并用作实时搜索服务。

特征

  • 通过 MCP 集成 Brave Search API
  • 使用 SSE 的实时搜索结果
  • Docker 和 Coolify 已准备就绪
  • TypeScript 实现
  • Express.js SSE 端点

先决条件

  • Brave Search API 密钥
  • Node.js 18+
  • Docker(用于容器化部署)
  • Coolify 实例

本地开发

  1. 克隆存储库
  2. 使用您的 Brave API 密钥创建一个.env文件:
    BRAVE_API_KEY=your_api_key_here PORT=3001
  3. 安装依赖项:
    npm install
  4. 启动开发服务器:
    npm run dev

Docker 部署

  1. 使用 docker-compose 构建并运行:
    docker-compose up --build

Coolify 部署

  1. 在 Coolify 仪表板中,创建一个新服务
  2. 选择“从源部署”
  3. 配置以下内容:
    • 存储库 URL:您的存储库 URL
    • 分支:主
    • 构建命令: npm run build
    • 启动命令: npm start
    • 端口:3001
    • 环境变量:
      • BRAVE_API_KEY=你的 API 密钥
      • 端口=3001

使用 SSE 集成

SSE 端点

GET http://your-server:3001/sse

SSE 端点提供实时搜索结果。使用 EventSource API 连接到该端点:

const eventSource = new EventSource('http://your-server:3001/sse'); eventSource.onmessage = (event) => { const data = JSON.parse(event.data); // Handle the search results console.log(data); }; eventSource.onerror = (error) => { console.error('SSE Error:', error); eventSource.close(); };

消息端点

POST http://your-server:3001/messages Content-Type: application/json { "query": "your search query", "count": 10 // optional, default: 10, max: 20 }

使用此端点触发将广播到所有连接的 SSE 客户端的搜索。

MCP 使用

服务器提供以下MCP工具:

  • brave_web_search :使用 Brave Search API 执行网络搜索
    { query: string; // Search query count?: number; // Number of results (1-20, default: 10) }

错误处理

  • 服务器向所有连接的 SSE 客户端广播错误
  • 错误格式如下:
    { "type": "error", "error": "error message" }

笔记

  • SSE 连接将保持打开状态,直到客户端关闭它
  • 每个搜索结果都会广播给所有连接的客户端
  • 服务器自动处理断开连接和清理
  • 对于生产部署,请考虑对消息端点实施身份验证
-
security - not tested
F
license - not found
-
quality - not tested

与 Brave Search API 集成的模型上下文协议服务器,通过服务器发送事件 (SSE) 提供实时搜索功能。

  1. Features
    1. Prerequisites
      1. Local Development
        1. Docker Deployment
          1. Coolify Deployment
            1. Using the SSE Integration
              1. SSE Endpoint
              2. Messages Endpoint
            2. MCP Usage
              1. Error Handling
                1. Notes
                  ID: sfb2agn09z