ReActMCP ウェブ検索
ReActMCP Web Searchは、AIアシスタントフレームワークにWeb検索機能を統合するMCP(Model Context Protocol)サーバーです。Exa APIを活用して基本的なWeb検索と高度なWeb検索の両方を実行し、タイトル、URL、公開日、コンテンツの概要を含むマークダウン形式の結果をリアルタイムで返します。
このリポジトリは、さまざまな MCP ツールとサーバーを接続して AI アシスタントに幅広い機能を提供する、より広範な ReActMCP プロジェクトの一部です。
目次
Related MCP server: Agora MCP
特徴
基本的な Web 検索: Exa API を使用して簡単な検索を実行します。
高度な Web 検索: ドメイン制限、テキスト包含要件、日付フィルターなどの追加のフィルター オプションを使用します。
Markdown 出力: 検索結果を Markdown でフォーマットして、タイトル、URL、要約を簡単に組み込むことができます。
MCP 統合: このツールを MCP サーバー エコシステムに簡単に追加して、マルチツール AI アシスタンスを実現します。
要件
インストール
リポジトリのクローンを作成する
git clone https://github.com/mshojaei77/ReActMCP.git
cd ReActMCP
仮想環境を作成する(オプションですが推奨)
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
依存関係をインストールする
pip install -r requirements.txt
構成
環境変数
プロジェクトのルート ディレクトリに、少なくとも次の変数を含む.envファイルを作成します。
EXA_API_KEY=your_exa_api_key_here
OPENAI_API_KEY=...
このキーは、Exa API が Web 検索を実行するために必要です。
MCP構成
MCP設定ファイルmcp_config.jsonは、MCPサーバーで利用可能な設定とツールを定義します。設定例を以下に示します。
{
"websearch": {
"script": "web_search.py",
"encoding_error_handler": "ignore",
"description": "Web search capability using Exa API that provides real-time internet search results. Supports both basic and advanced search with filtering options including domain restrictions, text inclusion requirements, and date filtering. Returns formatted results with titles, URLs, publication dates, and content summaries.",
"required_env_vars": ["EXA_API_KEY"],
"active": true
},
"settings": {
"model": "gpt-4o",
"system_prompt_path": "system_prompt.txt"
}
}
デフォルトの結果数などのパラメータを変更したり、新しい MCP ツールを追加したりすることで、この構成をカスタマイズまたは拡張できます。
システムプロンプト
system_prompt.txtファイルは、AIアシスタントの動作とトーンを設定します。絵文字を含め、親しみやすく、魅力的で、有益な応答となるよう誘導します。プロンプトの例を以下に示します。
You are a helpful, knowledgeable AI assistant with web search capabilities. Your goal is to provide accurate, comprehensive, and up-to-date information to users.
Use lots of emojis and make your responses fun and engaging.
## Available Search Tools
- `search_web`: Basic web search that returns results based on a query
- `advanced_search_web`: Advanced search with filtering options for domains, required text, and date ranges
## Guidelines for Responding to Questions
1. For current information or facts that might have changed since your training data, use the appropriate search tool to find the most recent and relevant information.
2. Use `search_web` for general queries and `advanced_search_web` with appropriate filters for more specific needs.
3. Formulate precise search queries to maximize result relevance.
4. For recent information, use the `max_age_days` parameter in advanced search to limit results to recent publications.
5. When targeting specific sources, use the `include_domains` parameter to focus your search.
6. Cite sources by including URLs from search results.
7. For insufficient or contradictory results, acknowledge limitations and explain findings.
8. Break down complex topics into organized sections.
9. Provide balanced perspectives on controversial topics.
10. Be transparent about uncertainty rather than making up information.
11. Maintain a helpful, informative, and conversational tone.
## Response Quality Standards
Your responses should be well-structured, factually accurate, and tailored to the user's level of understanding on the topic. Use the web search capabilities as your primary tools for accessing current information before responding to time-sensitive or factual queries.
希望するアシスタントの動作に合わせてシステムプロンプトを自由に調整してください。
使用法
Web検索サーバーの実行
MCPサーバーはserversディレクトリに実装されています。サーバーを実行するには、次のコマンドを実行するだけです。
python servers/web_search.py
このコマンドは、リクエストをリッスンし、次のツールを公開する MCP サーバーを起動します。
ツールのテスト
web_search.py には、検索機能の基本的な使い方を示すテスト関数test_search()が用意されています(現在はコメントアウトされています)。このテストは、テスト実行ブロックのコメントを解除し、Pythonのasyncioランナーを使用することで実行できます。
if __name__ == "__main__":
import asyncio
# Uncomment the following line to perform a test search
# asyncio.run(test_search())
mcp.run()
これにより、サンプル クエリの検索結果が印刷され、ツールが期待どおりに機能していることを確認できます。
クロードデスクトップ構成:
次の設定を追加して、Claude Desktop がこのサーバーを使用するように設定してください。
{
"mcpServers": {
"websearch": {
"command": "python",
"args": ["path/to/servers/exa_web_search.py"]
}
}
}
トラブルシューティング
EXA_API_KEY がありません: .envファイルが有効な Exa API キーで適切に設定されていることを確認してください。
**依存関係の問題:**必要なすべてのPythonパッケージがインストールされていることを確認してください( requirements.txtファイルを確認してください)。必要に応じてパッケージを再インストールしてください。
API エラー: Web 検索中にエラーが発生した場合は、ネットワーク接続を確認し、Exa API のステータスを確認してください。
ライセンス
このプロジェクトはMITライセンスの下で提供されています。詳細はLICENSEファイルをご覧ください。
貢献
貢献を歓迎します!提案、バグ修正、改善点がある場合は、問題を報告するか、プルリクエストを送信してください。
コーディングを楽しみながら、ReActMCP Web Search を使って自分だけのパーソナライズされたマルチツール AI アシスタントを構築しましょう! 🚀😊
スターの歴史