storybook-mcp-server
An MCP server that enables AI assistants to browse Storybook components, manage stories, inspect props, and capture screenshots of components.
README
Storybook MCP Server
A TypeScript MCP (Model Context Protocol) server that provides comprehensive access to Storybook instances. This server enables AI assistants to interact with Storybook components, stories, and capture screenshots.
The server can connect to any running Storybook instance - whether it's your local development server, a deployed production Storybook, or even public component libraries.
Features
Component Discovery
Browse and list all components in your Storybook instance.
Example:
"What components are available in my Storybook?"
Claude's response:
I found 3 components in your Storybook:
- Button (5 stories)
- Card (3 stories)
- Modal (2 stories)
Story Management
Access all stories with filtering by component.
Example:
"Show me all the Button stories"
Claude's response:
The Button component has 3 stories:
- Primary - Default primary button style
- Secondary - Secondary button variant
- Disabled - Button in disabled state
Detailed Inspection
Get complete story information including parameters, args, and prop definitions.
Example:
"What props does the Button component accept?"
Claude's response:
The Button component accepts the following props:
Prop Type Description Default labelstring Button label text required variant"primary" | "secondary" | "danger" Button style variant "primary" size"small" | "medium" | "large" Button size "medium" disabledboolean Disable button interaction false onClickfunction Click event handler -
Visual Testing
Capture screenshots of individual or all stories. Claude can see and analyze the screenshots immediately.
Example:
"Take a screenshot of the primary button story"
Claude's response:
I've captured a screenshot of the primary button story. Here's what I can see:
[Screenshot displayed in conversation]
The button appears with:
- Blue background (#007bff)
- White text reading "Click me"
- Rounded corners with 4px radius
- Standard padding and hover state
The screenshot has been saved to
./screenshots/components-button--primary.png
Responsive Testing
Test components across multiple viewport sizes.
Example:
"Capture the Card component at mobile size (375x667)"
Claude's response:
I've captured the Card component at mobile viewport (375x667):
[Screenshot displayed in conversation]
At mobile size, the card:
- Stacks content vertically
- Uses full width with 16px padding
- Shows responsive text sizing
- Image scales appropriately
Saved to
./screenshots/components-card--default_375x667.png
Smart Detection
Automatically detects Storybook version and API endpoints for compatibility across different Storybook setups.
Common Use Cases
Local Development
Connect to your local Storybook during development:
"Connect to my local Storybook at localhost:6006 and show me all components"
# Your Storybook running locally
npm run storybook # Usually runs on http://localhost:6006
Production Storybook
Analyze deployed component libraries:
"Check the Material UI Storybook at https://mui.com/storybook/ and show me their Button variants"
Visual Regression Testing
Compare component appearances across changes:
"Take screenshots of all Button stories in both desktop and mobile viewports"
Component Documentation
Extract prop types and usage examples:
"Generate a markdown table of all props for the DataGrid component with their types and default values"
Design System Audit
Review component library completeness:
"List all components and tell me which ones are missing accessibility features or documentation"
Cross-Browser Testing
Capture components in different states:
"Screenshot the Modal component in all its states: open, closed, loading, and error"
Installation
Using with Claude Desktop
-
Install the MCP server via npm:
npm install -g storybook-mcp-serverOr clone and build locally:
git clone https://github.com/stefanoamorelli/storybook-mcp-server.git cd storybook-mcp-server npm install npm run build -
Configure Claude Desktop: Add the following to your Claude Desktop MCP settings:
{ "mcpServers": { "storybook": { "command": "npx", "args": ["storybook-mcp-server"], "env": { "STORYBOOK_URL": "http://localhost:6006" } } } }Or if installed locally, use the full path:
{ "mcpServers": { "storybook": { "command": "node", "args": ["/path/to/storybook-mcp-server/dist/index.js"], "env": { "STORYBOOK_URL": "http://localhost:6006" } } } }
Prerequisites for Screenshots
If you want to use the screenshot functionality, Puppeteer requires Chrome/Chromium. When you first run the screenshot command, Puppeteer will automatically download a compatible version of Chromium.
Manual Chrome Installation (optional):
- macOS: Download from Google Chrome
- Linux:
# Ubuntu/Debian sudo apt-get update sudo apt-get install -y chromium-browser # Fedora sudo dnf install chromium - Windows: Download from Google Chrome
Note: Puppeteer will handle Chrome/Chromium automatically, so manual installation is typically not required.
Usage
Once configured in Claude Desktop, the MCP server will automatically connect to your Storybook instance. Make sure your Storybook is running before using the tools:
# Start your Storybook instance (in your project directory)
npm run storybook
# or
yarn storybook
Configuration Options
You can customize the server behavior through environment variables in your Claude Desktop MCP configuration:
Local Development Server:
{
"mcpServers": {
"storybook": {
"command": "npx",
"args": ["storybook-mcp-server"],
"env": {
"STORYBOOK_URL": "http://localhost:6006",
"OUTPUT_DIR": "./screenshots",
"LOG_LEVEL": "info"
}
}
}
}
Production Storybook:
{
"mcpServers": {
"storybook": {
"command": "npx",
"args": ["storybook-mcp-server"],
"env": {
"STORYBOOK_URL": "https://your-company.com/storybook",
"OUTPUT_DIR": "./screenshots/production",
"LOG_LEVEL": "info"
}
}
}
}
Public Component Library:
{
"mcpServers": {
"storybook": {
"command": "npx",
"args": ["storybook-mcp-server"],
"env": {
"STORYBOOK_URL": "https://storybookjs.netlify.app/vue-kitchen-sink",
"OUTPUT_DIR": "./screenshots/vue-components"
}
}
}
}
Command Line Options
--storybook-url,-url: URL of the Storybook instance (default: http://localhost:6006)--output-dir,-output: Directory to save screenshots (default: ./screenshots)--log-level: Logging level [error, warn, info, debug] (default: info)
MCP Tools
storybook_list_components
Lists all components available in the Storybook instance.
storybook_list_stories
Lists all stories, optionally filtered by component.
Parameters:
componentId(optional): Filter stories by component ID
storybook_get_story_details
Gets detailed information about a specific story.
Parameters:
storyId(required): The ID of the story
storybook_get_component_props
Gets the props/properties definition for a component.
Parameters:
componentId(required): The ID of the component
storybook_capture_screenshot
Captures a screenshot of a specific story.
Parameters:
storyId(required): The ID of the story to captureviewport(optional): Viewport dimensionswidth: Viewport width in pixelsheight: Viewport height in pixels
storybook_capture_all_screenshots
Captures screenshots of all stories.
Parameters:
viewport(optional): Viewport dimensionswidth: Viewport width in pixelsheight: Viewport height in pixels
Development
For contributors and developers working on this MCP server:
# Clone the repository
git clone https://github.com/anthropics/storybook-mcp-server.git
cd storybook-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode with hot reload
npm run dev
# Type checking
npm run type-check
# Linting
npm run lint
# Format code
npm run format
Architecture
The server is built with:
- TypeScript: For type safety and better developer experience
- MCP SDK: Official Model Context Protocol SDK for server implementation
- Puppeteer: For capturing screenshots of Storybook stories
- Axios: For HTTP communication with Storybook instance
- Winston: For structured logging
Requirements
- Node.js 18 or higher
- A running Storybook instance
- Chrome/Chromium (automatically downloaded by Puppeteer)
Troubleshooting
Screenshots not working?
- Ensure Puppeteer has downloaded Chromium: Run
npx puppeteer browsers install chrome - Check that your Storybook instance is running and accessible
- Verify the STORYBOOK_URL in your configuration matches your running instance
Connection issues?
- Verify your Storybook is running on the configured URL
- Check for any firewall or network restrictions
- Try accessing the Storybook URL directly in your browser
License
GNU Affero General Public License v3.0 (AGPL-3.0)
Copyright (C) 2024 Stefano Amorelli <stefano@amorelli.tech>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Commercial Licensing
For commercial use or if you need a different license, please contact stefano@amorelli.tech to discuss licensing options.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。