unapprove_pull_request
Remove approval from a pull request in Bitbucket by specifying the workspace, repository, and pull request ID. Manage PR lifecycle and code review efficiently with Bitbucket MCP Server integration.
Instructions
Remove approval from a pull request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pull_request_id | Yes | Pull request ID | |
| repository | Yes | Repository slug (e.g., "my-repo") | |
| workspace | Yes | Bitbucket workspace/project key (e.g., "PROJ") |
Implementation Reference
- src/handlers/review-handlers.ts:171-210 (handler)Core implementation of the unapprove_pull_request tool. Validates input using isApprovePullRequestArgs guard, then calls Bitbucket API: for Server - PUT /participants/{username} with status 'UNAPPROVED'; for Cloud - DELETE /approve. Returns success message or handles errors.async handleUnapprovePullRequest(args: any) { if (!isApprovePullRequestArgs(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for unapprove_pull_request' ); } const { workspace, repository, pull_request_id } = args; try { let apiPath: string; if (this.apiClient.getIsServer()) { // Bitbucket Server API - use participants endpoint 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: 'UNAPPROVED' }); } else { // Bitbucket Cloud API apiPath = `/repositories/${workspace}/${repository}/pullrequests/${pull_request_id}/approve`; await this.apiClient.makeRequest<any>('delete', apiPath); } return { content: [ { type: 'text', text: JSON.stringify({ message: 'Pull request approval removed successfully', pull_request_id, unapproved_by: this.username }, null, 2), }, ], }; } catch (error) { return this.apiClient.handleApiError(error, `removing approval from pull request ${pull_request_id} in ${workspace}/${repository}`); } }
- src/tools/definitions.ts:370-391 (schema)Tool schema definition including name, description, and inputSchema specifying required parameters: workspace, repository, pull_request_id.{ name: 'unapprove_pull_request', description: 'Remove approval from 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:126-127 (registration)Tool registration in the main switch statement that dispatches CallToolRequest to the ReviewHandlers.handleUnapprovePullRequest method.case 'unapprove_pull_request': return this.reviewHandlers.handleUnapprovePullRequest(request.params.arguments);