Skip to main content
Glama

get_repository

Retrieve repository details from Bitbucket including name, description, clone URLs, and metadata using the repository slug.

Instructions

Get information about a Bitbucket repository.

Args:
    repo_slug: Repository slug (e.g., "anzsic_classifier")

Returns:
    Repository info including name, description, clone URLs, and metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYes

Implementation Reference

  • MCP tool handler for 'get_repository'. Fetches repository data via BitbucketClient, handles not found cases, formats output using RepositoryDetail Pydantic model.
    @mcp.tool()
    @handle_bitbucket_error
    @formatted
    def get_repository(repo_slug: str) -> dict:
        """Get information about a Bitbucket repository.
    
        Args:
            repo_slug: Repository slug (e.g., "anzsic_classifier")
    
        Returns:
            Repository info including name, description, clone URLs, and metadata
        """
        client = get_client()
        result = client.get_repository(repo_slug)
        if not result:
            return not_found_response("Repository", repo_slug)
    
        return RepositoryDetail.from_api(result, client.extract_clone_urls(result)).model_dump()
  • Core helper method in BitbucketClient that performs the actual Bitbucket API GET request to retrieve repository details.
    def get_repository(self, repo_slug: str) -> Optional[dict[str, Any]]:
        """Get repository information.
    
        Args:
            repo_slug: Repository slug
    
        Returns:
            Repository info or None if not found
        """
        return self._request("GET", self._repo_path(repo_slug))
  • Pydantic model defining the output schema for get_repository tool response. Includes field validators for timestamp truncation and from_api factory method to parse Bitbucket API response.
    class RepositoryDetail(BaseModel):
        """Repository info for get responses."""
    
        name: str
        full_name: str
        description: str = ""
        private: bool = True
        created: Optional[str] = None
        updated: Optional[str] = None
        mainbranch: Optional[str] = None
        clone_urls: dict[str, str] = {}
        project: Optional[str] = None
    
        @field_validator("created", "updated", mode="before")
        @classmethod
        def truncate_ts(cls, v: Any) -> Optional[str]:
            return truncate_timestamp(v)
    
        @classmethod
        def from_api(cls, data: dict, clone_urls: dict[str, str]) -> "RepositoryDetail":
            return cls(
                name=data.get("name", ""),
                full_name=data.get("full_name", ""),
                description=data.get("description", ""),
                private=data.get("is_private", True),
                created=data.get("created_on"),
                updated=data.get("updated_on"),
                mainbranch=(data.get("mainbranch") or {}).get("name"),
                clone_urls=clone_urls,
                project=(data.get("project") or {}).get("key"),
            )

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