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 },
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. It states the tool retrieves diffs but doesn't mention critical details like whether it's a read-only operation, potential rate limits, authentication requirements, or the format of the returned data. For a tool with 5 parameters and no output schema, this is a significant gap in transparency.

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, clear sentence that efficiently conveys the core purpose without unnecessary words. It's front-loaded with the essential information, making it easy to parse quickly. Every part of the sentence earns its place by specifying the action, resource, and context.

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?

Given the tool's complexity (5 parameters, no annotations, no output schema), the description is insufficiently complete. It doesn't address behavioral aspects like safety, performance, or data format, nor does it provide usage guidance relative to siblings. For a diff tool that likely returns structured data, more context is needed to help an AI agent use it effectively.

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?

The input schema has 100% description coverage, so the schema already documents all parameters thoroughly. The description doesn't add any additional meaning or context beyond what's in the schema, such as explaining the relationship between 'from' and 'to' or clarifying the 'straight' parameter's impact. This meets the baseline of 3 when schema coverage is high.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get the changes/diffs between two branches or commits in a GitLab project.' It specifies the verb ('Get'), resource ('changes/diffs'), and context ('GitLab project'), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools like 'get_commit_diff' or 'get_merge_request_diffs,' which prevents a score of 5.

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. It doesn't mention sibling tools like 'get_commit_diff' or 'get_merge_request_diffs,' nor does it specify prerequisites or exclusions. This lack of contextual usage information limits its effectiveness for an AI agent.

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

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