Skip to main content
Glama

list_branch_restrictions

Retrieve configured branch restrictions for a Bitbucket repository to understand access controls and merge policies.

Instructions

List all branch restrictions for a repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repository_nameYesName of the repository (repo slug)

Implementation Reference

  • Implements the core logic of the 'list_branch_restrictions' tool by querying the Bitbucket API for branch restrictions in a specified repository, formatting the results, and handling errors.
    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' }`, }, ], }; } }
  • Defines the tool schema including name, description, and input parameters for 'list_branch_restrictions'.
    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)
    Imports the handler function and tool schema for 'list_branch_restrictions'.
    listBranchRestrictions, listBranchRestrictionsTool, } from './tools/branch-restrictions/listBranchRestrictions.js';
  • src/index.ts:122-122 (registration)
    Registers the tool schema in the list of available tools returned by ListToolsRequest.
    listBranchRestrictionsTool,
  • src/index.ts:161-161 (registration)
    Maps the tool name 'list_branch_restrictions' to its handler function in the CallToolRequest handler.
    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