chestnutforty/mcp-wikipedia
If you are the rightful owner of mcp-wikipedia and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The MCP Wikipedia Server is a tool that allows users to search and retrieve Wikipedia articles as they existed at a specific point in time, with support for multiple languages and efficient performance.
MCP Wikipedia Server
An MCP (Model Context Protocol) server that provides Wikipedia search with time-travel capability. This tool allows you to search Wikipedia articles and retrieve their content as it existed at a specific point in time.
Features
- Time-travel search: Retrieve Wikipedia articles as they existed before a specific date
- Multi-language support: Search Wikipedia in any language (default: English)
- Async implementation: Built on async/await for efficient performance
- Historical accuracy: Uses Wikipedia's revision history API
Installation
cd mcp-wikipedia
uv pip install -e .
Usage
Running the Server
python wikipedia_server.py
The server will start on port 8003.
Environment Variables
WIKIPEDIA_ACCESS_TOKEN(optional): Personal access token for higher rate limits
API
search_wikipedia
Search Wikipedia articles as they existed at a specific point in time.
Parameters:
query(string, required): Search queryend_date(string, required): ISO format date (YYYY-MM-DD) - retrieve articles as they existed before this datelang(string, optional): Language code (default: 'en')limit(integer, optional): Maximum number of articles to retrieve (default: 2)
Returns: Formatted string with article titles and content
Example:
# Search for articles about "Python programming" as they existed on January 1, 2023
result = await search_wikipedia(
query="Python programming",
end_date="2023-01-01",
lang="en",
limit=2
)
Use Cases
- Historical research and fact-checking
- Training data for language models (with temporal constraints)
- Base rate and reference statistics from a specific time period
- Biographical data and timelines
- Scientific concepts and their evolution
Architecture
- FastMCP: Uses the FastMCP framework for MCP protocol implementation
- Wikipedia API: Queries Wikipedia's MediaWiki API with revision history support
- Async HTTP: Uses
httpxfor async HTTP requests - Wikitext parsing: Uses
wikitextparserto clean Wikipedia markup
Dependencies
- mcp
- fastapi>=0.116.1
- uvicorn>=0.35.0
- httpx
- wikitextparser>=0.56.4
- pandas
Testing
Setup
Install test dependencies:
uv pip install -e ".[test]"
Running Tests
Run all tests:
pytest
Run with verbose output:
pytest -v
Run specific test file:
pytest tests/test_wikipedia_server.py
Run specific test:
pytest tests/test_wikipedia_server.py::test_search_basic -v
Test Coverage
The test suite covers:
- Basic search: Standard Wikipedia searches with time constraints
- Historical queries: Searches with older dates to test time-travel functionality
- Multiple results: Testing different limit values
- Multi-language: Testing non-English Wikipedia searches
- Error handling: Invalid dates, malformed input, missing results
- Edge cases: Very old dates, special characters, numerical queries
- Response format: Timestamp inclusion, content truncation for long articles
- Default parameters: Testing with and without optional parameters
Note: Tests make real calls to Wikipedia's API. No API keys required, but tests depend on network connectivity and Wikipedia API availability.
License
See the main gpt-oss repository for license information.