gitlab_list_branches
Retrieve a list of branches for a specified GitLab project by providing the project ID and optional search criteria.
Instructions
List branches of a GitLab project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The ID or URL-encoded path of the project | |
| search | No | Search branches by name |
Input Schema (JSON Schema)
{
"properties": {
"project_id": {
"description": "The ID or URL-encoded path of the project",
"type": "string"
},
"search": {
"description": "Search branches by name",
"type": "string"
}
},
"required": [
"project_id"
],
"type": "object"
}
Implementation Reference
- The main handler function that implements the gitlab_list_branches tool. It validates the project_id, calls the GitLab API to list branches, and formats the response.export const listBranches: ToolHandler = async (params, context) => { const { project_id, search } = params.arguments || {}; if (!project_id) { throw new McpError(ErrorCode.InvalidParams, 'project_id is required'); } const response = await context.axiosInstance.get( `/projects/${encodeURIComponent(String(project_id))}/repository/branches`, { params: { search } } ); return formatResponse(response.data); };
- src/utils/tools-data.ts:46-62 (schema)The tool definition object specifying the name, description, and input schema (JSON Schema) for the gitlab_list_branches tool.{ name: 'gitlab_list_branches', description: 'List branches of a GitLab project', inputSchema: { type: 'object', properties: { project_id: { type: 'string', description: 'The ID or URL-encoded path of the project' }, search: { type: 'string', description: 'Search branches by name' } }, required: ['project_id'] }
- src/utils/tool-registry.ts:26-26 (registration)The registration entry in the toolRegistry that maps the tool name 'gitlab_list_branches' to its handler function repoHandlers.listBranches.gitlab_list_branches: repoHandlers.listBranches,