diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-05-28 15:27:57 +0200 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-05-28 15:27:57 +0200 |
| commit | 0b819edceb307ce2f8ba6d58b37a86329b7d6ec0 (patch) | |
| tree | f8bc71742a93cd3cb6baa55ce81d14ad42c42720 /servers/gitlab_glab/README.md | |
| parent | a56a1ea5fa18c28d2fc3d42bfa780c026ce9b52d (diff) | |
feat(gitlab_glab): add merge request diff functionality with large diff mitigation
- Add get_mr_diff method to GitLabServer class with support for all glab mr diff options
- Implement smart large diff handling that saves diffs > 100KB to temporary files
- Add comprehensive test coverage (7 new tests) achieving 95% coverage
- Support for MR ID/branch, color options, raw format, and repository selection
- Include proper error handling and logging
- Update README with usage examples and documentation
- Follow project coding standards with type hints and docstrings
Resolves large diff handling for LLM consumption while preserving full diff access.
Diffstat (limited to 'servers/gitlab_glab/README.md')
| -rw-r--r-- | servers/gitlab_glab/README.md | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/servers/gitlab_glab/README.md b/servers/gitlab_glab/README.md index 50926fb..a2bb677 100644 --- a/servers/gitlab_glab/README.md +++ b/servers/gitlab_glab/README.md @@ -6,6 +6,9 @@ This MCP server provides integration with GitLab through the GitLab CLI (`glab`) - Check if the GitLab CLI is available and accessible - Find GitLab projects by name and retrieve their IDs +- Search for GitLab issues with various filters +- Create new GitLab issues +- Get merge request diffs with automatic handling of large diffs - More features to be added in the future ## Prerequisites @@ -145,6 +148,37 @@ The function returns a dictionary containing: - `url`: The URL of the created issue - `error`: Error message if the operation failed +### get_mr_diff + +Get the diff for a merge request using `glab mr diff`. + +```python +result = use_mcp_tool( + server_name="gitlab_glab", + tool_name="get_mr_diff", + arguments={ + "working_directory": "/path/to/current/directory", + # Optional parameters + "mr_id": "123", # MR ID or branch name (if None, uses current branch) + "color": "never", # Use color in diff output: always, never, auto (default: never) + "raw": True, # Use raw diff format (default: False) + "repo": "group/project", # Project path with namespace + "max_size_kb": 100 # Maximum size in KB before saving to temp file (default: 100) + } +) +``` + +The function returns a dictionary containing: +- `diff`: The diff content (if small enough) +- `size_kb`: The size of the diff in KB +- `temp_file_path`: Path to temporary file if diff is too large (None otherwise) +- `diff_too_large`: Boolean indicating if diff was saved to temp file +- `max_size_kb`: The configured maximum size threshold +- `message`: Human-readable message about temp file creation (if applicable) +- `error`: Error message if the operation failed + +**Note on Large Diffs**: To prevent overwhelming LLMs with extremely large diffs, this tool automatically saves diffs larger than `max_size_kb` (default: 100KB) to a temporary file and returns the file path instead of the content. This allows you to process large merge request diffs without hitting token limits. + ## Working Directory Context All tools require a `working_directory` parameter that specifies the directory context in which the GitLab CLI commands should be executed. This ensures that commands are run in the same directory as the agent, maintaining proper context for repository operations. |
