merge_pull_request
Merge open pull requests in Bitbucket Cloud using merge commit, squash, or fast-forward strategies to integrate code changes into the main branch.
Instructions
Merge an open pull request. Supports merge commit, squash, and fast-forward strategies.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | The workspace slug | |
| repo_slug | Yes | The repository slug | |
| pr_id | Yes | The pull request ID | |
| message | No | Merge commit message | |
| close_source_branch | No | Close source branch after merge | |
| merge_strategy | No | Merge strategy |
Implementation Reference
- src/tools/index.ts:944-948 (handler)MCP tool handler logic in ToolHandler.handleTool switch statement. Parses arguments with Zod schema and calls PullRequestsAPI.merge.case 'merge_pull_request': { const params = toolSchemas.merge_pull_request.parse(args); const { workspace, repo_slug, pr_id, ...options } = params; return this.prs.merge(workspace, repo_slug, pr_id, options); }
- src/tools/index.ts:93-103 (schema)Zod input schema definition for validating merge_pull_request tool parameters.merge_pull_request: z.object({ workspace: z.string().describe('The workspace slug'), repo_slug: z.string().describe('The repository slug'), pr_id: z.number().describe('The pull request ID'), message: z.string().optional().describe('Merge commit message'), close_source_branch: z.boolean().optional().describe('Close source branch after merge'), merge_strategy: z .enum(['merge_commit', 'squash', 'fast_forward']) .optional() .describe('Merge strategy'), }),
- src/tools/index.ts:463-483 (registration)Tool registration in the toolDefinitions array exported for MCP, including name, description, and JSON inputSchema.{ name: 'merge_pull_request', description: 'Merge an open pull request. Supports merge commit, squash, and fast-forward strategies.', inputSchema: { type: 'object' as const, properties: { workspace: { type: 'string', description: 'The workspace slug' }, repo_slug: { type: 'string', description: 'The repository slug' }, pr_id: { type: 'number', description: 'The pull request ID' }, message: { type: 'string', description: 'Merge commit message' }, close_source_branch: { type: 'boolean', description: 'Close source branch after merge' }, merge_strategy: { type: 'string', enum: ['merge_commit', 'squash', 'fast_forward'], description: 'Merge strategy', }, }, required: ['workspace', 'repo_slug', 'pr_id'], }, },
- src/api/pullrequests.ts:100-114 (helper)Supporting utility method in PullRequestsAPI class that executes the Bitbucket API POST to merge the pull request.async merge( workspace: string, repo_slug: string, pr_id: number, options?: { message?: string; close_source_branch?: boolean; merge_strategy?: 'merge_commit' | 'squash' | 'fast_forward'; } ): Promise<BitbucketPullRequest> { return this.client.post<BitbucketPullRequest>( `/repositories/${workspace}/${repo_slug}/pullrequests/${pr_id}/merge`, options ); }