Skip to main content
Glama

get_commit

Retrieve detailed commit information from Bitbucket repositories, including message, author, date, and parent commits, by providing repository slug and commit hash.

Instructions

Get detailed information about a specific commit.

Args:
    repo_slug: Repository slug
    commit: Commit hash (full or short)

Returns:
    Commit details including message, author, date, and parents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYes
commitYes

Implementation Reference

  • MCP tool handler for 'get_commit'. Fetches commit details via BitbucketClient and formats using CommitDetail model.
    @mcp.tool()
    @handle_bitbucket_error
    @formatted
    def get_commit(repo_slug: str, commit: str) -> dict:
        """Get detailed information about a specific commit.
    
        Args:
            repo_slug: Repository slug
            commit: Commit hash (full or short)
    
        Returns:
            Commit details including message, author, date, and parents
        """
        client = get_client()
        result = client.get_commit(repo_slug, commit)
        if not result:
            return not_found_response("Commit", commit)
    
        return CommitDetail.from_api(result).model_dump()
  • Pydantic schema/model for formatting commit details returned by the get_commit tool.
    class CommitDetail(BaseModel):
        """Commit info for get responses."""
    
        hash: str
        message: str = ""
        author_raw: Optional[str] = None
        author_user: Optional[str] = None
        date: Optional[str] = None
        parents: list[str] = []
    
        @field_validator("date", mode="before")
        @classmethod
        def truncate_ts(cls, v: Any) -> Optional[str]:
            return truncate_timestamp(v)
    
        @classmethod
        def from_api(cls, data: dict) -> "CommitDetail":
            author = data.get("author") or {}
            return cls(
                hash=data.get("hash", ""),
                message=data.get("message", ""),
                author_raw=author.get("raw"),
                author_user=(author.get("user") or {}).get("display_name"),
                date=data.get("date"),
                parents=[(p.get("hash") or "")[:12] for p in data.get("parents", [])],
            )
    
    
    # ==================== BRANCHES ====================
    
    
    class BranchSummary(BaseModel):
        """Branch info for list responses."""
    
        name: str
        commit: str
        message: str = ""
        date: Optional[str] = None
  • BitbucketClient helper method that performs the actual API request to retrieve commit information.
    def get_commit(
        self, repo_slug: str, commit: str
    ) -> Optional[dict[str, Any]]:
        """Get commit details.
    
        Args:
            repo_slug: Repository slug
            commit: Commit hash (full or short)
    
        Returns:
            Commit info or None if not found
        """
        return self._request("GET", self._repo_path(repo_slug, "commit", commit))

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/JaviMaligno/mcp-server-bitbucket'

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