gitlab_get_merge_request_changes
Retrieve complete file diffs for a GitLab merge request to review all code changes. Displays full file diffs with context for entire MR, including all commits. Use for detailed code review.
Instructions
Get detailed MR file changes Returns: Complete diffs for all files Use when: Reviewing code changes Shows: Full file diffs with context
Similar to commit diff but for entire MR Includes all commits in the MR
Related tools:
gitlab_get_merge_request: MR overview
gitlab_smart_diff: Customizable diffs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mr_iid | Yes | Merge request number (IID - Internal ID) Type: integer Format: Project-specific MR number (without !) Required: Yes Examples: - 456 (for MR !456) - 7890 (for MR !7890) How to find: Look at MR URL or title - URL: https://gitlab.com/group/project/-/merge_requests/456 → use 456 - Title: "Add new feature (!456)" → use 456 Note: This is NOT the global MR ID | |
| project_id | No | Project identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted |
Implementation Reference
- src/mcp_gitlab/tool_handlers.py:446-452 (handler)The primary handler function that implements the tool logic. It validates inputs, detects project if needed, and calls the underlying GitLabClient to fetch the merge request changes.def handle_get_merge_request_changes(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle getting merge request changes""" project_id = require_project_id(client, arguments) mr_iid = require_argument(arguments, "mr_iid") return client.get_merge_request_changes(project_id, mr_iid)
- Defines the tool's input schema, including parameters for project_id (optional, auto-detected) and required mr_iid, along with description.types.Tool( name=TOOL_GET_MR_CHANGES, description=desc.DESC_GET_MR_CHANGES, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "mr_iid": {"type": "integer", "description": desc.DESC_MR_IID} }, "required": ["mr_iid"] } ),
- src/mcp_gitlab/tool_handlers.py:1038-1038 (registration)Registers the handle_get_merge_request_changes function to the tool name TOOL_GET_MR_CHANGES in the TOOL_HANDLERS dictionary used by the MCP server.TOOL_GET_MR_CHANGES: handle_get_merge_request_changes,
- Imports the TOOL_GET_MR_CHANGES constant for use in the module.TOOL_GET_MR_APPROVALS, TOOL_GET_MR_DISCUSSIONS, TOOL_GET_MR_CHANGES,
- src/mcp_gitlab/constants.py:223-223 (helper)Defines the constant TOOL_GET_MR_CHANGES holding the exact tool name string used throughout the codebase.TOOL_GET_MR_CHANGES = "gitlab_get_merge_request_changes"