Skip to main content
Glama

getComponentList

Retrieve all components from Storybook to view available UI elements and their documentation.

Instructions

Get a list of all components from the configured Storybook

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary handler for the getComponentList MCP tool. Fetches Storybook JSON data and uses version-specific helpers to extract and return the list of available components.
    private async getComponentList() {
      try {
        const response = await fetch(this.storybookUrl);
        if (!response.ok) {
          throw new Error(
            `Failed to fetch Storybook data: ${response.statusText}`
          );
        }
    
        const data = (await response.json()) as StorybookDataV3 | StorybookDataV5;
    
        const components =
          data.v === 3 ? getComponentListV3(data) : getComponentListV5(data);
    
        return {
          content: [
            {
              type: "text",
              text: `Available components:\n${components.join("\n")}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(
          `Failed to get component list: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
  • src/server.ts:151-159 (registration)
    Registration of the getComponentList tool in the ListTools handler, including name, description, and empty input schema.
    {
      name: "getComponentList",
      description:
        "Get a list of all components from the configured Storybook",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • Zod schema definition for getComponentList input (empty object). Note: not used in handler.
    const GetComponentListSchema = z.object({});
  • Helper function that extracts unique component names from Storybook V3 data by parsing story 'kind' fields.
    export const getComponentList = (storybookData: StorybookData) => {
      if (!storybookData || storybookData.v !== 3 || !storybookData.stories) {
        return [];
      }
    
      const componentSet = new Set<string>();
      const stories = storybookData.stories;
    
      for (const key in stories) {
        if (Object.prototype.hasOwnProperty.call(stories, key)) {
          const story = stories[key];
          // filter out docs pages
          if (story.parameters && !story.parameters.docsOnly) {
            // get component path or name from 'kind' property
            const componentPath = story.kind.split("/");
            // usually the last part is the component name
            const componentName = componentPath[componentPath.length - 1];
            componentSet.add(componentName.trim());
          }
        }
      }
    
      // align with  v5
      return Array.from(componentSet).sort();
    };
  • Helper function that extracts component names from Storybook V5 data by filtering 'docs' type entries and using their 'title'.
    export const getComponentList = (data: StorybookData) => {
      if (!data || data.v !== 5 || !data.entries) {
        return [];
      }
    
      const entries = data.entries;
    
      // extract component names, filter only docs type entries
      const components = Object.values(entries)
        .filter((entry) => entry.type === "docs")
        .map((entry) => entry.title)
        .filter((title: string) => title)
        .sort();
    
      // remove duplicates
      const uniqueComponents = [...new Set(components)];
      return uniqueComponents;
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves a list but doesn't mention whether it's read-only, safe, requires authentication, has rate limits, or what the return format looks like (e.g., pagination, structure). This leaves significant gaps for a tool with zero annotation coverage.

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?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to understand quickly.

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 the lack of annotations and output schema, the description is incomplete. It doesn't explain behavioral traits (e.g., safety, authentication) or return values, which are critical for a tool that likely interacts with a Storybook configuration. More context is needed to fully inform usage.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, and it correctly implies no parameters are required, aligning with the schema. Baseline 4 is appropriate for zero-parameter tools.

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 action ('Get a list') and resource ('all components from the configured Storybook'), providing a specific purpose. However, it doesn't explicitly differentiate from its sibling tool 'getComponentsProps', which likely retrieves component properties rather than just the list.

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 its sibling 'getComponentsProps' or any alternatives. The description implies usage for listing components but lacks explicit context, prerequisites, or exclusions.

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/mcpland/storybook-mcp'

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