Skip to main content
Glama

gitlab_get_commit_diff

Retrieve detailed file changes for a specific commit to support code review and change analysis. Shows added/removed lines and file modifications.

Instructions

Get commit diff/changes Returns: Detailed diff of all changed files Use when: Code review, understanding changes Shows: Added/removed lines, file modifications

Example response: [{ "old_path": "src/main.py", "new_path": "src/main.py", "diff": "@@ -10,3 +10,5 @@\n def main():\n- print('Hello')\n+ print('Hello, World!')\n+ return 0", "new_file": false, "deleted_file": false }]

Related tools:

  • gitlab_get_commit: Commit metadata

  • gitlab_compare_refs: Compare branches

  • gitlab_smart_diff: Advanced diff options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoProject 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
commit_shaYesCommit SHA

Implementation Reference

  • Handler function that implements the gitlab_get_commit_diff tool. Extracts project_id and commit_sha from arguments, then calls client.get_commit_diff() to retrieve the diff.
    def handle_get_commit_diff(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]:
        """Handle getting commit diff"""
        project_id = require_project_id(client, arguments)
        commit_sha = require_argument(arguments, "commit_sha")
        
        return client.get_commit_diff(project_id, commit_sha)
  • Pydantic/MCP tool schema definition including inputSchema with project_id (optional) and required commit_sha.
    types.Tool(
        name=TOOL_GET_COMMIT_DIFF,
        description=desc.DESC_GET_COMMIT_DIFF,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID},
                "commit_sha": {"type": "string", "description": "Commit SHA"}
            },
            "required": ["commit_sha"]
        }
    ),
  • Registration of the tool name to its handler function in the TOOL_HANDLERS dictionary.
    TOOL_GET_COMMIT_DIFF: handle_get_commit_diff,
  • Constant definition for the tool name used across the codebase.
    TOOL_GET_COMMIT_DIFF = "gitlab_get_commit_diff"
Behavior3/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 describes what the tool returns ('Detailed diff of all changed files') and shows an example response format, which is helpful. However, it doesn't mention important behavioral aspects like whether this is a read-only operation, potential rate limits, authentication requirements, or error conditions. The example response adds value but doesn't fully compensate for the lack of annotations.

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 well-structured and efficiently organized with clear sections: purpose statement, returns, use cases, shows, example response, and related tools. Every sentence earns its place, and the information is front-loaded with the most important details first. The example response is appropriately included to illustrate the output format.

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

Completeness4/5

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

Given that there's no output schema, the description provides a good example response that shows the structure of the returned data. The tool has 2 parameters with 100% schema coverage, and the description adds context about when to use it and what it returns. However, for a tool with no annotations, it could provide more behavioral context about safety, permissions, or limitations to be fully complete.

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 schema description coverage is 100%, meaning both parameters are well-documented in the schema itself. The description doesn't add any additional parameter information beyond what's already in the schema. According to the scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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 commit diff/changes' followed by 'Returns: Detailed diff of all changed files'. This specifies both the action (get) and resource (commit diff/changes), and the 'Returns' statement clarifies the output. However, it doesn't explicitly differentiate from sibling tools like 'gitlab_smart_diff' beyond listing it as related.

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

Usage Guidelines4/5

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

The description includes a 'Use when:' section that provides clear context: 'Code review, understanding changes'. This gives practical guidance on when this tool is appropriate. However, it doesn't explicitly state when NOT to use it or provide direct comparisons with alternatives like 'gitlab_smart_diff' beyond listing it as related.

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

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