Skip to main content
Glama

list_commits

Retrieve commit history from a Bitbucket repository with optional filtering by branch, file path, or result limit to track code changes.

Instructions

List commits in a repository.

Args:
    repo_slug: Repository slug
    branch: Filter by branch name (optional)
    path: Filter by file path - only commits that modified this path (optional)
    limit: Maximum number of results (default: 20)

Returns:
    List of commits with hash, message, author, and date

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYes
branchNo
pathNo
limitNo

Implementation Reference

  • MCP tool handler: lists commits via BitbucketClient.list_commits and formats output using CommitSummary pydantic models.
    @mcp.tool()
    @handle_bitbucket_error
    @formatted
    def list_commits(
        repo_slug: str,
        branch: Optional[str] = None,
        path: Optional[str] = None,
        limit: int = 20,
    ) -> dict:
        """List commits in a repository.
    
        Args:
            repo_slug: Repository slug
            branch: Filter by branch name (optional)
            path: Filter by file path - only commits that modified this path (optional)
            limit: Maximum number of results (default: 20)
    
        Returns:
            List of commits with hash, message, author, and date
        """
        client = get_client()
        commits = client.list_commits(repo_slug, branch=branch, path=path, limit=validate_limit(limit))
        return {
            "commits": [CommitSummary.from_api(c).model_dump() for c in commits],
        }
  • BitbucketClient helper method implementing the API call to list commits using _paginated_list on the commits endpoint.
    def list_commits(
        self,
        repo_slug: str,
        branch: Optional[str] = None,
        path: Optional[str] = None,
        limit: int = 20,
    ) -> list[dict[str, Any]]:
        """List commits in a repository.
    
        Args:
            repo_slug: Repository slug
            branch: Filter by branch (optional)
            path: Filter by file path (optional)
            limit: Maximum results to return
    
        Returns:
            List of commit info dicts
        """
        return self._paginated_list(
            self._repo_path(repo_slug, "commits"),
            limit=limit,
            include=branch,
            path=path,
        )
  • Pydantic model CommitSummary used to format and validate commit data in the list_commits tool response.
    class CommitSummary(BaseModel):
        """Commit info for list responses."""
    
        hash: str
        message: str
        author: str = ""
        date: Optional[str] = None
    
        @field_validator("hash", mode="before")
        @classmethod
        def truncate_hash(cls, v: Any) -> str:
            return (v or "")[:12]
    
        @field_validator("message", mode="before")
        @classmethod
        def first_line(cls, v: Any) -> str:
            return (v or "").split("\n")[0]
    
        @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) -> "CommitSummary":
            return cls(
                hash=data.get("hash", ""),
                message=data.get("message"),
                author=(data.get("author") or {}).get("raw", ""),
                date=data.get("date"),
            )
  • src/server.py:748-748 (registration)
    @mcp.tool() decorator registers the list_commits function as an MCP tool.
    @mcp.tool()

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