Skip to main content
Glama

storybook_test_component

Run visual, accessibility, and interaction tests on Storybook components to verify UI functionality and compliance standards.

Instructions

Run visual and accessibility tests on a component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNameYes
storyNameNo
testTypesNo

Implementation Reference

  • The `testComponent` method in StorybookTools class implements the core logic for the `storybook_test_component` tool, performing simulated visual, accessibility, and interaction tests on Storybook components.
    async testComponent(args: any) {
      const params = StorybookTestSchema.parse(args);
      const testTypes = params.testTypes || ['visual', 'accessibility'];
      
      const results: any = {
        component: params.componentName,
        story: params.storyName || 'default',
        tests: {}
      };
    
      try {
        // Visual regression test simulation
        if (testTypes.includes('visual')) {
          results.tests.visual = {
            passed: true,
            message: 'Visual regression test passed',
            details: {
              pixelDifference: 0,
              percentageDifference: 0,
              threshold: 0.1
            }
          };
        }
    
        // Accessibility test simulation
        if (testTypes.includes('accessibility')) {
          results.tests.accessibility = {
            passed: true,
            violations: [],
            warnings: [
              {
                id: 'color-contrast',
                impact: 'minor',
                description: 'Ensure sufficient color contrast',
                nodes: 2
              }
            ],
            passes: [
              'aria-roles',
              'button-name',
              'document-title',
              'html-has-lang',
              'image-alt',
              'label',
              'link-name',
              'list',
              'listitem',
              'meta-viewport',
              'region'
            ]
          };
        }
    
        // Interaction test simulation
        if (testTypes.includes('interaction')) {
          results.tests.interaction = {
            passed: true,
            testsRun: [
              { name: 'renders correctly', passed: true },
              { name: 'handles click events', passed: true },
              { name: 'updates state on input', passed: true }
            ],
            duration: '1.2s'
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(results, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Error testing component: ${error.message}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod schema defining the input validation for the `storybook_test_component` tool parameters.
    const StorybookTestSchema = z.object({
      componentName: z.string(),
      storyName: z.string().optional(),
      testTypes: z.array(z.enum(['visual', 'accessibility', 'interaction'])).optional()
    });
  • src/index.ts:75-92 (registration)
    Tool registration in the `listTools` response, defining the tool's name, description, and input schema.
      name: 'storybook_test_component',
      description: 'Run visual and accessibility tests on a component',
      inputSchema: {
        type: 'object',
        properties: {
          componentName: { type: 'string' },
          storyName: { type: 'string' },
          testTypes: {
            type: 'array',
            items: { 
              type: 'string',
              enum: ['visual', 'accessibility', 'interaction']
            }
          }
        },
        required: ['componentName']
      }
    },
  • src/index.ts:304-305 (registration)
    Dispatch logic in the `callTool` request handler switch statement, routing calls to the `storybookTools.testComponent` method.
    case 'storybook_test_component':
      return await this.storybookTools.testComponent(args);
Behavior2/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 mentions 'Run visual and accessibility tests' but lacks critical behavioral details: whether this is a read-only or destructive operation, what permissions are needed, how results are returned, or any rate limits. For a testing tool with zero annotation coverage, this is a significant gap.

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 with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration, earning its place as concise and well-structured.

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 complexity (testing tool with 3 parameters), no annotations, no output schema, and 0% schema coverage, the description is incomplete. It doesn't explain return values, error handling, or behavioral traits, leaving the agent with insufficient information to use the tool effectively beyond its basic purpose.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It adds no meaning beyond the schema—no explanation of what componentName, storyName, or testTypes represent, their formats, or how they interact. With 3 parameters (one required) and no enum details in the description, this fails to provide necessary context.

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 tool's purpose with specific verbs ('Run visual and accessibility tests') and resource ('on a component'), distinguishing it from siblings like component_analyze or component_create. However, it doesn't explicitly differentiate from other testing tools like playwright_test_ui, which slightly reduces clarity.

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. With siblings like playwright_test_ui and storybook_get_stories, there's no indication of context, prerequisites, or exclusions, leaving the agent to infer usage from the tool name alone.

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/willem4130/ui-ux-mcp-server'

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