Skip to main content
Glama

gitlab_get_commit

Retrieve detailed information about a specific GitLab commit including author, message, and change statistics using the commit SHA identifier.

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
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_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

Implementation Reference

  • The primary handler function that implements the core logic for the gitlab_get_commit tool. Extracts project_id (auto-detects from git if possible), commit_sha, and optional stats flag, then calls the GitLabClient.get_commit method.
    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)
  • Pydantic/JSON schema definition for the gitlab_get_commit tool input parameters, including descriptions from tool_descriptions.py.
        name=TOOL_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"]
        }
    ),
  • Registration of the handle_get_commit function in the central TOOL_HANDLERS dictionary used by the MCP server to route tool calls.
    TOOL_GET_COMMIT: handle_get_commit,
  • Constant definition of the tool name 'gitlab_get_commit' used consistently across the codebase for registration and references.
    TOOL_GET_COMMIT = "gitlab_get_commit"
  • Detailed description text for the gitlab_get_commit tool, used in schema definitions and documentation.
    DESC_GET_COMMIT = """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"""
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that the tool returns 'Complete commit information with stats' and includes an example response showing the structure and content. However, it doesn't mention error conditions, rate limits, or authentication requirements, which are typical behavioral traits for API tools.

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 front-loaded with key information (purpose, returns, usage, required parameter). Each section ('Returns:', 'Use when:', 'Required:', 'Example response:', 'Related tools:') adds value without redundancy. The example response is illustrative but not overly verbose.

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 the tool's moderate complexity (3 parameters, no output schema, no annotations), the description provides good context: purpose, usage guidelines, example response, and related tools. It covers most needs for a read operation, though it lacks details on error handling or authentication, which would be helpful for completeness.

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%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema, only noting 'Required: Commit SHA (short or full)' which is already in the schema. No additional semantic context is provided for parameters like 'project_id' or 'include_stats'.

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

Purpose5/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 with a specific verb ('Get') and resource ('single commit details'), distinguishing it from siblings like 'gitlab_list_commits' (browse history) and 'gitlab_get_commit_diff' (view changes). The opening line 'Get single commit details' is precise and unambiguous.

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

Usage Guidelines5/5

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

The description explicitly states 'Use when: Examining specific commit' and provides a 'Related tools' section that names alternatives (e.g., 'gitlab_list_commits: Browse history'), giving clear guidance on when to use this tool versus others. This helps the agent select the right tool for the task.

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