mcp-mediawiki

vilosource/mcp-mediawiki

3.2

If you are the rightful owner of mcp-mediawiki 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 MediaWiki MCP Server is a robust Model Context Protocol server designed to integrate AI systems with MediaWiki instances, allowing for efficient content management and interaction.

Tools
5
Resources
0
Prompts
0

MediaWiki MCP Server

A powerful Model Context Protocol (MCP) server that provides seamless integration between AI systems and MediaWiki instances. This server enables LLMs and automation tools to read, search, and edit wiki content through a standardized interface.

šŸš€ Features

  • Full Page Access: Retrieve complete wiki page content without chunking
  • Content Management: Create, edit, and update wiki pages programmatically
  • Search Capabilities: Search pages by title keywords
  • Version History: Access page revision history
  • Docker Support: Containerized deployment with auto-restart capabilities
  • VS Code Integration: Works seamlessly with VS Code's MCP extension
  • Authentication: Bot account support for secure API access

šŸ“‹ Table of Contents

⚔ Quick Start

  1. Clone the repository:

    git clone <repository-url>
    cd mcp-mediawiki
    
  2. Set up environment:

    cp .env.example .env
    # Edit .env with your MediaWiki credentials
    
  3. Run with Docker (recommended):

    docker-compose up --build
    
  4. Or run locally:

    pip install -r requirements.txt
    python mcp_mediawiki.py
    
  5. Test the server:

    curl http://localhost:3000/
    

šŸ“¦ Installation

Prerequisites

  • Python 3.12+
  • Docker (optional but recommended)
  • Access to a MediaWiki instance

Local Installation

# Install dependencies
pip install -r requirements.txt

# Set up environment variables
cp .env.example .env

Docker Installation

# Build and run with Docker Compose
docker-compose up --build -d

āš™ļø Configuration

Create a .env file in the project root with your MediaWiki instance details:

# MediaWiki API Configuration
MW_API_HOST=wiki.example.com
MW_API_PATH=/wiki/
MW_USE_HTTPS=true

# Bot Account Credentials (optional but recommended)
MW_BOT_USER=mcp-bot
MW_BOT_PASS=secret-password

# Server Configuration
PORT=3000
HOST=0.0.0.0

Environment Variables

VariableDescriptionDefaultRequired
MW_API_HOSTMediaWiki hostname-āœ…
MW_API_PATHMediaWiki API path/wiki/āŒ
MW_USE_HTTPSUse HTTPS for connectionstrueāŒ
MW_BOT_USERBot account username-āŒ
MW_BOT_PASSBot account password-āŒ
PORTServer port3000āŒ
HOSTServer host0.0.0.0āŒ

MediaWiki Bot Setup

For write operations, it's recommended to create a bot account with appropriate permissions:

# Add to LocalSettings.php
$wgGroupPermissions['bot']['edit'] = true;
$wgGroupPermissions['bot']['createpage'] = true;
$wgGroupPermissions['bot']['writeapi'] = true;

šŸŽÆ Usage

Health Check

Test if the server is running:

curl http://localhost:3000/

Expected response:

{
  "status": "healthy",
  "service": "mcp-mediawiki",
  "version": "1.0.0"
}

MCP Integration

The server provides an MCP transport at /mcp for integration with MCP-compatible clients like VS Code extensions or AI assistants.

šŸ“š API Reference

Resources

wiki://{title}

Retrieves the complete content of a wiki page.

Example Request:

GET wiki://DevOps

Example Response:

{
  "@id": "wiki://DevOps",
  "@type": "Document", 
  "name": "DevOps",
  "content": "Full wikitext content...",
  "metadata": {
    "url": "https://wiki.example.com/wiki/DevOps",
    "last_modified": "2025-06-06T14:20:00Z",
    "namespace": 0,
    "length": 5032,
    "protection": {},
    "categories": []
  }
}

Tools

get_page

Retrieve the full content and metadata of a specific wiki page.

Parameters:

  • title (string): The title of the wiki page
update_page

Create or edit a wiki page with new content.

Parameters:

  • title (string): The title of the wiki page
  • content (string): The new content for the page
  • summary (string): Edit summary describing the changes

Example:

{
  "title": "DevOps",
  "content": "== Updated Section ==\nNew content here...",
  "summary": "Updated DevOps documentation"
}
search_pages

Search for pages by title keywords.

Parameters:

  • query (string): Search query
  • limit (integer, optional): Maximum number of results (default: 5)
get_page_history

Retrieve the revision history of a wiki page.

Parameters:

  • title (string): The title of the wiki page
  • limit (integer, optional): Maximum number of revisions (default: 5)
server_status

Get basic server configuration and MediaWiki version information.

🐳 Docker Deployment

Using Docker Compose (Recommended)

The project includes a docker-compose.yml file for easy deployment:

services:
  mcp-mediawiki:
    image: mcp-mediawiki:latest
    build: .
    restart: unless-stopped
    ports:
      - "3000:8000"
    env_file:
      - .env
    environment:
      - PYTHONUNBUFFERED=1
    networks:
      mcp_network:
        ipv4_address: 192.168.170.2

networks:
  mcp_network:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 192.168.170.0/24
          gateway: 192.168.170.1

Start the service:

docker-compose up -d --build

View logs:

docker-compose logs -f mcp-mediawiki

Stop the service:

docker-compose down

Manual Docker Build

# Build the image
docker build -t mcp-mediawiki .

# Run the container
docker run -d \
  --name mcp-mediawiki \
  --restart unless-stopped \
  -p 3000:8000 \
  --env-file .env \
  mcp-mediawiki

šŸ› ļø Development

Project Structure

mcp-mediawiki/
ā”œā”€ā”€ docker-compose.yml      # Docker Compose configuration
ā”œā”€ā”€ Dockerfile             # Docker image definition
ā”œā”€ā”€ entrypoint.sh          # Container entrypoint script
ā”œā”€ā”€ mcp_mediawiki.py       # Main server implementation
ā”œā”€ā”€ requirements.txt       # Python dependencies
ā”œā”€ā”€ settings.json          # MCP server settings
ā”œā”€ā”€ .env.example          # Environment variables template
ā”œā”€ā”€ tests/                # Test files
│   └── test_server.py
ā”œā”€ā”€ Makefile              # Development commands
ā”œā”€ā”€ README.md             # This file
ā”œā”€ā”€ Usage.md              # Detailed usage documentation
└── LICENSE               # License file

Local Development Setup

  1. Clone and setup:

    git clone <repository-url>
    cd mcp-mediawiki
    cp .env.example .env
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run in development mode:

    python mcp_mediawiki.py
    
  4. Run tests:

    python -m pytest tests/
    

Making Changes

  1. Code formatting:

    black mcp_mediawiki.py
    
  2. Linting:

    flake8 mcp_mediawiki.py
    
  3. Type checking:

    mypy mcp_mediawiki.py
    

Available Make Commands

make build          # Build Docker image
make run            # Run with Docker Compose
make stop           # Stop Docker containers
make logs           # View container logs
make test           # Run tests
make clean          # Clean up Docker resources

šŸ”§ VS Code Integration

Setup in VS Code

  1. Install the MCP extension in VS Code
  2. Add to your VS Code settings (settings.json):
{
  "mcp.servers": {
    "mediawiki": {
      "command": "python",
      "args": ["path/to/mcp-mediawiki/mcp_mediawiki.py"],
      "env": {
        "MW_API_HOST": "your-wiki-host.com",
        "MW_API_PATH": "/wiki/",
        "MW_USE_HTTPS": "true"
      }
    }
  }
}
  1. Or use the Docker version:
{
  "mcp.servers": {
    "mediawiki": {
      "transport": {
        "type": "http",
        "url": "http://localhost:3000/mcp"
      }
    }
  }
}

Usage in VS Code

Once configured, you can:

  • Ask the AI assistant to "Get the DevOps wiki page"
  • Request edits like "Update the API documentation page with new examples"
  • Search for pages: "Find all pages related to deployment"

šŸ¤ Contributing

We welcome contributions! Please see our for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Ensure all tests pass: make test
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to your branch: git push origin feature/amazing-feature
  7. Open a Pull Request

šŸ“„ License

This project is licensed under the MIT License - see the file for details.

šŸ†˜ Support

  • Issues: Report bugs or request features on
  • Documentation: Check for detailed examples
  • Wiki: Visit the project wiki for additional documentation

šŸ™ Acknowledgments


Made with ā¤ļø for the AI and MediaWiki communities