Skip to main content
Glama

getComponentsProps

Retrieve props information for multiple Storybook components to understand their configuration and usage requirements.

Instructions

Get props information for multiple components

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNamesYesArray of component names to get props information for

Implementation Reference

  • The primary handler function that implements the 'getComponentsProps' tool logic. It fetches Storybook data, uses Playwright to navigate to each component's props documentation page, extracts the props table HTML, and formats the results.
    private async getComponentsProps(componentNames: string[]) {
      try {
        // 1. get Storybook data to find component IDs
        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 results: { [componentName: string]: string } = {};
        const errors: { [componentName: string]: string } = {};
    
        // use Playwright to get page content
        const browser = await chromium.launch({ headless: true });
    
        try {
          for (const componentName of componentNames) {
            try {
              const componentUrl =
                data.v === 3
                  ? getComponentPropsDocUrlV3(
                      data,
                      componentName,
                      this.storybookUrl
                    )
                  : getComponentPropsDocUrlV5(
                      data,
                      componentName,
                      this.storybookUrl
                    );
    
              if (!componentUrl) {
                errors[
                  componentName
                ] = `Component "${componentName}" not found in Storybook`;
                continue;
              }
    
              const page = await browser.newPage();
    
              try {
                await page.goto(componentUrl, { waitUntil: "networkidle" });
    
                // wait for table to load
                await page.waitForSelector("table.docblock-argstable", {
                  timeout: 10000,
                });
    
                // get props table HTML
                const propsTableHTML = await page.$eval(
                  "table.docblock-argstable",
                  (element: HTMLElement) => element.outerHTML
                );
    
                results[componentName] = propsTableHTML;
              } catch (pageError) {
                errors[
                  componentName
                ] = `Failed to load component page or find props table: ${
                  pageError instanceof Error
                    ? pageError.message
                    : String(pageError)
                }`;
              } finally {
                await page.close();
              }
            } catch (componentError) {
              errors[componentName] = `Failed to get component URL: ${
                componentError instanceof Error
                  ? componentError.message
                  : String(componentError)
              }`;
            }
          }
        } finally {
          await browser.close();
        }
    
        // format results
        let resultText = "Props information for components:\n\n";
    
        for (const componentName of componentNames) {
          resultText += `### ${componentName}\n`;
          if (results[componentName]) {
            resultText += `${results[componentName]}\n\n`;
          } else if (errors[componentName]) {
            resultText += `Error: ${errors[componentName]}\n\n`;
          }
        }
    
        return {
          content: [
            {
              type: "text",
              text: resultText,
            },
          ],
        };
      } catch (error) {
        throw new Error(
          `Failed to get components props: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
  • Zod schema for validating the input parameters of the 'getComponentsProps' tool, requiring an array of component names.
    const GetComponentsPropsSchema = z.object({
      componentNames: z
        .array(z.string())
        .describe("Array of component names to get props information for"),
    });
  • src/server.ts:161-177 (registration)
    Tool registration in the listTools handler, defining the name, description, and input schema for 'getComponentsProps'.
      name: "getComponentsProps",
      description: "Get props information for multiple components",
      inputSchema: {
        type: "object",
        properties: {
          componentNames: {
            type: "array",
            items: {
              type: "string",
            },
            description:
              "Array of component names to get props information for",
          },
        },
        required: ["componentNames"],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Get' implies a read operation, it doesn't specify whether this is a safe read-only operation, what permissions might be required, whether there are rate limits, what format the returned data takes, or any error conditions. The description provides minimal behavioral context.

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 extremely concise - a single sentence that communicates the core purpose without any wasted words. It's appropriately sized for a simple tool with one parameter and good schema documentation.

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?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what 'props information' includes, what format the response takes, whether there are limitations on the number of components that can be requested, or any error handling. The agent would need to guess about important behavioral aspects.

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?

The input schema has 100% description coverage, with the single parameter 'componentNames' clearly documented as 'Array of component names to get props information for.' The description adds no additional parameter semantics beyond what the schema already provides, so the baseline score of 3 is appropriate.

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') and resource ('props information for multiple components'), making the purpose understandable. However, it doesn't distinguish this tool from its sibling 'getComponentList' - both appear to retrieve component information, so the distinction isn't explicit.

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?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of when to use 'getComponentsProps' versus 'getComponentList' or any other potential tools, nor does it specify prerequisites or appropriate contexts for 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/mcpland/storybook-mcp'

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