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:935-938 (handler)Tool handler case in ToolHandler.handleTool that validates input with Zod schema and calls PullRequestsAPI.create to execute the tool.case 'create_pull_request': { const params = toolSchemas.create_pull_request.parse(args); return this.prs.create(params); }
- src/api/pullrequests.ts:36-72 (helper)Core implementation in PullRequestsAPI.create: destructures params, builds Bitbucket API request body, and performs POST request 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/tools/index.ts:422-446 (registration)MCP tool registration definition including name, description, and input schema.{ 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/tools/index.ts:70-82 (schema)Zod schema for validating create_pull_request tool inputs.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/types/index.ts:293-302 (schema)TypeScript interface defining the parameters for create_pull_request.export interface CreatePullRequestParams { workspace: string; repo_slug: string; title: string; source_branch: string; destination_branch?: string; description?: string; close_source_branch?: boolean; reviewers?: string[]; }