Storybook Addon
STREAMABLE HTTPOfficialStorybook MCP addon that automates UI component development with agent-generated stories
Storybook MCP addon that automates UI component development with agent-generated stories
Welcome to the Storybook MCP Addon monorepo! This project enables AI agents to work more efficiently with Storybook by providing an MCP (Model Context Protocol) server that exposes UI component information and development workflows.
This monorepo contains two main packages:
Each package has its own README with user-facing documentation. This document is for contributors looking to develop, test, or contribute to these packages.
.nvmrc)package.json)# Use the correct Node version nvm use # Install pnpm if you don't have it npm install -g [email protected]
# Clone the repository git clone https://github.com/storybookjs/mcp.git cd addon-mcp # Install all dependencies (for all packages in the monorepo) pnpm install
# Build all packages pnpm build # Start development mode (watches for changes in all packages) pnpm dev # Run unit tests pnpm test # Run Storybook with the addon for testing pnpm storybook
The pnpm storybook command starts:
http://localhost:6006http://localhost:6006/mcpThe dev command runs all packages in watch mode, automatically rebuilding when you make changes:
# Start development mode for all packages pnpm dev
This runs:
packages/addon-mcp in watch mode (using tsdown --watch)packages/mcp in watch mode (using Node's --watch flag)Note: Running pnpm storybook automatically starts the addon in dev mode alongside Storybook. In this mode, making changes to addon-mcp will automatically restart Storybook. So you typically only need one command:
# This is usually all you need - starts Storybook AND watches addon for changes pnpm storybook
For more advanced workflows, you can run dev mode for a specific package:
# Watch only the addon package pnpm --filter @storybook/addon-mcp dev # Watch only the mcp package pnpm --filter @storybook/mcp dev
# Build all packages pnpm build # Build a specific package pnpm --filter @storybook/addon-mcp build pnpm --filter @storybook/mcp build
# Watch tests pnpm test # Run tests pnpm test run # Run tests with coverage pnpm test run --coverage
Use the MCP Inspector to debug and test MCP server functionality:
# Launches the MCP inspector (requires Storybook to be running) pnpm inspect
This uses the configuration in .mcp.inspect.json to connect to your local MCP servers.
Alternatively, you can also use these curl comamnds to check that everything works:
# test that the mcp server is running # use port 6006 to test the addon-mcp server instead curl -X POST \ http://localhost:13316/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} }' # test a specific tool call curl -X POST http://localhost:13316/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "list-all-components", "arguments": {} } }'
You can start the Storybook with
pnpm storybook
This will build everything and start up Storybook with addon-mcp, and you can then connect your coding agent to it at http://localhost:6006/mcp and try it out.
# Format all files pnpm format # Check formatting without changing files pnpm format --check
Always include file extensions in relative imports:
// ✅ Correct import { foo } from './bar.ts'; // ❌ Wrong import { foo } from './bar';
import pkg from '../package.json' with { type: 'json' };
This project uses Changesets for version management:
# 1. Create a changeset describing your changes pnpm changeset
When you create a PR, add a changeset if your changes should trigger a release:
We welcome contributions! Here's how to get started:
pnpm build)pnpm test)pnpm format)pnpm changeset)MIT - See LICENSE for details
Note: This project is experimental and under active development. APIs and architecture may change as we explore the best ways to integrate AI agents with Storybook.