Skip to main content
Glama

gitlab_get_commit

Retrieve detailed information about a single Git commit, including author, message, and file changes. Use this tool to analyze specific changes during code reviews or debugging. Requires the commit SHA for precise results.

Instructions

Get single commit details Returns: Complete commit information with stats Use when: Examining specific commit Required: Commit SHA (short or full)

Example response: { "id": "e83c5163316f89bfbde7d9ab23ca2e25604af290", "title": "Fix critical bug", "message": "Fix critical bug\n\nDetailed explanation...", "author": {"name": "John Doe", "email": "john@example.com"}, "parent_ids": ["ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"], "stats": { "additions": 15, "deletions": 3, "total": 18 } }

Related tools:

  • gitlab_get_commit_diff: View changes

  • gitlab_cherry_pick_commit: Apply to another branch

  • gitlab_list_commits: Browse history

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commit_shaYesGit commit SHA Type: string Format: Abbreviated (min 7 chars) or full 40-character SHA Required: Yes Examples: - 'a1b2c3d' (short form - minimum 7 characters) - 'a1b2c3d4e5f6' (medium form) - 'e83c5163316f89bfbde7d9ab23ca2e25604af290' (full SHA) How to find: git log, GitLab UI, or MR/commit pages
include_statsNoInclude statistics Type: boolean Default: false Options: - true: Include additions, deletions, total changes - false: Basic information only Use case: true for code review, false for quick browsing
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 main handler function that implements the core logic for the gitlab_get_commit tool. It resolves the project ID (auto-detecting from git if needed), extracts the commit SHA and optional stats flag, then calls the GitLabClient to fetch the commit details.
    def handle_get_commit(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle getting single commit""" project_id = require_project_id(client, arguments) commit_sha = require_argument(arguments, "commit_sha") include_stats = get_argument(arguments, "include_stats", False) return client.get_commit(project_id, commit_sha, include_stats)
  • Registration of the gitlab_get_commit handler in the TOOL_HANDLERS dictionary, which maps tool names to their handler functions. This dict is used by server.py to dispatch tool calls.
    TOOL_GET_COMMIT: handle_get_commit, TOOL_GET_COMMIT_DIFF: handle_get_commit_diff,
  • MCP tool schema definition including input validation and description, registered in the server's list_tools() method.
    types.Tool( name="gitlab_get_commit", description=desc.DESC_GET_COMMIT, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "commit_sha": {"type": "string", "description": desc.DESC_COMMIT_SHA}, "include_stats": {"type": "boolean", "description": desc.DESC_INCLUDE_STATS, "default": False} }, "required": ["commit_sha"] } ),
  • Explicit registration of the gitlab_get_commit tool in the MCP server's list_tools() handler, which exposes it to MCP clients.
    types.Tool( name="gitlab_get_commit", description=desc.DESC_GET_COMMIT, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "commit_sha": {"type": "string", "description": desc.DESC_COMMIT_SHA}, "include_stats": {"type": "boolean", "description": desc.DESC_INCLUDE_STATS, "default": False} }, "required": ["commit_sha"] }
  • Constant definition of the tool name 'gitlab_get_commit', used consistently across handler registration, schemas, and server code.
    TOOL_GET_COMMIT = "gitlab_get_commit"

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