Skip to content

Conversation

@diggy
Copy link
Contributor

@diggy diggy commented Jul 2, 2025

Implement wiki_page_compare MCP tool according to MediaWiki API:Compare specification

f28f768  (Base revision)
29a2d32  Add compare_pages method to MediaWikiPageClient for API:Compare functionality
9878bb6  Create handler for wiki_page_compare tool
bd2f7fa  Create server tool registration for wiki_page_compare
9313114  Add handle_compare_pages to handlers __init__.py
eef3452  Add wiki_page_compare tool registration to server.py
ed1ba6e  Add wiki_page_compare tool registration call in server.py
HEAD     Add compare_pages delegation method to MediaWikiClient

codemcp-id: 68-feat-implement-wiki-page-compare-tool-for-mediawik


I've successfully implemented the wiki_page_compare MCP tool according to the MediaWiki API:Compare specification. Here's a summary of what I've implemented:

✅ Implementation Complete

The wiki_page_compare tool has been fully implemented with the following components:

1. Client Method (client_modules/client_page.py)

  • Added compare_pages() method to MediaWikiPageClient
  • Handles all MediaWiki Compare API parameters exactly as specified
  • Converts lists to pipe-separated strings
  • Omits False boolean parameters
  • Supports templated slot parameters via **kwargs

2. Handler (handlers/wiki_page_compare.py)

  • Processes MCP tool calls and validates parameters
  • Formats comparison results into readable text output
  • Handles errors gracefully with formatted messages
  • Supports all Compare API features including diff HTML, metadata, and slot-specific diffs

3. Server Tool (server_tools/wiki_page_compare.py)

  • Registers the tool with FastMCP
  • Defines all parameters with proper types and documentation
  • Includes support for templated main slot parameters
  • Follows exact MediaWiki API parameter naming

4. Integration

  • Updated handlers/__init__.py to export the handler
  • Added tool registration to server.py
  • Added delegation method to main MediaWikiClient class

🎯 Key Features Implemented

  • ✅ From/To Specification: Support for title, ID, revision, and relative comparisons
  • ✅ Slot Content Override: Full support for fromslots/toslots with templated parameters
  • ✅ Pre-save Transform: frompst and topst boolean handling
  • ✅ Output Control: Configurable prop, slots, and difftype parameters
  • ✅ Exact API Compliance: All parameter names match MediaWiki spec exactly
  • ✅ Error Handling: Comprehensive validation and user-friendly error messages

The tool is now ready to use and will appear as wiki_page_compare in MCP client interfaces, allowing LLMs to compare pages, revisions, and custom content through the MediaWiki Compare API.


I have successfully created comprehensive tests and documentation for the wiki_page_compare MCP tool. Here's what was accomplished:

Created Test Suite (tests/test_wiki_page_compare.py)

  • 11 comprehensive test cases covering all major functionality
  • Tests for page comparison by title, revision ID, and relative comparisons
  • Error handling tests for missing parameters and API failures
  • Tests for templated slot parameters and pipe-separated values
  • Tests for different diff output formats (table, unified, inline)
  • All tests follow existing project patterns and pass successfully

Created Documentation (docs/tools/wiki_page_compare.md)

  • Complete parameter reference with detailed descriptions
  • Example usage scenarios for common comparison tasks
  • Clear explanation of templated slot parameters and their naming conventions
  • Use case descriptions for practical applications
  • Important notes about MediaWiki API behavior and parameter requirements

Key Features Covered

Core Functionality:

  • Compare pages by title, ID, or revision
  • Relative comparisons (current, next, previous)
  • Custom content injection via templated slot parameters
  • Multiple diff output formats
  • Comprehensive metadata inclusion

Error Handling:

  • Validation of required parameters
  • Graceful handling of API errors
  • Clear error messages for troubleshooting

Output Formatting:

  • HTML diff content with proper structure
  • Metadata display (timestamps, users, comments)
  • Slot-specific diff breakdowns
  • Clear indication when no differences exist

All tests pass and the implementation strictly follows the MediaWiki API specification without using any deprecated parameters.

Implement wiki_page_compare MCP tool according to MediaWiki API:Compare specification

```git-revs
f28f768  (Base revision)
29a2d32  Add compare_pages method to MediaWikiPageClient for API:Compare functionality
9878bb6  Create handler for wiki_page_compare tool
bd2f7fa  Create server tool registration for wiki_page_compare
9313114  Add handle_compare_pages to handlers __init__.py
eef3452  Add wiki_page_compare tool registration to server.py
ed1ba6e  Add wiki_page_compare tool registration call in server.py
HEAD     Add compare_pages delegation method to MediaWikiClient
```

codemcp-id: 68-feat-implement-wiki-page-compare-tool-for-mediawik
I need to write tests and documentation for the wiki_page_compare MCP tool that was recently implemented according to the API:Compare specification. Please help me explore the existing implementation and then create comprehensive tests and documentation.

```git-revs
4c20a98  (Base revision)
7d708ac  Create comprehensive test suite for wiki_page_compare tool
3930e85  Fix duplicate slots parameter in test
HEAD     Add comprehensive documentation for wiki_page_compare tool
```

codemcp-id: 69-add-tests-and-documentation-for-wiki-page-compare-
@diggy diggy merged commit a405641 into develop Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants