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
      );
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only mentions supported merge strategies. It doesn't disclose critical behavioral traits like required permissions, whether merging is irreversible, rate limits, or what happens on failure. For a mutation tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose and adds useful detail about merge strategies. Every word earns its place with zero redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after merging (success/failure outcomes), return values, error conditions, or prerequisites beyond the implied 'open' state. More behavioral context is needed given the complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds minimal value by mentioning merge strategies (which the schema's enum already covers), but doesn't provide additional context like default behaviors or parameter interactions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('merge') on a specific resource ('an open pull request'), distinguishing it from sibling tools like 'decline_pull_request' or 'update_pull_request'. It provides the exact verb and target without being tautological.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning 'an open pull request', suggesting it should only be used when a PR is open. However, it doesn't explicitly state when NOT to use it (e.g., for closed/merged PRs) or name alternatives like 'decline_pull_request' for rejection scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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