Skip to main content
Glama

list_branch_restrictions

Retrieve all branch restriction rules for a Bitbucket repository to manage access controls and enforce development policies.

Instructions

List all branch restrictions for a repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repository_nameYesName of the repository (repo slug)

Implementation Reference

  • The main handler function that executes the tool logic: fetches branch restrictions from Bitbucket API for a given repository, formats them, and returns as text content.
    export async function listBranchRestrictions( axiosInstance: AxiosInstance, config: Config, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { try { const { repository_name } = args; if (!repository_name) { throw new Error('Repository name is required'); } console.error( `Fetching branch restrictions for repository: ${repository_name}` ); const response = await axiosInstance.get< BitbucketPaginatedResponse<BranchRestriction> >( `/repositories/${config.BITBUCKET_WORKSPACE}/${repository_name}/branch-restrictions` ); const restrictions = response.data.values; const summary = `Found ${restrictions.length} branch restrictions in repository "${repository_name}"`; const restrictionList = restrictions .map( restriction => `**Restriction ${restriction.id}** - Kind: ${restriction.kind} - Pattern: ${restriction.pattern}` ) .join('\n\n'); return { content: [ { type: 'text', text: `${summary}\n\n${restrictionList}`, }, ], }; } catch (error) { console.error('Error fetching branch restrictions:', error); return { content: [ { type: 'text', text: `Error fetching branch restrictions: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } }
  • Tool schema definition including name, description, and input schema for the list_branch_restrictions tool.
    export const listBranchRestrictionsTool = { name: 'list_branch_restrictions', description: 'List all branch restrictions for a repository.', inputSchema: { type: 'object', properties: { repository_name: { type: 'string', description: 'Name of the repository (repo slug)', }, }, required: ['repository_name'], }, };
  • src/index.ts:37-39 (registration)
    Import of the handler function and tool schema object.
    listBranchRestrictions, listBranchRestrictionsTool, } from './tools/branch-restrictions/listBranchRestrictions.js';
  • src/index.ts:122-122 (registration)
    Registration of the tool in the listTools response array.
    listBranchRestrictionsTool,
  • src/index.ts:161-161 (registration)
    Mapping of tool name to handler function in the CallToolRequest handler dispatch.
    list_branch_restrictions: listBranchRestrictions,

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

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