Skip to main content
Glama
freema

MCP Design System Extractor

get_component_variants

Retrieve all story variants and states for a specific component from a Storybook design system. Returns variant IDs, names, and parameters to analyze component behavior across different scenarios.

Instructions

Get all story variants/states for a specific component. Returns all stories (variants) for a component with their IDs, names, and parameters. Component name should match exactly as shown in list_components (case-sensitive).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNameYesExact name of the component as returned by list_components (e.g., "Button", "Input", "Card"). Case-sensitive matching.

Implementation Reference

  • Core handler function that validates the input, fetches the Storybook stories index, filters stories to find variants matching the component name (case-insensitive), extracts id, name, args, parameters, and returns a formatted success response with the list of variants or an error if none found.
    export async function handleGetComponentVariants(input: any) {
      let validatedInput: any;
      try {
        validatedInput = validateGetComponentVariantsInput(input);
        const client = new StorybookClient();
    
        const storiesIndex = await client.fetchStoriesIndex();
        const variants: ComponentVariant[] = [];
    
        const stories = storiesIndex.stories || storiesIndex.entries || {};
        Object.values(stories).forEach(story => {
          const componentName = story.title.split('/').pop() || story.title;
    
          if (componentName.toLowerCase() === validatedInput.componentName.toLowerCase()) {
            variants.push({
              id: story.id,
              name: story.name,
              ...(story.args && { args: story.args }),
              ...(story.parameters && { parameters: story.parameters }),
            });
          }
        });
    
        if (variants.length === 0) {
          const notFoundError = createNotFoundError(
            'get component variants',
            'component',
            'Use list_components tool to see all available components, or search_components to find similar component names',
            undefined,
            validatedInput.componentName
          );
          return handleError(notFoundError.message);
        }
    
        return formatSuccessResponse(
          variants,
          `Found ${variants.length} variants for component: ${validatedInput.componentName}`
        );
      } catch (error) {
        return handleErrorWithContext(error, 'get component variants', {
          componentName: validatedInput?.componentName || 'unknown',
        });
      }
    }
  • Tool registration object defining the name, description, and input schema for the 'get_component_variants' tool.
    export const getComponentVariantsTool: Tool = {
      name: 'get_component_variants',
      description:
        'Get all story variants/states for a specific component. Returns all stories (variants) for a component with their IDs, names, and parameters. Component name should match exactly as shown in list_components (case-sensitive).',
      inputSchema: {
        type: 'object',
        properties: {
          componentName: {
            type: 'string',
            description:
              'Exact name of the component as returned by list_components (e.g., "Button", "Input", "Card"). Case-sensitive matching.',
          },
        },
        required: ['componentName'],
      },
    };
  • Zod schema for validating the input to get_component_variants, requiring a componentName string.
    const GetComponentVariantsInputSchema = z.object({
      componentName: z.string(),
    });
  • src/index.ts:15-24 (registration)
    Server registration mapping the tool name 'get_component_variants' to its handler function.
    const toolHandlers = new Map<string, (input: any) => Promise<any>>([
      ['list_components', tools.handleListComponents],
      ['get_component_html', tools.handleGetComponentHTML],
      ['get_component_variants', tools.handleGetComponentVariants],
      ['search_components', tools.handleSearchComponents],
      ['get_component_dependencies', tools.handleGetComponentDependencies],
      ['get_theme_info', tools.handleGetThemeInfo],
      ['get_component_by_purpose', tools.handleGetComponentByPurpose],
      ['get_external_css', tools.handleGetExternalCSS],
    ]);
  • Validation function using the Zod schema to parse and validate input for get_component_variants.
    export function validateGetComponentVariantsInput(input: any): GetComponentVariantsInput {
      return GetComponentVariantsInputSchema.parse(input);
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the operation is a read ('Get'), returns specific fields (IDs, names, parameters), and mentions case-sensitive matching. However, it lacks details on error handling, pagination, or rate limits, which are important for a tool with no 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 front-loaded with the core purpose, followed by return details and usage note. It consists of two efficient sentences with no wasted words, making it easy to parse quickly.

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?

Given no annotations and no output schema, the description adequately covers the purpose and parameter usage but lacks information on return structure (beyond listing fields) and potential behavioral aspects like errors or constraints. For a tool with 1 parameter and 100% schema coverage, it meets minimum viability but could be more complete.

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%, with the parameter 'componentName' well-documented in the schema. The description adds marginal value by reinforcing that the name should match exactly as in 'list_components' and is case-sensitive, but does not provide additional syntax or format details beyond the schema.

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 verb 'Get' and resource 'story variants/states for a specific component', specifying it returns 'all stories (variants) for a component with their IDs, names, and parameters'. It distinguishes from siblings like 'list_components' (which lists components) and 'get_component_by_purpose' (which filters by purpose) by focusing on variants of a single component.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: to retrieve variants for a specific component, with the component name needing to match exactly as shown in 'list_components'. However, it does not explicitly state when not to use it or name alternatives among siblings, such as using 'search_components' for broader queries.

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/freema/mcp-design-system-extractor'

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