Skip to main content
Glama

retrieve_single_branch

Retrieve a specific branch and its details from Storyblok by supplying the branch's numeric ID via the Management API.

Instructions

Retrieves a single branch (pipeline) by its ID via the Storyblok Management API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branch_idYesNumeric ID of the branch to retrieve

Implementation Reference

  • The 'retrieve_single_branch' tool handler. Registered on the MCP server with a 'branch_id' (z.number()) input schema. Calls apiGet(`/branches/${branch_id}`) via the Storyblok Management API and returns the response as JSON. On APIError, returns an error response.
    // Tool: retrieve_single_branch
    server.tool(
      'retrieve_single_branch',
      'Retrieves a single branch (pipeline) by its ID via the Storyblok Management API.',
      {
        branch_id: z.number().describe('Numeric ID of the branch to retrieve'),
      },
      async ({ branch_id }) => {
        try {
          const data = await apiGet(`/branches/${branch_id}`);
          return createJsonResponse(data);
        } catch (error) {
          if (error instanceof APIError) {
            return createErrorResponse(error);
          }
          throw error;
        }
      }
    );
  • Input schema for 'retrieve_single_branch': expects branch_id as a z.number() (numeric ID of the branch to retrieve).
    {
      branch_id: z.number().describe('Numeric ID of the branch to retrieve'),
    },
  • The registerBranches() function registers all branch-related tools (including 'retrieve_single_branch') on the MCP server instance.
    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;
          }
        }
      );
    
      // Tool: retrieve_single_branch
      server.tool(
        'retrieve_single_branch',
        'Retrieves a single branch (pipeline) by its ID via the Storyblok Management API.',
        {
          branch_id: z.number().describe('Numeric ID of the branch to retrieve'),
        },
        async ({ branch_id }) => {
          try {
            const data = await apiGet(`/branches/${branch_id}`);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    
      // Tool: create_branch
      server.tool(
        'create_branch',
        'Creates a new branch (pipeline) in a Storyblok space via the Management API.',
        {
          name: z.string().describe('Required name for the new branch'),
          source_id: z.number().optional().describe('ID of an existing branch to clone'),
          url: z.string().optional().describe('Preview URL for the branch'),
          position: z.number().optional().describe('Numeric position for ordering'),
        },
        async ({ name, source_id, url, position }) => {
          try {
            const branchData: Record<string, unknown> = { name };
            if (source_id !== undefined) branchData.source_id = source_id;
            if (url !== undefined) branchData.url = url;
            if (position !== undefined) branchData.position = position;
    
            const payload = { branch: branchData };
            const data = await apiPost('/branches/', payload);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    
      // Tool: update_branch
      server.tool(
        'update_branch',
        'Updates an existing branch (pipeline) in a Storyblok space via the Management API.',
        {
          branch_id: z.number().describe('Numeric ID of the branch to update'),
          name: z.string().optional().describe('New branch name'),
          source_id: z.number().optional().describe('Set/clear source branch (clone origin)'),
          url: z.string().optional().describe('Preview URL'),
          position: z.number().optional().describe('Position ordering number'),
        },
        async ({ branch_id, name, source_id, url, position }) => {
          try {
            const branchData: Record<string, unknown> = {};
            if (name !== undefined) branchData.name = name;
            if (source_id !== undefined) branchData.source_id = source_id;
            if (url !== undefined) branchData.url = url;
            if (position !== undefined) branchData.position = position;
    
            const payload = { branch: branchData };
            const data = await apiPut(`/branches/${branch_id}`, payload);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    
      // Tool: delete_branch
      server.tool(
        'delete_branch',
        'Deletes a branch (pipeline) by its ID in a Storyblok space.',
        {
          branch_id: z.number().describe('Numeric ID of the branch to delete'),
        },
        async ({ branch_id }) => {
          try {
            const data = await apiDelete(`/branches/${branch_id}`);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    }
  • Import of registerBranches from './pipelines.js' in the tool aggregator.
    import { registerBranches } from './pipelines.js';
  • Call to registerBranches(server) that activates the 'retrieve_single_branch' tool registration.
    registerBranches(server);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must cover behavioral traits. It implies a read operation but lacks details on authentication requirements, rate limits, error handling, or what happens if the branch is not found.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence conveys the purpose efficiently with no unnecessary words. Perfectly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple retrieval tool with one parameter and no output schema, the description is minimally adequate. However, it lacks usage context and behavioral details that would make it fully informative.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds no new meaning beyond 'by its ID', which is already in the schema's parameter description. No extra semantic value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('retrieves'), the resource ('single branch (pipeline)'), and the method ('by its ID'). It effectively distinguishes from sibling tools like 'retrieve_multiple_branches' by specifying singular retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'retrieve_multiple_branches'. There is no mention of prerequisites, limitations, or context for appropriate usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/hypescale/storyblok-mcp-server'

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