Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The server provides various MCP tools with the `wiki_` prefix:
|---|---|
|[**`wiki_page_edit`**](docs/tools/wiki_page_edit.md)|Edit or create MediaWiki pages with comprehensive editing options|
|[**`wiki_page_get`**](docs/tools/wiki_page_get.md)|Retrieve page information and content|
|[**`wiki_page_parse`**](docs/tools/wiki_page_parse.md)|Parse page content with support for wikitext processing, HTML generation, metadata extraction, and advanced parsing features|
|[**`wiki_page_compare`**](docs/tools/wiki_page_compare.md)|Compare two pages, revisions, or text content to show differences between them|
|[**`wiki_page_move`**](docs/tools/wiki_page_move.md)|Move pages with support for talk pages, subpages, and redirects|
|[**`wiki_page_delete`**](docs/tools/wiki_page_delete.md)|Delete pages with support for talk pages, watchlist management, and logging|
|[**`wiki_page_undelete`**](docs/tools/wiki_page_undelete.md)|Undelete (restore) deleted MediaWiki pages with comprehensive restoration options|
Expand Down
91 changes: 91 additions & 0 deletions docs/tools/wiki_page_compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
### wiki_page_compare

Compare two pages, revisions, or text content to show differences between them. This tool provides comprehensive diff capabilities including HTML-formatted differences, metadata comparison, and slot-specific comparisons for multi-content revisions.

**From Source Parameters (at least one required):**
- `fromtitle` (string): Title of the first page to compare
- `fromid` (integer): Page ID of the first page to compare
- `fromrev` (integer): Revision ID of the first revision to compare

**To Source Parameters (at least one required):**
- `totitle` (string): Title of the second page to compare
- `toid` (integer): Page ID of the second page to compare
- `torev` (integer): Revision ID of the second revision to compare
- `torelative` (string): Use a revision relative to the "from" revision. Options: "cur" (current), "next", "prev"

**Content Override Parameters:**
- `fromslots` (string): Pipe-separated list of slots to override in the "from" revision (e.g., "main")
- `toslots` (string): Pipe-separated list of slots to override in the "to" revision (e.g., "main")
- `frompst` (boolean): Apply pre-save transform to "from" content (default: false)
- `topst` (boolean): Apply pre-save transform to "to" content (default: false)

**Templated Slot Parameters for "from" side:**
- `fromtext_main` (string): Custom text content for the main slot of the "from" revision
- `fromsection_main` (string): Section identifier when using section content for the "from" revision
- `fromcontentmodel_main` (string): Content model for the "from" text (e.g., "wikitext", "json", "css")
- `fromcontentformat_main` (string): Content serialization format for the "from" text

**Templated Slot Parameters for "to" side:**
- `totext_main` (string): Custom text content for the main slot of the "to" revision
- `tosection_main` (string): Section identifier when using section content for the "to" revision
- `tocontentmodel_main` (string): Content model for the "to" text (e.g., "wikitext", "json", "css")
- `tocontentformat_main` (string): Content serialization format for the "to" text

**Output Control Parameters:**
- `prop` (string): Pipe-separated list of information to include. Options: "comment", "diff", "diffsize", "ids", "parsedcomment", "rel", "size", "timestamp", "title", "user" (default: "diff|ids|title")
- `slots` (string): Return individual diffs for specific slots rather than combined diff. Use "*" for all slots or pipe-separated slot names
- `difftype` (string): Format of the diff output. Options: "table" (default), "inline", "unified"

**Example Usage:**

Compare two pages by title:
```
fromtitle: "Template:Example"
totitle: "Template:Example/sandbox"
prop: "diff|title|user|timestamp"
```

Compare specific revisions:
```
fromrev: 12345
torev: 12346
difftype: "unified"
```

Compare current revision to previous:
```
fromtitle: "Main Page"
torelative: "prev"
prop: "diff|diffsize|comment"
```

Compare with custom content:
```
fromrev: 12345
torev: 12346
fromslots: "main"
fromtext_main: "Custom comparison text"
fromcontentmodel_main: "wikitext"
```

**Return Format:**

The tool returns a formatted text output containing:
- Page/revision identification information
- Diff size and metadata (timestamps, users, comments) if requested
- HTML-formatted diff showing additions, deletions, and changes
- Individual slot diffs if multiple slots are compared
- Clear indication when no differences are found

**Common Use Cases:**
- Reviewing changes between page revisions
- Comparing live pages with sandbox versions
- Analyzing differences in template implementations
- Checking content changes before publishing
- Debugging page content issues by comparing known good revisions

**Notes:**
- At least one "from" parameter and one "to" parameter must be specified
- Templated slot parameters use underscores in parameter names (e.g., `fromtext_main`) but are converted to hyphens internally (e.g., `fromtext-main`)
- The diff HTML output is formatted for display in tables with appropriate CSS classes
- Relative comparisons at the first or last revision of a page may produce special results as documented in the MediaWiki API
104 changes: 104 additions & 0 deletions docs/tools/wiki_page_parse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
### wiki_page_parse

Parse content and return parser output from a MediaWiki page using the comprehensive Parse API. This tool provides access to MediaWiki's full parsing engine with support for wikitext processing, HTML generation, metadata extraction, and advanced parsing features.

**Content Source Parameters (provide one):**
- `title` (string): Title of page the text belongs to. If omitted, contentmodel must be specified
- `pageid` (integer): Parse the content of this page. Overrides `page` parameter
- `oldid` (integer): Parse the content of this revision. Overrides `page` and `pageid` parameters
- `text` (string): Text to parse. Use `title` or `contentmodel` to control the content model
- `revid` (integer): Revision ID, for {{REVISIONID}} and similar variables
- `summary` (string): Summary to parse (for parsing edit summaries)
- `page` (string): Parse the content of this page. Cannot be used together with `text` and `title`

**Output Control Parameters:**
- `redirects` (boolean): If page or pageid is set to a redirect, resolve it (default: false)
- `prop` (string): Which pieces of information to get. Pipe-separated values from:
- `text`: Gives the parsed text of the wikitext (HTML output)
- `langlinks`: Gives the language links in the parsed wikitext
- `categories`: Gives the categories in the parsed wikitext
- `categorieshtml`: Gives the HTML version of the categories
- `links`: Gives the internal links in the parsed wikitext
- `templates`: Gives the templates in the parsed wikitext
- `images`: Gives the images in the parsed wikitext
- `externallinks`: Gives the external links in the parsed wikitext
- `sections`: Gives the sections in the parsed wikitext
- `revid`: Adds the revision ID of the parsed page
- `displaytitle`: Adds the title of the parsed wikitext
- `subtitle`: Adds the page subtitle for the parsed page
- `wikitext`: Gives the original wikitext that was parsed
- `properties`: Gives various properties defined in the parsed wikitext
- `parsewarnings`: Gives the warnings that occurred while parsing content
- `iwlinks`: Gives interwiki links in the parsed wikitext
- Default: `text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings`

**Formatting and Display Parameters:**
- `wrapoutputclass` (string): CSS class to use to wrap the parser output (default: "mw-parser-output")
- `usearticle` (boolean): Use the ArticleParserOptions hook to ensure options match article page views
- `parsoid` (boolean): Generate HTML conforming to the MediaWiki DOM spec using Parsoid
- `useskin` (string): Apply the selected skin to the parser output (affects text, langlinks, modules, etc.)
- `mobileformat` (boolean): Return parse output in a format suitable for mobile devices

**Processing Control Parameters:**
- `pst` (boolean): Do a pre-save transform on the input before parsing it. Only valid when used with `text`
- `onlypst` (boolean): Do a pre-save transform (PST) on the input, but don't parse it. Only valid when used with `text`
- `preview` (boolean): Parse in preview mode
- `sectionpreview` (boolean): Parse in section preview mode (enables preview mode too)

**Section Parameters:**
- `section` (string): Only parse the content of the section with this identifier. Use "new" to parse text and sectiontitle as if adding a new section
- `sectiontitle` (string): New section title when section is "new". Unlike page editing, this does not fall back to summary when omitted

**Output Customization Parameters:**
- `disablelimitreport` (boolean): Omit the limit report ("NewPP limit report") from the parser output
- `disableeditsection` (boolean): Omit edit section links from the parser output
- `disablestylededuplication` (boolean): Do not deduplicate inline stylesheets in the parser output
- `disabletoc` (boolean): Omit table of contents in output
- `showstrategykeys` (boolean): Whether to include internal merge strategy information in jsconfigvars

**Content Model Parameters:**
- `contentformat` (string): Content serialization format used for the input text. Only valid when used with `text`
- Options: application/json, application/octet-stream, text/css, text/javascript, text/plain, text/x-wiki, etc.
- `contentmodel` (string): Content model of the input text. If omitted, title must be specified. Only valid when used with `text`
- Options: wikitext, javascript, css, json, text, etc.

**Template Sandbox Parameters:**
- `templatesandboxprefix` (string): Template sandbox prefix, as with Special:TemplateSandbox (pipe-separated for multiple values)
- `templatesandboxtitle` (string): Parse the page using templatesandboxtext in place of the contents of the page named here
- `templatesandboxtext` (string): Parse the page using this page content in place of the page named by templatesandboxtitle
- `templatesandboxcontentmodel` (string): Content model of templatesandboxtext
- `templatesandboxcontentformat` (string): Content format of templatesandboxtext

**Examples:**

Parse a page by title:
```
wiki_page_parse(title="Main Page")
```

Parse specific wikitext:
```
wiki_page_parse(text="Hello '''world'''! [[Example]]", contentmodel="wikitext")
```

Parse a page with specific properties:
```
wiki_page_parse(title="Example", prop="text|categories|links|templates")
```

Parse a section of a page:
```
wiki_page_parse(title="Large Article", section="2")
```

Parse with mobile formatting:
```
wiki_page_parse(title="Main Page", mobileformat=true, prop="text")
```

Parse a revision by ID:
```
wiki_page_parse(oldid=12345, prop="text|parsewarnings")
```

The tool returns comprehensive parsed content including HTML output, metadata, links, categories, templates, and any requested analysis information formatted in a readable structure.
8 changes: 8 additions & 0 deletions mediawiki_api_mcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ async def get_page_extracts(self, **kwargs: Any) -> dict[str, Any]:
"""Get page extracts using the TextExtracts API."""
return await self.page_client.get_page_extracts(**kwargs)

async def parse_page(self, **kwargs: Any) -> dict[str, Any]:
"""Parse content and return parser output using the MediaWiki Parse API."""
return await self.page_client.parse_page(**kwargs)

async def move_page(self, **kwargs: Any) -> dict[str, Any]:
"""Move a MediaWiki page."""
return await self.page_client.move_page(**kwargs)
Expand All @@ -71,6 +75,10 @@ async def undelete_page(self, **kwargs: Any) -> dict[str, Any]:
"""Undelete (restore) the revisions of a deleted MediaWiki page."""
return await self.page_client.undelete_page(**kwargs)

async def compare_pages(self, **kwargs: Any) -> dict[str, Any]:
"""Get the difference between two pages using the MediaWiki Compare API."""
return await self.page_client.compare_pages(**kwargs)

# Search operations delegation
async def search_pages(self, **kwargs: Any) -> dict[str, Any]:
"""Perform a full-text search using MediaWiki's search API."""
Expand Down
Loading