WebSearch-MCP

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

  • Utilizes FlareSolverr to bypass Cloudflare protection when crawling websites, ensuring more reliable search results from protected sites

  • Integrates with Docker to run the WebSearch Crawler API service, which handles the actual web searches and retrieves results from the internet

  • Performs web searches through Google's search engine, with the ability to customize search parameters like language, region, and result types

WebSearch-MCP

stdioトランスポート経由でWeb検索機能を提供するモデルコンテキストプロトコル(MCP)サーバー実装。このサーバーはWebSearch Crawler APIと統合して検索結果を取得します。

目次

について

WebSearch-MCPは、MCPをサポートするAIアシスタントにウェブ検索機能を提供するモデルコンテキストプロトコル(MCP)サーバーです。ClaudeのようなAIモデルは、Webをリアルタイムで検索し、あらゆるトピックに関する最新情報を取得できます。

サーバーは、実際の Web 検索を処理するクローラー API サービスと統合され、標準化されたモデル コンテキスト プロトコルを使用して AI アシスタントと通信します。

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop の WebSearch を自動的にインストールするには:

npx -y @smithery/cli install @mnhlt/WebSearch-MCP --client claude

手動インストール

npm install -g websearch-mcp

またはインストールせずに使用します:

npx websearch-mcp

構成

WebSearch MCP サーバーは環境変数を使用して構成できます。

  • API_URL : WebSearch Crawler APIのURL(デフォルト: http://localhost:3001
  • MAX_SEARCH_RESULT : リクエストで指定されていない場合に返される検索結果の最大数(デフォルト: 5

例:

# Configure API URL API_URL=https://crawler.example.com npx websearch-mcp # Configure maximum search results MAX_SEARCH_RESULT=10 npx websearch-mcp # Configure both API_URL=https://crawler.example.com MAX_SEARCH_RESULT=10 npx websearch-mcp

セットアップと統合

WebSearch-MCP のセットアップには、実際の Web 検索を実行するクローラー サービスの構成と、MCP サーバーと AI クライアント アプリケーションの統合という 2 つの主要な部分が含まれます。

クローラーサービスの設定

WebSearch MCPサーバーでは、実際のウェブ検索を実行するためにクローラーサービスが必要です。クローラーサービスはDocker Composeを使って簡単に設定できます。

前提条件

クローラーサービスの開始

  1. 次の内容を含むdocker-compose.ymlという名前のファイルを作成します。
version: '3.8' services: crawler: image: laituanmanh/websearch-crawler:latest container_name: websearch-api restart: unless-stopped ports: - "3001:3001" environment: - NODE_ENV=production - PORT=3001 - LOG_LEVEL=info - FLARESOLVERR_URL=http://flaresolverr:8191/v1 depends_on: - flaresolverr volumes: - crawler_storage:/app/storage flaresolverr: image: 21hsmw/flaresolverr:nodriver container_name: flaresolverr restart: unless-stopped environment: - LOG_LEVEL=info - TZ=UTC volumes: crawler_storage:

Mac Apple Siliconの回避策

version: '3.8' services: crawler: image: laituanmanh/websearch-crawler:latest container_name: websearch-api platform: "linux/amd64" restart: unless-stopped ports: - "3001:3001" environment: - NODE_ENV=production - PORT=3001 - LOG_LEVEL=info - FLARESOLVERR_URL=http://flaresolverr:8191/v1 depends_on: - flaresolverr volumes: - crawler_storage:/app/storage flaresolverr: image: 21hsmw/flaresolverr:nodriver platform: "linux/arm64" container_name: flaresolverr restart: unless-stopped environment: - LOG_LEVEL=info - TZ=UTC volumes: crawler_storage:
  1. サービスを開始します。
docker-compose up -d
  1. サービスが実行されていることを確認します。
docker-compose ps
  1. クローラー API ヘルス エンドポイントをテストします。
curl http://localhost:3001/health

予想される応答:

{ "status": "ok", "details": { "status": "ok", "flaresolverr": true, "google": true, "message": null } }

クローラー API はhttp://localhost:3001で利用できます。

クローラーAPIのテスト

curl を使用してクローラー API を直接テストできます。

curl -X POST http://localhost:3001/crawl \ -H "Content-Type: application/json" \ -d '{ "query": "typescript best practices", "numResults": 2, "language": "en", "filters": { "excludeDomains": ["youtube.com"], "resultType": "all" } }'

カスタム構成

docker-compose.ymlファイル内の環境変数を変更することで、クローラー サービスをカスタマイズできます。

  • PORT : クローラーAPIがリッスンするポート(デフォルト: 3001)
  • LOG_LEVEL : ログレベル(オプション: debug、info、warn、error)
  • FLARESOLVERR_URL : FlareSolverr サービスの URL (Cloudflare 保護を回避するため)

MCPクライアントとの統合

クイックリファレンス: MCP 構成

さまざまなクライアント間の MCP 構成のクイック リファレンスを次に示します。

{ "mcpServers": { "websearch": { "command": "npx", "args": [ "websearch-mcp" ], "environment": { "API_URL": "http://localhost:3001", "MAX_SEARCH_RESULT": "5" // reduce to save your tokens, increase for wider information gain } } } }

Windowsの問題に対する回避策

{ "mcpServers": { "websearch": { "command": "cmd", "args": [ "/c", "npx", "websearch-mcp" ], "environment": { "API_URL": "http://localhost:3001", "MAX_SEARCH_RESULT": "1" } } } }

使用法

このパッケージは、次のパラメータを持つweb_searchツールを公開する stdio トランスポートを使用して MCP サーバーを実装します。

パラメータ

  • query (必須): 検索する検索クエリ
  • numResults (オプション): 返される結果の数 (デフォルト: 5)
  • language (オプション): 検索結果の言語コード(例:'en')
  • region (オプション): 検索結果の地域コード(例:'us')
  • excludeDomains (オプション): 結果から除外するドメイン
  • includeDomains (オプション): 結果にこれらのドメインのみを含める
  • excludeTerms (オプション): 結果から除外する用語
  • resultType (オプション): 返される結果の種類 ('all'、'news'、または 'blogs')

検索応答の例

検索応答の例を次に示します。

{ "query": "machine learning trends", "results": [ { "title": "Top Machine Learning Trends in 2025", "snippet": "The key machine learning trends for 2025 include multimodal AI, generative models, and quantum machine learning applications in enterprise...", "url": "https://example.com/machine-learning-trends-2025", "siteName": "AI Research Today", "byline": "Dr. Jane Smith" }, { "title": "The Evolution of Machine Learning: 2020-2025", "snippet": "Over the past five years, machine learning has evolved from primarily supervised learning approaches to more sophisticated self-supervised and reinforcement learning paradigms...", "url": "https://example.com/ml-evolution", "siteName": "Tech Insights", "byline": "John Doe" } ] }

ローカルテスト

WebSearch MCP サーバーをローカルでテストするには、付属のテスト クライアントを使用できます。

npm run test-client

これにより、MCP サーバーと、検索クエリを入力して結果を表示できるシンプルなコマンド ライン インターフェイスが起動します。

テスト クライアントの API_URL を構成することもできます。

API_URL=https://crawler.example.com npm run test-client

図書館として

このパッケージはプログラムで使用できます。

import { createMCPClient } from '@modelcontextprotocol/sdk'; // Create an MCP client const client = createMCPClient({ transport: { type: 'subprocess', command: 'npx websearch-mcp' } }); // Execute a web search const response = await client.request({ method: 'call_tool', params: { name: 'web_search', arguments: { query: 'your search query', numResults: 5, language: 'en' } } }); console.log(response.result);

トラブルシューティング

クローラーサービスの問題

  • API に到達できません: クローラー サービスが実行されており、構成された API_URL でアクセスできることを確認してください。
  • 検索結果が利用できません: クローラー サービスのログをチェックして、エラーがないか確認してください。
    docker-compose logs crawler
  • FlareSolverr の問題:一部のウェブサイトは Cloudflare による保護を使用しています。これに関連するエラーが表示される場合は、FlareSolverr が動作しているかどうかを確認してください。
    docker-compose logs flaresolverr

MCP サーバーの問題

  • インポート エラー: MCP SDK が最新バージョンであることを確認してください。
    npm install -g @modelcontextprotocol/sdk@latest
  • 接続の問題: stdio トランスポートがクライアントに対して適切に構成されていることを確認してください。

発達

このプロジェクトに取り組むには:

  1. リポジトリをクローンする
  2. 依存関係をインストール: npm install
  3. プロジェクトをビルドします: npm run build
  4. 開発モードで実行: npm run dev

サーバーは、付属のswagger.jsonファイルに定義されているWebSearch Crawler APIを期待しています。設定されたAPI_URLでAPIが実行されていることを確認してください。

プロジェクト構造

  • .gitignore : Git が無視するファイル (node_modules、dist、logs など) を指定します。
  • .npmignore : npm に公開するときに含めないファイルを指定します
  • package.json : プロジェクトのメタデータと依存関係
  • src/ : ソースTypeScriptファイル
  • dist/ : コンパイルされたJavaScriptファイル(ビルド時に生成)

npmへの公開

このパッケージを npm に公開するには:

  1. npm アカウントがあり、ログインしていることを確認してください ( npm login )
  2. package.json のバージョンを更新します ( npm version patch|minor|major )
  3. npm publish実行する

.npmignoreファイルは、公開されたパッケージに必要なファイルのみが含まれるようにします。

  • dist/内のコンパイルされたコード
  • README.md および LICENSE ファイル
  • パッケージ.json

貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

ライセンス

ISC

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

AI アシスタントがリアルタイムの Web 検索を実行し、クローラー API を介してインターネットから最新情報を取得できるようにするモデル コンテキスト プロトコル サーバー。

  1. Table of Contents
    1. About
      1. Installation
        1. Installing via Smithery
        2. Manual Installation
      2. Configuration
        1. Setup & Integration
          1. Setting Up the Crawler Service
          2. Prerequisites
          3. Starting the Crawler Service
          4. Testing the Crawler API
          5. Custom Configuration
        2. Integrating with MCP Clients
          1. Quick Reference: MCP Configuration
        3. Usage
          1. Parameters
          2. Example Search Response
          3. Testing Locally
          4. As a Library
        4. Troubleshooting
          1. Crawler Service Issues
          2. MCP Server Issues
        5. Development
          1. Project Structure
          2. Publishing to npm
        6. Contributing
          1. License
            ID: 67sea795iv