Skip to main content
Glama

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
NameRequiredDescriptionDefault
project_idNoProject ID or complete URL-encoded path to project
fromYesThe base branch or commit SHA to compare from
toYesThe target branch or commit SHA to compare to
straightNoComparison method: false for '...' (default), true for '--'
excluded_file_patternsNoArray 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

  • 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"]' ), });
  • 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(), });
  • 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 },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zereight/gitlab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server