retrieve_multiple_branches
Fetch multiple branches (pipelines) from a Storyblok space, with optional filtering by branch IDs or a name search.
Instructions
Retrieves multiple branches (pipelines) in a Storyblok space via the Management API.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by_ids | No | Comma-separated list of branch IDs to filter | |
| search | No | Filter term for branch names |
Implementation Reference
- src/tools/pipelines.ts:11-34 (handler)The handler function for the 'retrieve_multiple_branches' tool. It accepts optional 'by_ids' and 'search' parameters, builds query params, makes a GET request to '/branches/', and returns the JSON response or an error.
// Tool: retrieve_multiple_branches server.tool( 'retrieve_multiple_branches', 'Retrieves multiple branches (pipelines) in a Storyblok space via the Management API.', { by_ids: z.string().optional().describe('Comma-separated list of branch IDs to filter'), search: z.string().optional().describe('Filter term for branch names'), }, async ({ by_ids, search }) => { try { const params: Record<string, string> = {}; if (by_ids) params.by_ids = by_ids; if (search) params.search = search; const data = await apiGet('/branches/', params); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/pipelines.ts:15-18 (schema)Zod schema definitions for the 'retrieve_multiple_branches' tool input: optional 'by_ids' (comma-separated branch IDs) and 'search' (filter term for branch names).
{ by_ids: z.string().optional().describe('Comma-separated list of branch IDs to filter'), search: z.string().optional().describe('Filter term for branch names'), }, - src/tools/pipelines.ts:10-34 (registration)The tool is registered via server.tool('retrieve_multiple_branches', ...) inside the registerBranches() function exported from src/tools/pipelines.ts.
export function registerBranches(server: McpServer): void { // Tool: retrieve_multiple_branches server.tool( 'retrieve_multiple_branches', 'Retrieves multiple branches (pipelines) in a Storyblok space via the Management API.', { by_ids: z.string().optional().describe('Comma-separated list of branch IDs to filter'), search: z.string().optional().describe('Filter term for branch names'), }, async ({ by_ids, search }) => { try { const params: Record<string, string> = {}; if (by_ids) params.by_ids = by_ids; if (search) params.search = search; const data = await apiGet('/branches/', params); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/index.ts:63-64 (registration)The registerBranches function is called from registerAllTools() in the aggregator module, which registers all tools with the MCP server.
// Branch/Pipeline management registerBranches(server); - src/utils/api.ts:180-190 (helper)The apiGet helper function that performs the actual HTTP GET request to the Storyblok Management API, used by the retrieve_multiple_branches handler.
export async function apiGet<T = unknown>( path: string, params: Record<string, string> = {} ): Promise<T> { const url = buildUrlWithParams(buildManagementUrl(path), params); const response = await fetch(url, { method: 'GET', headers: getManagementHeaders(), }); return handleResponse<T>(response, url); }