Skip to main content
Glama
Lexmata

Bitbucket Cloud MCP Server

by Lexmata

create_branch

Create a new branch in Bitbucket Cloud from a specific commit or existing branch to organize development work and isolate changes.

Instructions

Create a new branch from a specific commit or existing branch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceYesThe workspace slug
repo_slugYesThe repository slug
nameYesNew branch name
targetYesTarget commit hash or branch name

Implementation Reference

  • Core handler function in BranchesAPI that executes the Bitbucket API POST request to create a new branch from the specified target.
    async create(params: CreateBranchParams): Promise<BitbucketBranch> {
      const { workspace, repo_slug, name, target } = params;
      return this.client.post<BitbucketBranch>(
        `/repositories/${workspace}/${repo_slug}/refs/branches`,
        {
          name,
          target: { hash: target },
        }
      );
    }
  • Tool registration definition including name, description, and input schema for MCP tool registration.
      name: 'create_branch',
      description: 'Create a new branch from a specific commit or existing branch.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          workspace: { type: 'string', description: 'The workspace slug' },
          repo_slug: { type: 'string', description: 'The repository slug' },
          name: { type: 'string', description: 'New branch name' },
          target: { type: 'string', description: 'Target commit hash or branch name' },
        },
        required: ['workspace', 'repo_slug', 'name', 'target'],
      },
    },
  • Zod schema used for input validation and parsing in the tool handler.
    create_branch: z.object({
      workspace: z.string().describe('The workspace slug'),
      repo_slug: z.string().describe('The repository slug'),
      name: z.string().describe('New branch name'),
      target: z.string().describe('Target commit hash or branch name'),
    }),
  • Dispatch handler case in ToolHandler.handleTool that parses input and delegates to BranchesAPI.create.
    case 'create_branch': {
      const params = toolSchemas.create_branch.parse(args);
      return this.branches.create(params);
    }
  • TypeScript interface defining the input parameters for the create branch operation.
    export interface CreateBranchParams {
      workspace: string;
      repo_slug: string;
      name: string;
      target: 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