Skip to content

Conversation

yumeminami
Copy link
Owner

@yumeminami yumeminami commented Aug 13, 2025

Summary

Implements comprehensive merge request/pull request detail functionality as requested in #19

This PR adds two new MCP tools that enable detailed analysis of merge requests and pull requests across both GitLab and GitHub platforms.

Changes Made

New MCP Tools Added

  • get_merge_request_diff() - Retrieves file changes and diff content with configurable options
  • get_merge_request_commits() - Gets commit history with comprehensive metadata

Technical Implementation

  • Base Infrastructure: Extended PlatformAdapter with abstract methods for new functionality
  • Service Layer: Added unified methods in PlatformService with standardized response format
  • GitLab Support: Implemented using mr.changes() and mr.commits() APIs with proper error handling
  • GitHub Support: Implemented using pr.get_files() and pr.get_commits() APIs with rich statistics
  • MCP Integration: Registered new tools in server with comprehensive documentation and parameter validation

Key Features

  • 🌍 Cross-platform consistency - Identical response structure for GitLab and GitHub
  • 📊 Rich metadata - File statistics, commit details, line counts, and URLs
  • 🔧 Configurable options - Control diff content inclusion and response format
  • 🛡️ Robust error handling - Meaningful error messages and graceful degradation
  • 🌏 Unicode support - Handles international content (tested with Chinese characters)
  • 📁 Binary detection - Proper handling of binary files in diffs

Usage Examples

Get Diff Information

# Get file changes without diff content (fast)
diff_info = await get_merge_request_diff("github", "owner/repo", "123", include_diff=False)

# Get complete diff with content
full_diff = await get_merge_request_diff("gitlab", "group/project", "456", 
                                        format="json", include_diff=True)

Get Commit History

# Get all commits in MR/PR
commits = await get_merge_request_commits("github", "owner/repo", "123")
print(f"Total commits: {commits['total_commits']}")
for commit in commits['commits']:
    print(f"{commit['sha'][:8]} - {commit['message']}")

Quality Assurance

  • Code Quality: All linting (ruff), formatting, and type checking (mypy) passed
  • Security: Bandit security scanning passed
  • Pre-commit Hooks: All hooks passed successfully
  • Backward Compatibility: No breaking changes to existing functionality
  • Documentation: Comprehensive docstrings and inline documentation

Production Readiness

This implementation is production-ready and handles:

  • Large merge requests (17+ files, 30+ commits tested)
  • Complex merge scenarios and merge commits
  • International content and Unicode characters
  • Binary file detection and proper handling
  • API rate limiting and network error scenarios
  • Cross-platform consistency and reliability

Closes #19

Add two new MCP tools to support comprehensive merge request/pull request analysis:

- get_merge_request_diff(): Retrieves file changes and diff content with options
- get_merge_request_commits(): Gets commit history with full metadata

Features:
- Cross-platform support for both GitLab and GitHub
- Standardized response format across platforms
- Optional diff content inclusion with size controls
- Rich commit metadata including statistics and URLs
- Proper error handling and binary file detection
- Unicode content support (tested with Chinese characters)

Implementation:
- Extended PlatformAdapter base class with abstract methods
- Added service layer methods in PlatformService
- Implemented platform-specific adapters for GitLab and GitHub
- Registered new MCP tools in server with comprehensive documentation

Testing:
- Verified on real GitLab MR (17 files, 31 commits, merged)
- Verified on real GitHub PR (2 files, 2 commits, open)
- All functionality tested and working across both platforms

Closes #19

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@yumeminami yumeminami merged commit 7fa2852 into main Aug 13, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support get mr/pr detail
1 participant