wiki-mcp-server
The Wikipedia MCP Server is designed to search, analyze, and evaluate Wikipedia articles using advanced AI models. It supports multiple AI models and provides endpoints for various operations, offering detailed server statistics.
Wikipedia MCP Server
Server for searching and analyzing Wikipedia articles using AI models.
API Reference
Search Articles
Endpoint: /search
Method: POST
Content-Type: application/json
Request body:
{
"topic": "string",
"limit": 5, // optional, default: 5
"model": "gpt-3.5-turbo" // optional
}
Response is a Server-Sent Events (SSE) stream with the following event types:
- Started event:
{
"status": "started"
}
- Processing event (sent for each article):
{
"status": "processing",
"article": {
"title": "string",
"url": "string",
"snippet": "string",
"relevance_score": float
}
}
- Completion event:
{
"status": "completed"
}
- Error event (if something goes wrong):
{
"status": "error",
"error": "error message"
}
Evaluate Article
Endpoint: /evaluate
Method: POST
Content-Type: application/json
Request body:
{
"article": {
"title": "string",
"snippet": "string",
"url": "string"
},
"model": "gpt-3.5-turbo" // optional
}
Response:
{
"relevance": "string",
"article": {
"title": "string",
"snippet": "string",
"url": "string"
}
}
Analyze Article
Endpoint: /analyze
Method: POST
Content-Type: application/json
Request body:
{
"article": {
"title": "string",
"snippet": "string",
"url": "string"
},
"model": "gpt-3.5-turbo" // optional
}
Response:
{
"analysis": "string",
"article": {
"title": "string",
"snippet": "string",
"url": "string"
}
}
Server Statistics
Endpoint: /stats
Method: GET
Response:
{
"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
}
Environment Variables
Required:
OPENROUTER_API_KEY
: API key for OpenRouter
Optional:
SERVER_TIMEOUT
: Server timeout in seconds (default: 300)KEEPALIVE_TIMEOUT
: Keep-alive timeout in seconds (default: 60)MAX_CONNECTIONS
: Maximum number of concurrent connections (default: 100)
Running the Server
- Install dependencies:
pip install -r requirements.txt
- Set environment variables:
export OPENROUTER_API_KEY=your_api_key
- Run the server:
python wiki_mcp_server.py
The server will start on http://localhost:8000
Integration Examples
Python with SSE Client
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 Example
curl -X POST http://localhost:8000/search \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"topic": "King penguin", "limit": 3}'
Available Models
The server supports the following AI models:
- gpt-3.5-turbo (default)
- gpt-4
- claude-2
- mistral-7b
License
MIT License