Storybook MCP Server

0.1.3 · active · verified Sun Apr 19

storybook-mcp-server is a TypeScript-based Model Context Protocol (MCP) server that enables AI assistants to interact comprehensively with Storybook instances. It allows AI agents to discover components, list and filter stories, retrieve detailed story information (including props and args), and capture screenshots across various viewports. The current stable version is 0.1.3, indicating it's in early development with a focus on feature completion and documentation. Release cadence appears to be driven by documentation updates and initial feature set completion rather than strict timeboxes, with all releases to date being pre-1.0. Key differentiators include its adherence to the MCP standard, direct integration with Storybook for metadata extraction, and leveraging Puppeteer for robust visual testing capabilities, making it a specialized tool for AI-driven component interaction and analysis.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to launch the `storybook-mcp-server` as a command-line utility, connecting it to a specified Storybook instance and configuring an output directory for captured screenshots. This showcases the primary way developers interact with the server, enabling AI assistants to access Storybook content.

import { exec } from 'child_process';
import path from 'path';

// IMPORTANT: Ensure your Storybook is running before starting the MCP server.
// For example, run `npm run storybook` in your project, typically on http://localhost:6006.
console.log('--- Starting Storybook MCP Server Quickstart ---');
console.log('Please ensure your Storybook is running, e.g., on http://localhost:6006');

const storybookUrl = process.env.STORYBOOK_URL ?? 'http://localhost:6006';
const outputDir = path.resolve(process.cwd(), './mcp-screenshots');

console.log(`Configured to connect to Storybook at: ${storybookUrl}`);
console.log(`Screenshots will be saved to: ${outputDir}`);

const command = `storybook-mcp-server --storybook-url ${storybookUrl} --output-dir ${outputDir}`;

console.log(`Executing command: ${command}\n`);

// Execute the CLI command as a child process
const childProcess = exec(command, (error, stdout, stderr) => {
  if (error) {
    console.error(`Error starting MCP server: ${error.message}`);
    console.error(`Stderr: ${stderr}`);
    return;
  }
  console.log(`MCP Server Stdout: ${stdout}`);
  if (stderr) {
    console.warn(`MCP Server Stderr: ${stderr}`);
  }
  console.log('\nStorybook MCP Server started successfully (or is attempting to connect).');
  console.log('An AI assistant (e.g., Anthropic Claude) can now connect and interact via the Model Context Protocol.');
  console.log('Example prompt for AI: "What components are available in my Storybook?"');
  console.log('To stop the server, you would typically kill this process.');
});

// Optional: Add a listener for process exit for cleanup or logging
childProcess.on('exit', (code) => {
  console.log(`\nStorybook MCP Server process exited with code ${code}.`);
});

view raw JSON →