bitbucket_approve_pr
Approve a pull request in a Bitbucket project and repository using the pull request ID.
Instructions
Approve a pull request
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | Project key | |
| repo | Yes | Repository slug | |
| prId | Yes | Pull request ID |
Implementation Reference
- src/tools/pr-tools.ts:359-380 (handler)Handler function for the bitbucket_approve_pr tool. Validates input using prRefShape, checks manage_pr permission, calls prApi.approve(), invalidates cache, and returns the result or an error.
bitbucket_approve_pr: async (args: unknown): Promise<McpToolResult> => { const start = Date.now(); try { const input = z.object(prRefShape).parse(args); requirePermission(config, 'manage_pr'); log('info', 'tool start', { operation: 'tool_execute', toolName: 'bitbucket_approve_pr' }); const result = await prApi.approve(input.project, input.repo, input.prId); invalidatePrCache(cache, config, input.project, input.repo, input.prId); log('info', 'tool end', { toolName: 'bitbucket_approve_pr', durationMs: Date.now() - start, }); return textResult(result); } catch (err) { log('error', 'tool error', { toolName: 'bitbucket_approve_pr', error: String(err), durationMs: Date.now() - start, }); return errorResult('APPROVE_FAILED', err instanceof Error ? err.message : String(err)); } }, - src/tools/schemas.ts:32-32 (schema)Input schema (prRefShape) defining project, repo, and prId fields used by bitbucket_approve_pr.
export const prRefShape = { project, repo, prId } as const; - src/tools/registry.ts:117-122 (registration)Registration entry pairing the tool name 'bitbucket_approve_pr' with its description, schema, and handler.
{ name: 'bitbucket_approve_pr', description: 'Approve a pull request', shape: prRefShape, handler: h.pr.bitbucket_approve_pr, }, - API helper method that POSTs to /projects/{project}/repos/{repo}/pull-requests/{prId}/approve to approve a pull request.
async approve(project: string, repo: string, prId: number): Promise<BitbucketComment> { return this.client.requestJson<BitbucketComment>( `/projects/${project}/repos/${repo}/pull-requests/${prId}/approve`, { method: 'POST' } ); - src/tools/pr-tools.ts:35-43 (helper)Helper function to invalidate the cache entry for a pull request after approval.
function invalidatePrCache( cache: Cache, config: Config, project: string, repo: string, prId: number ): void { cache.invalidate(`${config.bitbucketUrl}:pr:${project}/${repo}/${prId}`); }