Skip to main content
Glama
harshmaur

GitLab MCP Server

by harshmaur

get_branch_diffs

Compare changes between branches or commits in a GitLab project to identify code differences and review modifications.

Instructions

Get the changes/diffs between two branches or commits in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject 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

  • Input schema (GetBranchDiffsSchema) for the 'get_branch_diffs' tool, which defines parameters for comparing branches or commits in a GitLab project, including project_id (inherited), from, to, straight, and excluded_file_patterns.
    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\"]"
      ),
    });
  • Output schema (GitLabCompareResultSchema) likely used by the 'get_branch_diffs' tool, containing commits and diffs between branches.
    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(),
    });
  • Schema for individual diff entries (GitLabDiffSchema) used in branch comparison results for the 'get_branch_diffs' tool.
    export const GitLabDiffSchema = z.object({
      old_path: z.string(),
      new_path: z.string(),
      a_mode: z.string(),
      b_mode: z.string(),
      diff: z.string(),
      new_file: z.boolean(),
      renamed_file: z.boolean(),
      deleted_file: z.boolean(),
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions 'changes/diffs', it doesn't describe the output format (e.g., patch format, file list), pagination behavior, rate limits, authentication requirements, or error conditions. This leaves significant gaps for an agent to understand how to interpret results.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that immediately states the tool's purpose without any wasted words. It's appropriately sized and front-loaded with the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't address the behavioral aspects needed for proper usage (output format, error handling, etc.), leaving the agent with incomplete context despite the good parameter documentation in the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't clarify the relationship between 'from' and 'to', or provide examples of valid commit SHA formats). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get the changes/diffs') and resource ('between two branches or commits in a GitLab project'). It distinguishes itself from siblings like 'get_merge_request_diffs' by focusing on branch/commit comparisons rather than merge request diffs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_merge_request_diffs' or 'get_file_contents' for specific diff scenarios. It lacks any mention of prerequisites, typical use cases, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/harshmaur/gitlab-mcp'

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