wikipedia_mcp_server

igorvan2005/wikipedia_mcp_server

3.2

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.

Tools
4
Resources
0
Prompts
0

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 content
  • wikipedia_get_article: Retrieve full Wikipedia article content
  • wikipedia_get_summary: Get concise article summaries
  • wikipedia_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

  1. Clone or download the project:

    cd wiki_mcp
    
  2. Install dependencies:

    pip install -e .
    
  3. 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 string
  • limit (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 name
  • language (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 name
  • language (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 name
  • link_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

  1. Search for articles:

    Tool: wikipedia_search
    Query: "renewable energy"
    
  2. Get article summary:

    Tool: wikipedia_get_summary
    Title: "Renewable energy"
    
  3. Get full article:

    Tool: wikipedia_get_article
    Title: "Solar power"
    
  4. Explore related topics:

    Tool: wikipedia_get_links
    Title: "Solar power"
    Link type: "internal"
    

Research Workflow

  1. Start with a broad search
  2. Use summaries to quickly evaluate relevance
  3. Get full articles for detailed information
  4. Follow links to explore related topics
  5. 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:

  1. Check existing issues in the project repository
  2. Review the documentation above
  3. Test with the provided examples
  4. 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.