igorvan2005/wikipedia_mcp_server
If you are the rightful owner of wikipedia_mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Wikipedia MCP Server provides Claude with comprehensive access to Wikipedia content, enabling real-time information retrieval, article analysis, and knowledge exploration.
env - conda wiki_mcp
Wikipedia MCP Server
A Model Context Protocol (MCP) server that provides Claude with comprehensive access to Wikipedia content, enabling real-time information retrieval, article analysis, and knowledge exploration.
Features
Core Tools
wikipedia_search
: Search Wikipedia articles by title or contentwikipedia_get_article
: Retrieve full Wikipedia article contentwikipedia_get_summary
: Get concise article summarieswikipedia_get_links
: Extract internal and external links from articles
Key Capabilities
- ā Fast Search: Find Wikipedia articles by query with OpenSearch API
- ā Full Content: Access complete article text in clean, readable format
- ā Smart Summaries: Get condensed 2-3 paragraph article summaries
- ā Link Navigation: Explore Wikipedia's interconnected knowledge network
- ā Error Handling: Graceful handling of missing articles, rate limits, and API errors
- ā Rate Limiting: Respectful API usage (1 request per second)
Installation
Prerequisites
- Python 3.8 or higher
- pip package manager
Setup
-
Clone or download the project:
cd wiki_mcp
-
Install dependencies:
pip install -e .
-
For development, install with dev dependencies:
pip install -e ".[dev]"
Usage
Running the Server
The Wikipedia MCP server can be run in several ways:
Direct execution:
python -m wiki_mcp.server
Using the installed script:
wiki-mcp
As a module:
python -c "from wiki_mcp.server import main; import asyncio; asyncio.run(main())"
Configuration with Claude
To use this MCP server with Claude, add it to your Claude configuration:
{
"mcpServers": {
"wikipedia": {
"command": "python",
"args": ["-m", "wiki_mcp.server"],
"env": {}
}
}
}
Tool Reference
wikipedia_search
Search Wikipedia articles by title or content using the OpenSearch API.
Parameters:
query
(required): Search query stringlimit
(optional): Maximum number of results (default: 10, max: 50)language
(optional): Wikipedia language code (default: 'en')
Example:
Search for "quantum computing" with limit of 5 results
Returns: List of matching articles with titles, descriptions, and URLs.
wikipedia_get_article
Retrieve the full content of a Wikipedia article.
Parameters:
title
(required): Article title or page namelanguage
(optional): Wikipedia language code (default: 'en')
Example:
Get full article content for "Artificial Intelligence"
Returns: Complete article text with metadata including title, URL, last modified date, and description.
wikipedia_get_summary
Get a concise summary of a Wikipedia article.
Parameters:
title
(required): Article title or page namelanguage
(optional): Wikipedia language code (default: 'en')
Example:
Get summary for "Machine Learning"
Returns: 2-3 paragraph summary with key facts, metadata, and coordinates (if applicable).
wikipedia_get_links
Extract internal and external links from a Wikipedia article.
Parameters:
title
(required): Article title or page namelink_type
(optional): Type of links ('internal', 'external', 'all') (default: 'all')language
(optional): Wikipedia language code (default: 'en')
Example:
Get all links from "Climate Change" article
Returns: Lists of internal Wikipedia links and external reference URLs.
Examples
Basic Search and Retrieval
-
Search for articles:
Tool: wikipedia_search Query: "renewable energy"
-
Get article summary:
Tool: wikipedia_get_summary Title: "Renewable energy"
-
Get full article:
Tool: wikipedia_get_article Title: "Solar power"
-
Explore related topics:
Tool: wikipedia_get_links Title: "Solar power" Link type: "internal"
Research Workflow
- Start with a broad search
- Use summaries to quickly evaluate relevance
- Get full articles for detailed information
- Follow links to explore related topics
- Use different languages for global perspectives
Error Handling
The server handles various error conditions gracefully:
- Article Not Found: Clear message when articles don't exist
- Disambiguation Pages: Helpful guidance when titles are ambiguous
- Rate Limiting: Automatic rate limiting to respect Wikipedia's API limits
- Network Issues: Timeout and connection error handling
- Invalid Input: Validation and helpful error messages
Rate Limiting
The server implements conservative rate limiting:
- 1 request per second to Wikipedia APIs
- 10-second timeout for requests
- Graceful handling of Wikipedia's rate limits
Development
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=wiki_mcp
# Run specific test file
pytest tests/test_server.py
Code Quality
# Format code
black src/ tests/
# Sort imports
isort src/ tests/
# Type checking
mypy src/
Project Structure
wiki_mcp/
āāā src/wiki_mcp/
ā āāā __init__.py # Package initialization
ā āāā server.py # Main MCP server implementation
ā āāā wikipedia_client.py # Wikipedia API client
ā āāā utils.py # Utility functions
āāā tests/
ā āāā test_server.py # Server tests
ā āāā test_wikipedia_client.py # Client tests
ā āāā test_utils.py # Utility tests
āāā pyproject.toml # Project configuration
āāā README.md # This file
Technical Details
Architecture
- MCP Server: Implements the Model Context Protocol for Claude integration
- Wikipedia Client: Async HTTP client with rate limiting and error handling
- Content Processing: HTML cleaning and text formatting for optimal readability
- Error Recovery: Robust error handling with user-friendly messages
APIs Used
- Wikipedia OpenSearch API: For article search functionality
- Wikipedia REST API v1: For article content and summaries
- Wikipedia Action API: For links and metadata
Performance
- Response time: < 5 seconds for most queries
- Rate limited: 1 request/second to respect Wikipedia
- Content optimization: HTML cleaned and formatted for readability
- Memory efficient: Streaming responses for large articles
Contributing
This is an MVP implementation focused on core functionality. Future enhancements may include:
- Multi-language support expansion
- Image and media handling
- Infobox structured data extraction
- Category browsing
- Caching for improved performance
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- Check existing issues in the project repository
- Review the documentation above
- Test with the provided examples
- Submit detailed bug reports with steps to reproduce
Wikipedia MCP Server v0.1.0 - Bringing Wikipedia's knowledge to Claude through the Model Context Protocol.