Skip to main content
Glama

get_commit

Retrieve detailed commit information from GitLab projects by providing project ID and commit SHA to access changes, author details, and timestamps.

Instructions

取得 Commit 詳細資訊

Args: project_id: 專案 ID 或路徑 sha: Commit SHA(完整或縮短)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
shaYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool registration and handler function for 'get_commit'.
    @mcp.tool()
    def get_commit(project_id: int | str, sha: str) -> str:
        """取得 Commit 詳細資訊
    
        Args:
            project_id: 專案 ID 或路徑
            sha: Commit SHA(完整或縮短)
        """
        try:
            client = get_client()
            c = client.get_commit(project_id, sha)
    
            stats = c.get("stats", {})
            return f"""Commit {c.get('id', 'N/A')}
    標題: {c.get('title', 'N/A')}
    訊息: {c.get('message', 'N/A')}
    作者: {c.get('author_name', 'N/A')} <{c.get('author_email', '')}>
    時間: {c.get('authored_date', 'N/A')}
    新增: {stats.get('additions', 0)} 行 | 刪除: {stats.get('deletions', 0)} 行 | 變更檔案: {stats.get('total', 0)}
    網址: {c.get('web_url', '')}"""
        except GitLabAPIError as e:
            return f"取得 commit 失敗: {str(e)}"
    
    
    @mcp.tool()
    def compare_branches(project_id: int | str, from_ref: str, to_ref: str) -> str:
        """比較兩個分支或 commit 的差異
    
        Args:
  • The Gitlab client method that makes the API request to fetch commit details.
    def get_commit(self, project_id: int | str, sha: str) -> dict:
        """GET /projects/:id/repository/commits/:sha"""
        pid = self._resolve_project_id(project_id)
        return self._get_json(f"/projects/{pid}/repository/commits/{sha}")
Behavior2/5

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

No annotations are provided, so the description carries full burden. It only states what the tool does ('取得 Commit 詳細資訊') without disclosing behavioral traits like whether it's read-only, what authentication is needed, rate limits, error conditions, or what format/details the commit information includes. For a tool with no annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the main purpose is stated first, followed by parameter clarifications. There's no wasted text. However, the structure could be slightly improved by separating the purpose from parameter explanations more clearly.

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

Completeness3/5

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

Given that there's an output schema (which handles return values), no annotations, and low schema coverage (0%), the description is minimally complete. It states the purpose and clarifies parameters briefly, but lacks behavioral context and usage guidance. For a simple read operation with output schema, it's adequate but has clear gaps.

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?

Schema description coverage is 0%, so the schema provides no parameter descriptions. The description adds minimal semantics: it clarifies that 'project_id' can be an ID or path, and 'sha' can be full or shortened. However, it doesn't explain what a 'project_id' or 'sha' represents in context, or provide examples. With 0% schema coverage, the description partially compensates but not fully.

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 purpose: '取得 Commit 詳細資訊' (Get commit details/information). It specifies the verb ('取得' - get/retrieve) and resource ('Commit 詳細資訊' - commit details). However, it doesn't explicitly differentiate from sibling tools like 'list_commits' or 'get_merge_request_commits', which reduces it from a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'list_commits' (for listing multiple commits) or 'get_merge_request_commits' (for commits within a merge request). The agent must infer usage from the tool name alone.

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

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