Skip to main content
Glama

get_pr_diff

Retrieve the diff content for a specific pull request in Bitbucket to review code changes between branches.

Instructions

Get the diff of a pull request.

Args: repo_slug: Repository slug pr_id: Pull request ID Returns: Diff content as text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYes
pr_idYes

Implementation Reference

  • The main MCP tool handler for 'get_pr_diff'. Decorated with @mcp.tool() for registration, fetches the PR diff using the BitbucketClient, handles truncation for large diffs, and applies formatting and error handling.
    @mcp.tool() @handle_bitbucket_error @formatted def get_pr_diff(repo_slug: str, pr_id: int) -> dict: """Get the diff of a pull request. Args: repo_slug: Repository slug pr_id: Pull request ID Returns: Diff content as text """ client = get_client() diff = client.get_pr_diff(repo_slug, pr_id) if not diff: return {"error": f"PR #{pr_id} not found or has no diff"} # Truncate if too long max_length = 50000 truncated = len(diff) > max_length return { "pr_id": pr_id, "diff": diff[:max_length] if truncated else diff, "truncated": truncated, "total_length": len(diff), }
  • Helper method in BitbucketClient that performs the actual API request to retrieve the pull request diff from Bitbucket's /pullrequests/{pr_id}/diff endpoint.
    def get_pr_diff( self, repo_slug: str, pr_id: int ) -> str: """Get diff of a pull request. Args: repo_slug: Repository slug pr_id: Pull request ID Returns: Diff content as string """ path = self._repo_path(repo_slug, "pullrequests", str(pr_id), "diff") return self._request_text(path) or ""

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