Skip to main content
Glama
Brave Search MCP Server

Brave Search MCP Server

by isaacgounton

SSE サポートを備えた Brave Search MCP

これは、Server-Sent Events(SSE)統合によるBrave Search機能を提供するModel Context Protocol(MCP)サーバーです。Coolifyにデプロイして、リアルタイム検索サービスとして使用できます。

特徴

  • MCP を介した Brave Search API の統合

  • SSEを使用したリアルタイム検索結果

  • DockerとCoolifyに対応

  • TypeScript実装

  • Express.js SSEエンドポイント

Related MCP server: WebSearch-MCP

前提条件

  • 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接続はクライアントが閉じるまで開いたままになります。

  • 各検索結果は接続されているすべてのクライアントにブロードキャストされます

  • サーバーは自動的に切断とクリーンアップを処理します

  • 本番環境では、メッセージエンドポイントの認証を実装することを検討してください。

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that enables AI assistants to perform real-time web searches, retrieving up-to-date information from the internet via a Crawler API.
    1
    86 npm
    42
    ISC
  • A
    license
    A
    quality
    B
    maintenance
    A Model Context Protocol server that provides real-time web search capabilities to AI assistants through pluggable search providers, currently integrated with the Brave Search API.
    5
    26 npm
    16
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    An MCP Server implementation that integrates the Brave Search API, providing, Web Search, Local Points of Interest Search, Image Search, Video Search, News Search and LLM Context Search capabilities
    5
    236 npm
    130
    GPL 3.0