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"

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