get_branch_diffs
Compare changes between GitLab branches or commits to review code differences and identify modifications in a project.
Instructions
Get the changes/diffs between two branches or commits in a GitLab project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Project ID or complete URL-encoded path to project | |
| from | Yes | The base branch or commit SHA to compare from | |
| to | Yes | The target branch or commit SHA to compare to | |
| straight | No | Comparison method: false for '...' (default), true for '--' | |
| excluded_file_patterns | No | Array of regex patterns to exclude files from the diff results. Each pattern is a JavaScript-compatible regular expression that matches file paths to ignore. Examples: ["^test/mocks/", "\.spec\.ts$", "package-lock\.json"] |
Implementation Reference
- schemas.ts:1122-1134 (schema)Zod input schema for the 'get_branch_diffs' MCP tool. Defines required parameters: project_id (inherited), from (base branch/commit), to (target branch/commit), optional straight (comparison type), and excluded_file_patterns (regex filters for files). Maps to GitLab API /projects/{project_id}/repository/compare.export const GetBranchDiffsSchema = ProjectParamsSchema.extend({ from: z.string().describe("The base branch or commit SHA to compare from"), to: z.string().describe("The target branch or commit SHA to compare to"), straight: z.boolean() .optional() .describe("Comparison method: false for '...' (default), true for '--'"), excluded_file_patterns: z .array(z.string()) .optional() .describe( 'Array of regex patterns to exclude files from the diff results. Each pattern is a JavaScript-compatible regular expression that matches file paths to ignore. Examples: ["^test/mocks/", "\\.spec\\.ts$", "package-lock\\.json"]' ), });
- schemas.ts:636-651 (schema)Zod output schema for GitLab branch compare API response, used by get_branch_diffs tool. Includes optional commit summary, array of commits, array of diffs (using GitLabDiffSchema), and flags for timeout/same ref.export const GitLabCompareResultSchema = z.object({ commit: z .object({ id: z.string().optional(), short_id: z.string().optional(), title: z.string().optional(), author_name: z.string().optional(), author_email: z.string().optional(), created_at: z.string().optional(), }) .optional(), commits: z.array(GitLabCommitSchema), diffs: z.array(GitLabDiffSchema), compare_timeout: z.boolean().optional(), compare_same_ref: z.boolean().optional(), });
- test/readonly-mcp-tests.ts:80-80 (registration)Tool listed in MCP readonly tools test suite under merge_request category. Used for automated testing of the get_branch_diffs tool implementation.{ name: 'get_branch_diffs', category: 'merge_request', required: true },