create_pull_request
Create a pull request to merge code changes from a source branch to a destination branch in Bitbucket Cloud repositories.
Instructions
Create a new pull request from a source branch to a destination branch.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | The workspace slug | |
| repo_slug | Yes | The repository slug | |
| title | Yes | Pull request title | |
| source_branch | Yes | Source branch name | |
| destination_branch | No | Destination branch (defaults to main branch) | |
| description | No | Pull request description | |
| close_source_branch | No | Close source branch after merge | |
| reviewers | No | List of reviewer UUIDs |
Implementation Reference
- src/tools/index.ts:933-936 (handler)The main handler for the 'create_pull_request' tool in the ToolHandler class. It parses the input arguments using the Zod schema and delegates to the PullRequestsAPI.create method to execute the pull request creation.case 'create_pull_request': { const params = toolSchemas.create_pull_request.parse(args); return this.prs.create(params); }
- src/tools/index.ts:70-82 (schema)Zod schema definition for validating the input parameters of the create_pull_request tool.create_pull_request: z.object({ workspace: z.string().describe('The workspace slug'), repo_slug: z.string().describe('The repository slug'), title: z.string().describe('Pull request title'), source_branch: z.string().describe('Source branch name'), destination_branch: z .string() .optional() .describe('Destination branch (defaults to main branch)'), description: z.string().optional().describe('Pull request description'), close_source_branch: z.boolean().optional().describe('Close source branch after merge'), reviewers: z.array(z.string()).optional().describe('List of reviewer UUIDs'), }),
- src/tools/index.ts:423-446 (registration)Registration of the 'create_pull_request' tool in the toolDefinitions array, including name, description, and input schema for MCP.name: 'create_pull_request', description: 'Create a new pull request from a source branch to a destination branch.', inputSchema: { type: 'object' as const, properties: { workspace: { type: 'string', description: 'The workspace slug' }, repo_slug: { type: 'string', description: 'The repository slug' }, title: { type: 'string', description: 'Pull request title' }, source_branch: { type: 'string', description: 'Source branch name' }, destination_branch: { type: 'string', description: 'Destination branch (defaults to main branch)', }, description: { type: 'string', description: 'Pull request description' }, close_source_branch: { type: 'boolean', description: 'Close source branch after merge' }, reviewers: { type: 'array', items: { type: 'string' }, description: 'List of reviewer UUIDs', }, }, required: ['workspace', 'repo_slug', 'title', 'source_branch'], }, },
- src/api/pullrequests.ts:36-72 (helper)The core implementation in PullRequestsAPI that constructs the request body and makes the Bitbucket API POST call to create the pull request.async create(params: CreatePullRequestParams): Promise<BitbucketPullRequest> { const { workspace, repo_slug, title, source_branch, destination_branch, description, close_source_branch, reviewers, } = params; const body: Record<string, unknown> = { title, source: { branch: { name: source_branch }, }, close_source_branch: close_source_branch ?? false, }; if (destination_branch) { body.destination = { branch: { name: destination_branch } }; } if (description) { body.description = description; } if (reviewers && reviewers.length > 0) { body.reviewers = reviewers.map((uuid) => ({ uuid })); } return this.client.post<BitbucketPullRequest>( `/repositories/${workspace}/${repo_slug}/pullrequests`, body ); }
- src/types/index.ts:291-300 (schema)TypeScript interface defining the parameters for creating a pull request, used by the API methods.export interface CreatePullRequestParams { workspace: string; repo_slug: string; title: string; source_branch: string; destination_branch?: string; description?: string; close_source_branch?: boolean; reviewers?: string[]; }