Skip to main content
Glama

list_environments

Retrieve deployment environments for a Bitbucket repository to manage test, staging, and production configurations.

Instructions

List deployment environments for a repository.

Args:
    repo_slug: Repository slug
    limit: Maximum number of results (default: 20)

Returns:
    List of environments (e.g., test, staging, production)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYes
limitNo

Implementation Reference

  • MCP tool handler function that lists deployment environments by calling the Bitbucket client and formatting the response using EnvironmentSummary models.
    @mcp.tool()
    @handle_bitbucket_error
    @formatted
    def list_environments(repo_slug: str, limit: int = 20) -> dict:
        """List deployment environments for a repository.
    
        Args:
            repo_slug: Repository slug
            limit: Maximum number of results (default: 20)
    
        Returns:
            List of environments (e.g., test, staging, production)
        """
        client = get_client()
        environments = client.list_environments(repo_slug, limit=validate_limit(limit))
        return {
            "environments": [EnvironmentSummary.from_api(e).model_dump() for e in environments],
        }
  • BitbucketClient method that performs the API call to list deployment environments using paginated list helper.
    def list_environments(
        self,
        repo_slug: str,
        limit: int = 20,
    ) -> list[dict[str, Any]]:
        """List deployment environments.
    
        Args:
            repo_slug: Repository slug
            limit: Maximum results to return
    
        Returns:
            List of environment info dicts
        """
        return self._paginated_list(
            self._repo_path(repo_slug, "environments"),
            limit=limit,
        )
  • Pydantic model used to format and validate environment data in the tool response.
    class EnvironmentSummary(BaseModel):
        """Environment info for list responses."""
    
        uuid: str
        name: str
        environment_type: Optional[str] = None
        rank: Optional[int] = None
    
        @classmethod
        def from_api(cls, data: dict) -> "EnvironmentSummary":
            return cls(
                uuid=data.get("uuid", ""),
                name=data.get("name", ""),
                environment_type=(data.get("environment_type") or {}).get("name"),
                rank=data.get("rank"),
            )
  • Decorators registering the list_environments function as an MCP tool with error handling and formatting.
    @mcp.tool()
    @handle_bitbucket_error
    @formatted

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