Skip to main content
Glama

approve_pull_request

Automate approval of Bitbucket pull requests by specifying workspace, repository, and pull request ID for streamlined code review and PR lifecycle management.

Instructions

Approve a pull request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pull_request_idYesPull request ID
repositoryYesRepository slug (e.g., "my-repo")
workspaceYesBitbucket workspace/project key (e.g., "PROJ")

Implementation Reference

  • The main handler function that validates arguments using isApprovePullRequestArgs, constructs the appropriate Bitbucket API endpoint for Cloud or Server, sends the approval request, and returns a success message or handles errors.
    async handleApprovePullRequest(args: any) { if (!isApprovePullRequestArgs(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for approve_pull_request' ); } const { workspace, repository, pull_request_id } = args; try { let apiPath: string; if (this.apiClient.getIsServer()) { // Bitbucket Server API - use participants endpoint // Convert email format: @ to _ for the API const username = this.username.replace('@', '_'); apiPath = `/rest/api/latest/projects/${workspace}/repos/${repository}/pull-requests/${pull_request_id}/participants/${username}`; await this.apiClient.makeRequest<any>('put', apiPath, { status: 'APPROVED' }); } else { // Bitbucket Cloud API apiPath = `/repositories/${workspace}/${repository}/pullrequests/${pull_request_id}/approve`; await this.apiClient.makeRequest<any>('post', apiPath); } return { content: [ { type: 'text', text: JSON.stringify({ message: 'Pull request approved successfully', pull_request_id, approved_by: this.username }, null, 2), }, ], }; } catch (error) { return this.apiClient.handleApiError(error, `approving pull request ${pull_request_id} in ${workspace}/${repository}`); } }
  • JSON Schema definition for the approve_pull_request tool, specifying input parameters: workspace, repository, pull_request_id.
    name: 'approve_pull_request', description: 'Approve a pull request', inputSchema: { type: 'object', properties: { workspace: { type: 'string', description: 'Bitbucket workspace/project key (e.g., "PROJ")', }, repository: { type: 'string', description: 'Repository slug (e.g., "my-repo")', }, pull_request_id: { type: 'number', description: 'Pull request ID', }, }, required: ['workspace', 'repository', 'pull_request_id'], }, },
  • src/index.ts:124-125 (registration)
    Registration of the approve_pull_request tool in the main server request handler switch statement, delegating to ReviewHandlers.handleApprovePullRequest.
    case 'approve_pull_request': return this.reviewHandlers.handleApprovePullRequest(request.params.arguments);
  • Type guard function for validating approve_pull_request arguments at runtime, used in the handler.
    export const isApprovePullRequestArgs = ( args: any ): args is { workspace: string; repository: string; pull_request_id: number; } => typeof args === 'object' && args !== null && typeof args.workspace === 'string' && typeof args.repository === 'string' && typeof args.pull_request_id === 'number';

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

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