bitbucket_get_branches
List all branches in a Bitbucket repository by specifying project key and repo slug. Supports pagination and result limits.
Instructions
List repository branches
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | Project key | |
| repo | Yes | Repository slug | |
| limit | No | Max results | |
| start | No | Pagination start |
Implementation Reference
- src/tools/repo-tools.ts:157-185 (handler)Handler function for bitbucket_get_branches tool. Parses input with repoPaginatedShape (project, repo, limit, start), checks 'read_repo' permission, calls repoApi.getBranches(), and returns the result.
bitbucket_get_branches: async (args: unknown): Promise<McpToolResult> => { const start = Date.now(); try { const input = z.object(repoPaginatedShape).parse(args); requirePermission(config, 'read_repo'); log('info', 'tool start', { operation: 'tool_execute', toolName: 'bitbucket_get_branches', }); const result = await repoApi.getBranches( input.project, input.repo, input.limit, input.start ); log('info', 'tool end', { toolName: 'bitbucket_get_branches', durationMs: Date.now() - start, }); return textResult(result); } catch (err) { log('error', 'tool error', { toolName: 'bitbucket_get_branches', error: String(err), durationMs: Date.now() - start, }); return errorResult('GET_BRANCHES_FAILED', err instanceof Error ? err.message : String(err)); } }, - src/tools/schemas.ts:77-77 (schema)Input schema for bitbucket_get_branches: extends repoRefShape (project, repo) with optional limit and start pagination fields.
export const repoPaginatedShape = { ...repoRefShape, limit, start } as const; - src/tools/registry.ts:143-148 (registration)Registers bitbucket_get_branches tool with name, description, input shape repoPaginatedShape, and handler from repo tools.
{ name: 'bitbucket_get_branches', description: 'List repository branches', shape: repoPaginatedShape, handler: h.repo.bitbucket_get_branches, }, - RepositoryApi.getBranches method - makes HTTP GET request to Bitbucket REST API /projects/{project}/repos/{repo}/branches with pagination params.
async getBranches( project: string, repo: string, limit = 25, start = 0 ): Promise<BitbucketPagedResponse<BitbucketBranch>> { return this.client.requestJson<BitbucketPagedResponse<BitbucketBranch>>( `/projects/${project}/repos/${repo}/branches`, { queryParams: { limit, start } } ); }