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

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

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