Wikipedia MCP Server について
AI モデルを使って Wikipedia の記事を検索し、個別の記事を評価・分析するサーバーです。検索状況はストリームで返され、モデルを選択できます。利用には OpenRouter の認証情報が必要です。
主な機能
- 01トピックに基づく Wikipedia 記事検索
- 02検索状況と結果のストリーミング
- 03記事の関連性評価
- 04記事の分析生成
- 05対応 AI モデルの選択
活用シーン
- 01調査テーマに関する Wikipedia 記事の検索
- 02記事とクエリの関連性評価
- 03記事の分析生成
MCP 対応
README には HTTP エンドポイントと SSE レスポンスの説明がありますが、MCP ツールやプロトコル連携は記載されていません。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Wikipedia MCP サーバー
AI モデルを使用して Wikipedia の記事を検索、分析するサーバーです。
API リファレンス
記事を検索
エンドポイント:/search
メソッド:POST
Content-Type:application/json
リクエスト本文:
{
"topic": "string",
"limit": 5, // optional, default: 5
"model": "gpt-3.5-turbo" // optional
}
レスポンスは、以下のイベントタイプを含む Server-Sent Events(SSE)ストリームです。
- 開始イベント:
{
"status": "started"
}
- 処理イベント(記事ごとに送信):
{
"status": "processing",
"article": {
"title": "string",
"url": "string",
"snippet": "string",
"relevance_score": float
}
}
- 完了イベント:
{
"status": "completed"
}
- エラーイベント(問題が発生した場合):
{
"status": "error",
"error": "error message"
}
記事を評価
エンドポイント:/evaluate
メソッド:POST
Content-Type:application/json
リクエスト本文:
{
"article": {
"title": "string",
"snippet": "string",
"url": "string"
},
"model": "gpt-3.5-turbo" // optional
}
レスポンス:
{
"relevance": "string",
"article": {
"title": "string",
"snippet": "string",
"url": "string"
}
}
記事を分析
エンドポイント:/analyze
メソッド:POST
Content-Type:application/json
リクエスト本文:
{
"article": {
"title": "string",
"snippet": "string",
"url": "string"
},
"model": "gpt-3.5-turbo" // optional
}
レスポンス:
{
"analysis": "string",
"article": {
"title": "string",
"snippet": "string",
"url": "string"
}
}
サーバーの統計情報
エンドポイント:/stats
メソッド:GET
レスポンス:
{
"total_requests": int,
"endpoints": {
"search": int,
"evaluate": int,
"analyze": int
},
"models": {
"gpt-3.5-turbo": int,
"gpt-4": int,
"claude-2": int,
"mistral-7b": int
},
"errors": int,
"last_update": timestamp
}
環境変数
必須:
OPENROUTER_API_KEY:OpenRouter の API キー
任意:
SERVER_TIMEOUT:サーバーのタイムアウト時間(秒単位、デフォルト:300)KEEPALIVE_TIMEOUT:キープアライブのタイムアウト時間(秒単位、デフォルト:60)MAX_CONNECTIONS:同時接続の最大数(デフォルト:100)
サーバーの実行
- 依存関係をインストールします。
pip install -r requirements.txt
- 環境変数を設定します。
export OPENROUTER_API_KEY=your_api_key
- サーバーを実行します。
python wiki_mcp_server.py
サーバーは http://localhost:8000 で起動します。
統合例
SSE クライアントを使用した Python
from sseclient import SSEClient
import json
def search_articles(topic, max_results=3):
url = "http://localhost:8000/search"
headers = {
"Content-Type": "application/json",
"Accept": "text/event-stream"
}
payload = {
"topic": topic,
"limit": max_results,
"model": "gpt-3.5-turbo"
}
try:
response = requests.post(url,
json=payload,
headers=headers,
stream=True)
if response.status_code != 200:
print(f"Error: {response.status_code}")
print(response.text)
return
client = SSEClient(response)
for event in client.events():
try:
data = json.loads(event.data)
print(f"Event: {data}")
except json.JSONDecodeError as e:
print(f"Error parsing event data: {e}")
except Exception as e:
print(f"Error: {e}")
# Example usage
search_articles("King penguin", 3)
Curl の例
curl -X POST http://localhost:8000/search \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"topic": "King penguin", "limit": 3}'
利用可能なモデル
サーバーは以下の AI モデルをサポートしています。
- gpt-3.5-turbo(デフォルト)
- gpt-4
- claude-2
- mistral-7b
ライセンス
MIT ライセンス
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。