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
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | The workspace slug | |
| repo_slug | Yes | The repository slug | |
| name | Yes | New branch name | |
| target | Yes | Target commit hash or branch name |
Implementation Reference
- src/tools/index.ts:994-997 (handler)ToolHandler.handleTool switch case for 'create_branch': parses input parameters using Zod schema and delegates to BranchesAPI.create method.case 'create_branch': { const params = toolSchemas.create_branch.parse(args); return this.branches.create(params); }
- src/api/branches.ts:35-44 (handler)BranchesAPI.create method: extracts parameters and makes a POST request to Bitbucket API to create the branch from the target hash.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 }, } ); }
- src/tools/index.ts:162-167 (schema)Zod schema definition for create_branch tool input validation.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'), }),
- src/tools/index.ts:599-612 (registration)MCP tool registration in toolDefinitions array, including name, description, and inputSchema.{ 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'], }, },