MediaWiki API MCP Server

MediaWiki API MCP Server

Enables LLMs to interact with MediaWiki installations as a bot user, supporting page editing, searching, moving, deleting, comparing revisions, and retrieving site information through the MediaWiki API.

Category
访问服务器

README

MediaWiki API MCP Server

A Model Context Protocol (MCP) server that allows LLMs to interact with MediaWiki installations through the MediaWiki API as a bot user.

Features

Tools

The server provides various MCP tools with the wiki_ prefix:

Tool Description
wiki_page_edit Edit or create MediaWiki pages with comprehensive editing options
wiki_page_get Retrieve page information and content
wiki_page_parse Parse page content with support for wikitext processing, HTML generation, metadata extraction, and advanced parsing features
wiki_page_compare Compare two pages, revisions, or text content to show differences between them
wiki_page_move Move pages with support for talk pages, subpages, and redirects
wiki_page_delete Delete pages with support for talk pages, watchlist management, and logging
wiki_page_undelete Undelete (restore) deleted MediaWiki pages with comprehensive restoration options
wiki_search Search for pages using MediaWiki's search API with advanced filtering
wiki_opensearch Search using OpenSearch protocol for quick suggestions and autocomplete
wiki_meta_siteinfo Get overall site information including general info, namespaces, statistics, extensions, and more

Installation

  1. Clone the repository and checkout the main branch

  2. Install dependencies using UV:

uv install
  1. Set up environment variables:
export MEDIAWIKI_API_URL="http://mediawiki.test/api.php"
export MEDIAWIKI_API_BOT_USERNAME="YourUserName@YourBotName"
export MEDIAWIKI_API_BOT_PASSWORD="YourBotPassword"
export MEDIAWIKI_API_BOT_USER_AGENT="MediaWiki-MCP-Bot/1.0 (your.email@mediawiki.test)"  # Optional

Usage

Running the Server

uv run mediawiki-api-mcp

Or directly:

python -m mediawiki_api_mcp.server

Configuration with Claude Desktop

Configuration File Location

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Template Configuration

Add to your Claude Desktop configuration file:

{
  "mcpServers": {
    "mediawiki-api": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/mediawiki-api-mcp",
        "run",
        "mediawiki-api-mcp"
      ],
      "env": {
        "MEDIAWIKI_API_URL": "http://mediawiki.test/api.php",
        "MEDIAWIKI_API_BOT_USERNAME": "YourUserName@YourBotName",
        "MEDIAWIKI_API_BOT_PASSWORD": "YourBotPassword",
        "MEDIAWIKI_API_BOT_USER_AGENT": "MediaWiki-MCP-Bot/1.0 (your.email@mediawiki.test)"
      }
    }
  }
}

Configuration Instructions

  1. Replace /absolute/path/to/mediawiki-api-mcp with the actual absolute path to this project directory
  2. Update MEDIAWIKI_API_URL with your MediaWiki installation's API endpoint
  3. Set MEDIAWIKI_API_BOT_USERNAME to your bot username (typically in format YourUserName@YourBotName)
  4. Set MEDIAWIKI_API_BOT_PASSWORD to the generated bot password from your wiki's Special:BotPasswords page
  5. Customize MEDIAWIKI_API_BOT_USER_AGENT with appropriate contact information (optional)
Bot Password Setup

Create bot credentials at e.g.: http://mediawiki.test/index.php/Special:BotPasswords

Required permissions:

  • Basic rights: Read pages
  • High-volume editing: Edit existing pages, Create, edit, and move pages
  • Additional permissions as needed for your specific use case
Security Notes
  • Keep your bot credentials secure and never commit them to version control
  • Use the principle of least privilege when setting bot permissions
  • Monitor bot activity through your MediaWiki's logging interface
  • Consider using IP restrictions for additional security

Development

Technology Stack

  • MCP SDK: mcp >= 1.2.0 (using FastMCP pattern)
  • HTTP Client: httpx >= 0.27.0 for MediaWiki API calls
  • Data Validation: pydantic >= 2.0.0 for configuration models
  • Environment: python-dotenv >= 1.0.0 for configuration
  • Testing: pytest with pytest-asyncio for async testing
  • Code Quality: ruff for linting, mypy for type checking

Architecture

  • FastMCP server with @mcp.tool() decorators
  • Separation of concerns: server → handler → client → MediaWiki API
  • AsyncIO throughout for non-blocking operations
  • Environment-based configuration for MediaWiki credentials

Client Layer (client.py and client_modules/)

  • Handles MediaWiki API authentication and requests
  • Manages CSRF tokens and session state
  • Provides typed methods for API operations

Tools Layer (tools/)

  • Defines MCP tool schemas using JSON Schema
  • Separated by functional area (edit, search)
  • Ensures all tools have wiki_ prefix

Handlers Layer (handlers/)

  • Implements actual tool logic
  • Handles argument validation and error handling
  • Returns properly formatted MCP responses

Server Layer (server.py and server_tools/)

  • Main MCP server orchestration
  • Routes tool calls to appropriate handlers
  • Manages configuration and client lifecycle

Project Structure

The project is organized into modular components for maintainability:

mediawiki-api-mcp/
├── mediawiki_api_mcp/
│   ├── __init__.py
│   ├── server.py             # FastMCP server with tool definitions
│   ├── client.py             # MediaWiki API client
│   ├── client_modules/       # Client modules for API operations
│   │    ├── __init__.py      # Client module exports
│   │    └── client_*.py        # Individual client modules
│   ├── handlers/             # Business logic handlers
│   │    ├── __init__.py      # Handler exports
│   │    └── wiki_*.py        # Individual tool handlers
│   ├── tools/                # Tool schemas
│   │   ├── __init__.py       # Tool schema exports
│   │   └── wiki_*.py         # Individual tool schemas
│   └── server_tools/         # Tool definitions
│       ├── __init__.py       # Tool definition exports
│       └── wiki_*.py         # Individual tool definitions
├── tests/                    # Test suite
│   └── test_*.py             # Test files matching handlers
├── docs/                     # Documentation
│   └── tools/                # Tool-specific documentation
│       └── wiki_*.md         # Individual tool docs
├── pyproject.toml            # Project configuration
└── uv.lock                   # Dependency lock file

Running Tests

uv run pytest

Run specific test modules, e.g.:

uv run pytest tests/test_server.py
uv run pytest tests/test_tools.py
uv run pytest tests/test_wiki_page_edit.py
uv run pytest tests/test_wiki_search.py
uv run pytest tests/test_wiki_opensearch.py

Code Quality

# Linting
uv run ruff check

# Type checking
uv run mypy mediawiki_api_mcp

Error Handling

The server implements comprehensive error handling:

  • Configuration errors: Missing environment variables
  • Authentication errors: Invalid credentials or permissions
  • API errors: Network issues, invalid requests
  • Tool errors: Missing parameters, invalid arguments

All errors are returned as MCP TextContent responses for LLM visibility.

Security

  • Bot credentials are required for editing operations
  • All API requests include proper User-Agent headers
  • CSRF tokens are automatically managed
  • Input validation on all tool parameters

License

MIT License

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选