Skip to main content
Glama
garc33

Bitbucket Server MCP

by garc33

create_pull_request

Create pull requests to propose code changes, request reviews, and merge feature branches in Bitbucket Server repositories. Submit code for review, assign reviewers, and manage branch merges.

Instructions

Create a new pull request to propose code changes, request reviews, or merge feature branches. Use this when you want to submit code for review, merge a feature branch, or contribute changes to a repository. Automatically sets up branch references and can assign reviewers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNoBitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable. Use list_projects to discover available projects.
repositoryYesRepository slug where the pull request will be created. Use list_repositories to find available repositories.
titleYesClear, descriptive title for the pull request that summarizes the changes.
descriptionNoDetailed description of changes, context, and any relevant information for reviewers. Supports Markdown formatting.
sourceBranchYesSource branch name containing the changes to be merged (e.g., "feature/new-login", "bugfix/security-patch").
targetBranchYesTarget branch where changes will be merged (e.g., "main", "develop", "release/v1.2").
reviewersNoArray of Bitbucket usernames to assign as reviewers for this pull request.

Implementation Reference

  • The core handler function that executes the create_pull_request tool by making a POST request to the Bitbucket API to create a new pull request with the specified title, description, branches, and reviewers.
    private async createPullRequest(input: PullRequestInput) {
      const response = await this.api.post(
        `/projects/${input.project}/repos/${input.repository}/pull-requests`,
        {
          title: input.title,
          description: input.description,
          fromRef: {
            id: `refs/heads/${input.sourceBranch}`,
            repository: {
              slug: input.repository,
              project: { key: input.project }
            }
          },
          toRef: {
            id: `refs/heads/${input.targetBranch}`,
            repository: {
              slug: input.repository,
              project: { key: input.project }
            }
          },
          reviewers: input.reviewers?.map(username => ({ user: { name: username } }))
        }
      );
    
      return {
        content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }]
      };
    }
  • src/index.ts:190-209 (registration)
    Tool registration in the MCP server, including name, description, and detailed input schema for validation.
      name: 'create_pull_request',
      description: 'Create a new pull request to propose code changes, request reviews, or merge feature branches. Use this when you want to submit code for review, merge a feature branch, or contribute changes to a repository. Automatically sets up branch references and can assign reviewers.',
      inputSchema: {
        type: 'object',
        properties: {
          project: { type: 'string', description: 'Bitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable. Use list_projects to discover available projects.' },
          repository: { type: 'string', description: 'Repository slug where the pull request will be created. Use list_repositories to find available repositories.' },
          title: { type: 'string', description: 'Clear, descriptive title for the pull request that summarizes the changes.' },
          description: { type: 'string', description: 'Detailed description of changes, context, and any relevant information for reviewers. Supports Markdown formatting.' },
          sourceBranch: { type: 'string', description: 'Source branch name containing the changes to be merged (e.g., "feature/new-login", "bugfix/security-patch").' },
          targetBranch: { type: 'string', description: 'Target branch where changes will be merged (e.g., "main", "develop", "release/v1.2").' },
          reviewers: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of Bitbucket usernames to assign as reviewers for this pull request.'
          }
        },
        required: ['repository', 'title', 'sourceBranch', 'targetBranch']
      }
    },
  • TypeScript interface defining the input structure for the createPullRequest handler, used for type checking.
    interface PullRequestInput extends RepositoryParams {
      title: string;
      description: string;
      sourceBranch: string;
      targetBranch: string;
      reviewers?: string[];
    }
  • Dispatcher case in the main tool handler that validates input and delegates to the createPullRequest method.
    case 'create_pull_request': {
      if (!this.isPullRequestInput(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid pull request input parameters'
        );
      }
      // Ensure project is set
      const createArgs = { ...args, project: getProject(args.project) };
      return await this.createPullRequest(createArgs);
    }
  • Runtime type guard helper function to validate arguments before calling createPullRequest.
    private isPullRequestInput(args: unknown): args is PullRequestInput {
      const input = args as Partial<PullRequestInput>;
      return typeof args === 'object' &&
        args !== null &&
        typeof input.project === 'string' &&
        typeof input.repository === 'string' &&
        typeof input.title === 'string' &&
        typeof input.sourceBranch === 'string' &&
        typeof input.targetBranch === 'string' &&
        (input.description === undefined || typeof input.description === 'string') &&
        (input.reviewers === undefined || Array.isArray(input.reviewers));
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context about automatically setting up branch references and assigning reviewers, but lacks details on permissions required, error conditions, rate limits, or what happens on success/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.

Conciseness4/5

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

The description is efficiently structured in two sentences that front-load the core purpose and usage context. Every sentence adds value, though it could be slightly more concise by combining some clauses without losing clarity.

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

Completeness3/5

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

For a mutation tool with 7 parameters, no annotations, and no output schema, the description is moderately complete. It covers purpose and basic usage but lacks details on behavioral outcomes, error handling, or return values. Given the complexity and absence of structured safety/behavioral data, it should provide more guidance on what to expect after invocation.

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 7 parameters thoroughly. The description does not add any parameter-specific information beyond what's in the schema, such as formatting examples or constraints not captured in schema descriptions. Baseline 3 is appropriate when schema does the heavy lifting.

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 tool's purpose with specific verbs ('create a new pull request') and resources ('code changes', 'feature branches'), distinguishing it from siblings like 'merge_pull_request' or 'decline_pull_request' by focusing on creation rather than modification or review actions.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool ('when you want to submit code for review, merge a feature branch, or contribute changes'), but does not explicitly state when NOT to use it or name specific alternatives among siblings like 'merge_pull_request' for merging without creation.

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/garc33/bitbucket-server-mcp-server'

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