Skip to main content
Glama

gitlab_get_commit_diff

Extract detailed commit differences for code review, showing added/removed lines and file modifications. Integrates with MCP GitLab Server to simplify change analysis and improve understanding of GitLab project updates.

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
commit_shaYesCommit SHA
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

Implementation Reference

  • The handler function that implements the core logic for the gitlab_get_commit_diff tool. It extracts the project_id (auto-detecting if not provided) and commit_sha parameters, then delegates to the GitLabClient to fetch the commit 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)
  • The input schema definition for the gitlab_get_commit_diff tool, defining the expected parameters: optional project_id (string) and required commit_sha (string).
    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 handle_get_commit_diff handler function in the TOOL_HANDLERS dictionary, which maps tool names to their handler functions. This dictionary is used by the MCP server to dispatch tool calls.
    TOOL_GET_COMMIT: handle_get_commit, TOOL_GET_COMMIT_DIFF: handle_get_commit_diff, TOOL_GET_MR_APPROVALS: handle_get_merge_request_approvals,
  • Tool registration and schema definition in the MCP server's list_tools() handler, exposing gitlab_get_commit_diff to MCP clients.
    types.Tool( name="gitlab_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"] }
  • Constant definition for the tool name TOOL_GET_COMMIT_DIFF = "gitlab_get_commit_diff", used throughout the codebase for consistent tool naming.
    TOOL_GET_COMMIT = "gitlab_get_commit" TOOL_GET_COMMIT_DIFF = "gitlab_get_commit_diff"

Other Tools

Related 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