vilosource/mcp-mediawiki
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.
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
- Installation
- Configuration
- Usage
- API Reference
- Development
- Docker Deployment
- VS Code Integration
- Contributing
ā” Quick Start
-
Clone the repository:
git clone <repository-url> cd mcp-mediawiki
-
Set up environment:
cp .env.example .env # Edit .env with your MediaWiki credentials
-
Run with Docker (recommended):
docker-compose up --build
-
Or run locally:
pip install -r requirements.txt python mcp_mediawiki.py
-
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
Variable | Description | Default | Required |
---|---|---|---|
MW_API_HOST | MediaWiki hostname | - | ā |
MW_API_PATH | MediaWiki API path | /wiki/ | ā |
MW_USE_HTTPS | Use HTTPS for connections | true | ā |
MW_BOT_USER | Bot account username | - | ā |
MW_BOT_PASS | Bot account password | - | ā |
PORT | Server port | 3000 | ā |
HOST | Server host | 0.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 pagecontent
(string): The new content for the pagesummary
(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 querylimit
(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 pagelimit
(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
-
Clone and setup:
git clone <repository-url> cd mcp-mediawiki cp .env.example .env
-
Install dependencies:
pip install -r requirements.txt
-
Run in development mode:
python mcp_mediawiki.py
-
Run tests:
python -m pytest tests/
Making Changes
-
Code formatting:
black mcp_mediawiki.py
-
Linting:
flake8 mcp_mediawiki.py
-
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
- Install the MCP extension in VS Code
- 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"
}
}
}
}
- 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
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes and add tests
- Ensure all tests pass:
make test
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to your branch:
git push origin feature/amazing-feature
- 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
- MCP Python SDK for the protocol implementation
- mwclient for MediaWiki API integration
- FastAPI for the web framework
Made with ā¤ļø for the AI and MediaWiki communities