MediaWiki 文章管理 MCP 服务

面向 MCP 兼容客户端的 MediaWiki 文章管理服务,支持对 MediaWiki 实例中的文章进行创建、编辑、删除、读取、分区获取与搜索,适用于通过 AI 助手或 MCP 客户端管理 Wiki 内容的场景。

  • by gesslar
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 gesslar/mediawiki-mcp

使用说明

@gesslar/mediawiki-mcp

A Model Context Protocol server that lets MCP-compatible clients create, edit, delete, read, and search articles on a MediaWiki instance.

Requirements

  • Node.js >=24.11.0
  • A MediaWiki instance with API access
  • A bot account with sufficient permissions for the operations you intend to perform

Installation

npm install -g @gesslar/mediawiki-mcp

Or run it directly via npx:

npx @gesslar/mediawiki-mcp

Configuration

The server is configured through environment variables:

Variable Description
MEDIAWIKI_URL Base URL of the MediaWiki instance (e.g. https://wiki.example.com)
MEDIAWIKI_BOT_USERNAME Bot account username
MEDIAWIKI_BOT_PASSWORD Bot account password

All three variables are required. The server will exit on startup if any are missing.

Note: The server currently authenticates all reads and writes (private: true on the underlying Wikid client). This is intentional for wikis that require authentication for read access. If you're pointing this at a fully public wiki, reads will still work — they'll just be authenticated when they wouldn't strictly need to be. This package is released under 0BSD, so if the hardcoded behaviour doesn't suit your setup, you're welcome to fork it and tweak the Wikid constructor options to taste.

Usage with an MCP client

Add the server to your MCP client configuration. For example, in a Claude Desktop claude_desktop_config.json:

{
  "mcpServers": {
    "mediawiki": {
      "command": "npx",
      "args": ["-y", "@gesslar/mediawiki-mcp"],
      "env": {
        "MEDIAWIKI_URL": "https://wiki.example.com",
        "MEDIAWIKI_BOT_USERNAME": "YourBot@YourBotPassword",
        "MEDIAWIKI_BOT_PASSWORD": "your-bot-password"
      }
    }
  }
}

The server communicates over stdio.

Tools

The server exposes the following tools:

mediawiki_create_article

Create a new article. Fails if the article already exists.

Parameter Type Required Description
title string yes Title of the article to create
content string yes Wikitext content for the article
summary string no Edit summary

mediawiki_edit_article

Edit an existing article. Supports full replacement, append, or prepend, of either the whole page or a single section.

Parameter Type Required Description
title string yes Title of the article to edit
content string yes New wikitext content
summary string no Edit summary
append boolean no Append content instead of replacing
prepend boolean no Prepend content instead of replacing
section number | "new" no Edit only this section (0 is the lead); "new" adds a section at the end
sectiontitle string no Heading for the new section when section is "new"

When section is a number, content replaces that section and must include its heading line. With section: "new", content is the body only; the heading comes from sectiontitle. With append or prepend, content is just the text to add. Section editing keeps request bodies small, which matters on wikis behind a firewall that limits POST body size.

mediawiki_delete_article

Delete an article. Requires delete permissions on the bot account.

Parameter Type Required Description
title string yes Title of the article to delete
reason string no Reason for deletion

mediawiki_get_article

Return the current wikitext content of an article.

Parameter Type Required Description
title string yes Title of the article to retrieve
section number no Return only this section (0 is the lead)

mediawiki_get_sections

List an article's sections with their numbers, for use with the section parameter above.

Parameter Type Required Description
title string yes Title of the article

mediawiki_search

Search articles on the wiki.

Parameter Type Required Description
query string yes Search query
limit number no Maximum number of results (default: 10)

Development

# Start the server locally
npm start

# Lint
npm run lint
npm run lint:fix

License

@gesslar/mediawiki-mcp is released under the 0BSD.

This package includes or depends on third-party components under their own licenses:

Dependency License
@gesslar/wikid 0BSD
@modelcontextprotocol/sdk MIT
zod MIT