Skip to main content
Glama

fetch_components

Retrieve Storyblok components using server-side filtering, sorting, and group inclusion options. Supports pagination and summary fields.

Instructions

Fetches components with server-side filters, sorting, and option to include groups.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
component_summaryNoIf true, return only id, name, and display_name for each component
include_schema_detailsNoIf false, exclude schema from component response
filter_by_nameNoSearch query for filtering components by name
is_rootNoFilter for root components only
in_groupNoFilter by component group ID
sort_byNoField to sort by
per_pageNoNumber of results per page

Implementation Reference

  • Handler function for the fetch_components tool. It builds query params from inputs, calls apiGet('/components', params) to fetch components, optionally summarizes or excludes schema, also fetches component_groups, and returns a JSON response.
      async ({ component_summary, include_schema_details, filter_by_name, is_root, in_group, sort_by, per_page }) => {
        try {
          const params: Record<string, string> = {};
          if (filter_by_name) {
            params.search = filter_by_name;
          }
          if (is_root !== undefined) {
            params.is_root = is_root ? '1' : '0';
          }
          if (in_group !== undefined) {
            params.in_group = String(in_group);
          }
          if (sort_by) {
            params.sort_by = sort_by;
          }
          if (per_page) {
            params.per_page = String(per_page);
          }
    
          const data = await apiGet<{ components: Array<Record<string, unknown>> }>('/components', params);
          let components = data.components || [];
    
          // Summaries or remove schema if requested
          if (component_summary) {
            components = components.map((c) => ({
              id: c.id,
              name: c.name,
              display_name: c.display_name,
            }));
          } else if (!include_schema_details) {
            components = components.map((c) => {
              const { schema, ...rest } = c;
              return rest;
            });
          }
    
          // Also fetch component groups (folders)
          const groupsData = await apiGet<{ component_groups: Array<Record<string, unknown>> }>('/component_groups');
          const groups = groupsData.component_groups || [];
    
          return createJsonResponse({
            components_count: components.length,
            components,
            component_groups: groups,
          });
        } catch (error) {
          if (error instanceof APIError) {
            return createErrorResponse(error);
          }
          throw error;
        }
      }
    );
  • Zod schema definitions for fetch_components inputs: component_summary, include_schema_details, filter_by_name, is_root, in_group, sort_by, per_page.
    {
      component_summary: z
        .boolean()
        .optional()
        .default(false)
        .describe('If true, return only id, name, and display_name for each component'),
      include_schema_details: z
        .boolean()
        .optional()
        .default(true)
        .describe('If false, exclude schema from component response'),
      filter_by_name: z.string().optional().describe('Search query for filtering components by name'),
      is_root: z.boolean().optional().describe('Filter for root components only'),
      in_group: z.number().optional().describe('Filter by component group ID'),
      sort_by: z.string().optional().describe('Field to sort by'),
      per_page: z.number().optional().describe('Number of results per page'),
    },
  • Registration of the fetch_components tool via server.tool('fetch_components', ...) inside the registerComponents function.
    export function registerComponents(server: McpServer): void {
      // Tool: fetch_components
      server.tool(
        'fetch_components',
        'Fetches components with server-side filters, sorting, and option to include groups.',
        {
          component_summary: z
            .boolean()
            .optional()
            .default(false)
            .describe('If true, return only id, name, and display_name for each component'),
          include_schema_details: z
            .boolean()
            .optional()
            .default(true)
            .describe('If false, exclude schema from component response'),
          filter_by_name: z.string().optional().describe('Search query for filtering components by name'),
          is_root: z.boolean().optional().describe('Filter for root components only'),
          in_group: z.number().optional().describe('Filter by component group ID'),
          sort_by: z.string().optional().describe('Field to sort by'),
          per_page: z.number().optional().describe('Number of results per page'),
        },
        async ({ component_summary, include_schema_details, filter_by_name, is_root, in_group, sort_by, per_page }) => {
          try {
            const params: Record<string, string> = {};
            if (filter_by_name) {
              params.search = filter_by_name;
            }
            if (is_root !== undefined) {
              params.is_root = is_root ? '1' : '0';
            }
            if (in_group !== undefined) {
              params.in_group = String(in_group);
            }
            if (sort_by) {
              params.sort_by = sort_by;
            }
            if (per_page) {
              params.per_page = String(per_page);
            }
    
            const data = await apiGet<{ components: Array<Record<string, unknown>> }>('/components', params);
            let components = data.components || [];
    
            // Summaries or remove schema if requested
            if (component_summary) {
              components = components.map((c) => ({
                id: c.id,
                name: c.name,
                display_name: c.display_name,
              }));
            } else if (!include_schema_details) {
              components = components.map((c) => {
                const { schema, ...rest } = c;
                return rest;
              });
            }
    
            // Also fetch component groups (folders)
            const groupsData = await apiGet<{ component_groups: Array<Record<string, unknown>> }>('/component_groups');
            const groups = groupsData.component_groups || [];
    
            return createJsonResponse({
              components_count: components.length,
              components,
              component_groups: groups,
            });
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
  • Top-level registration call: registerComponents(server) which registers fetch_components among other component tools.
    registerComponents(server);
    registerComponentsFolder(server);
  • The apiGet helper used by fetch_components to make GET requests to the Storyblok Management API.
    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);
    }
Behavior2/5

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

No annotations exist, so the description carries full burden. It describes the operation as a read with filtering/sorting but omits important details like pagination behavior, rate limits, or what 'include groups' entails. The per_page parameter suggests pagination but is not mentioned.

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

Conciseness4/5

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

The description is a single, front-loaded sentence with no wasted words. It efficiently conveys the core purpose, though it could benefit from brief structuring (e.g., listing filter types) for clarity.

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

Completeness2/5

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

Given 7 optional parameters and no output schema, the description is too sparse. It fails to explain pagination behavior, return format, or how to combine filters. This leaves the agent needing to infer important usage details.

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?

Schema description coverage is 100%, so baseline is 3. The description groups parameters into categories (filters, sorting, include groups) but adds little beyond what the schema already explains. It does not clarify parameter interactions or usage nuances.

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

Purpose4/5

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

The description clearly states the verb 'Fetches' and resource 'components', and highlights key features like server-side filters, sorting, and include groups. This distinguishes it from sibling tools like get_component (single) or create_component, though it could explicitly differentiate from other fetch/retrieve tools.

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 is provided on when to use this tool versus alternatives such as get_component for a single component or other list operations. There is no mention of prerequisites, use cases, or when not to use it.

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