Skip to main content
Glama
Lexmata

Bitbucket Cloud MCP Server

by Lexmata

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
NameRequiredDescriptionDefault
workspaceYesThe workspace slug
repo_slugYesThe repository slug
titleYesPull request title
source_branchYesSource branch name
destination_branchNoDestination branch (defaults to main branch)
descriptionNoPull request description
close_source_branchNoClose source branch after merge
reviewersNoList of reviewer UUIDs

Implementation Reference

  • 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); }
  • 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'), }),
  • 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'], }, },
  • 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 ); }
  • 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[]; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Lexmata/bitbucket-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server