Skip to main content
Glama

get_pull_request

Retrieve a specific pull request by ID from a Bitbucket repository to review changes, check status, or manage code integration.

Instructions

Get a single pull request by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repository_nameYesName of the repository (repo slug)
pull_request_idYesThe ID of the pull request.

Implementation Reference

  • The main handler function that executes the get_pull_request tool. It fetches the pull request details from the Bitbucket API using axios, formats the information into a markdown-like string, and returns it in the expected content format. Handles errors by returning an error message.
    export async function getPullRequest( axiosInstance: AxiosInstance, config: Config, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { try { const { repository_name, pull_request_id } = args; if (!repository_name) { throw new Error('Repository name is required'); } if (!pull_request_id) { throw new Error('Pull request ID is required'); } console.error( `Fetching pull request ${pull_request_id} for repository: ${repository_name}` ); const response = await axiosInstance.get<PullRequest>( `/repositories/${config.BITBUCKET_WORKSPACE}/${repository_name}/pullrequests/${pull_request_id}` ); const pr = response.data; const prDetails = `**PR #${pr.id}: ${pr.title}** - State: ${pr.state} - Author: ${pr.author.display_name} - Source: ${pr.source.branch.name} - Destination: ${pr.destination.branch.name} - Description: ${pr.description} - URL: ${pr.links.html.href}`; return { content: [ { type: 'text', text: prDetails, }, ], }; } catch (error) { console.error('Error fetching pull request:', error); return { content: [ { type: 'text', text: `Error fetching pull request: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } }
  • The tool definition including name, description, and input schema for validation. This is used for tool registration and defines the expected input parameters: repository_name and pull_request_id.
    export const getPullRequestTool = { name: 'get_pull_request', description: 'Get a single pull request by its ID.', inputSchema: { type: 'object', properties: { repository_name: { type: 'string', description: 'Name of the repository (repo slug)', }, pull_request_id: { type: 'string', description: 'The ID of the pull request.', }, }, required: ['repository_name', 'pull_request_id'], }, };
  • src/index.ts:111-135 (registration)
    Registration of the tool in the MCP server's listTools handler. The getPullRequestTool is added to the list of available tools.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Repositories listRepositoriesTool, getRepositoryDetailsTool, // Commits listCommitsTool, getCommitTool, // Branching Model updateRepositoryBranchingModelSettingsTool, updateProjectBranchingModelSettingsTool, listBranchRestrictionsTool, getBranchRestrictionTool, // Projects getProjectTool, listDefaultReviewersTool, // Pull Requests listPullRequestsTool, getPullRequestTool, createPullRequestTool, updatePullRequestTool, // Workspaces listWorkspacesTool, ], }));
  • src/index.ts:142-173 (registration)
    Maps the tool name 'get_pull_request' to its handler function getPullRequest in the central dispatch handlers object used in callToolRequest handler.
    const handlers: Record< string, ( axiosInstance: AxiosInstance, config: Config, args: any ) => Promise<{ content: Array<{ type: string; text: string }> }> > = { // Repositories list_repositories: listRepositories, get_repository_details: getRepositoryDetails, // Commits list_commits: listCommits, get_commit: getCommit, // Branching Model update_repository_branching_model_settings: updateRepositoryBranchingModelSettings, update_project_branching_model_settings: updateProjectBranchingModelSettings, list_branch_restrictions: listBranchRestrictions, get_branch_restriction: getBranchRestriction, // Projects get_project: getProject, list_default_reviewers: listDefaultReviewers, // Pull Requests list_pull_requests: listPullRequests, get_pull_request: getPullRequest, create_pull_request: createPullRequest, update_pull_request: updatePullRequest, // Workspaces list_workspaces: listWorkspaces, };
  • src/index.ts:58-60 (registration)
    Import of the handler function and tool definition from the implementation file.
    getPullRequest, getPullRequestTool, } from './tools/pull-requests/getPullRequest.js';

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/Korfu/mcp-bitbucket'

If you have feedback or need assistance with the MCP directory API, please join our Discord server