Skip to main content
Glama
Lexmata

Bitbucket Cloud MCP Server

by Lexmata

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
NameRequiredDescriptionDefault
workspaceYesThe workspace slug
repo_slugYesThe repository slug
pr_idYesThe pull request ID
messageNoMerge commit message
close_source_branchNoClose source branch after merge
merge_strategyNoMerge strategy

Implementation Reference

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

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