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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_slug | Yes | ||
| limit | No |
Implementation Reference
- src/server.py:1094-1112 (handler)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], }
- src/bitbucket_client.py:1095-1113 (helper)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, )
- src/models.py:487-502 (schema)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"), )
- src/server.py:1094-1096 (registration)Decorators registering the list_environments function as an MCP tool with error handling and formatting.@mcp.tool() @handle_bitbucket_error @formatted