get_pull_request
Retrieve pull request details including state, author, reviewers, and merge status from Bitbucket repositories to track development progress.
Instructions
Get information about a pull request.
Args:
repo_slug: Repository slug
pr_id: Pull request ID
Returns:
PR info including state, author, reviewers, and merge status
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_slug | Yes | ||
| pr_id | Yes |
Implementation Reference
- src/server.py:251-270 (handler)MCP tool handler function for 'get_pull_request'. Fetches PR details via BitbucketClient and formats output using PullRequestDetail model.@mcp.tool() @handle_bitbucket_error @formatted def get_pull_request(repo_slug: str, pr_id: int) -> dict: """Get information about a pull request. Args: repo_slug: Repository slug pr_id: Pull request ID Returns: PR info including state, author, reviewers, and merge status """ client = get_client() result = client.get_pull_request(repo_slug, pr_id) if not result: return not_found_response("PR", f"#{pr_id}") return PullRequestDetail.from_api(result, client.extract_pr_url(result)).model_dump()
- src/bitbucket_client.py:432-448 (helper)BitbucketClient helper method that makes the actual Bitbucket API request to retrieve pull request details.def get_pull_request( self, repo_slug: str, pr_id: int ) -> Optional[dict[str, Any]]: """Get pull request by ID. Args: repo_slug: Repository slug pr_id: Pull request ID Returns: PR info or None if not found """ return self._request( "GET", self._repo_path(repo_slug, "pullrequests", str(pr_id)), )
- src/models.py:115-152 (schema)Pydantic model PullRequestDetail used for output schema and formatting of the get_pull_request tool response.class PullRequestDetail(BaseModel): """PR info for get responses.""" id: int title: str description: str = "" state: str author: Optional[str] = None source_branch: Optional[str] = None destination_branch: Optional[str] = None created: Optional[str] = None updated: Optional[str] = None url: str = "" comment_count: int = 0 task_count: int = 0 @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, url: str = "") -> "PullRequestDetail": return cls( id=data.get("id", 0), title=data.get("title", ""), description=data.get("description", ""), state=data.get("state", ""), author=(data.get("author") or {}).get("display_name"), source_branch=(data.get("source") or {}).get("branch", {}).get("name"), destination_branch=(data.get("destination") or {}).get("branch", {}).get("name"), created=data.get("created_on"), updated=data.get("updated_on"), url=url, comment_count=data.get("comment_count", 0), task_count=data.get("task_count", 0), )