AI-powered Storybook story generator for any JavaScript framework and design system
Story UI generates working Storybook stories from natural language. Describe what you want, and the AI writes production-ready story code using your design system's actual components. Works with any framework and any component library.
# Install Story UI
npm install -D @tpitre/story-ui
# Initialize in your project
npx story-ui init
# Start generating stories
npm run story-ui
Story UI will guide you through:
Describe what you want in natural language. Story UI generates complete, working Storybook stories using your design system's components with proper imports, props, and TypeScript types.
When generated code has syntax errors, invalid imports, or forbidden patterns, Story UI automatically:
A live playground mode where you speak component ideas and see them rendered instantly in Storybook. Uses browser speech recognition with auto-submit, pauses during generation, and renders output through an iframe with react-live.
Continue the conversation to refine generated stories. Story UI preserves context and modifies only what you request.
Attach screenshots or mockups to your prompt. The AI uses them as reference when generating components.
| Framework | Design Systems | Status |
|---|---|---|
| React | Mantine, Chakra UI, Material UI, shadcn/ui, Custom | Fully Supported |
| Vue | Vuetify, Custom | Fully Supported |
| Angular | Angular Material, Custom | Fully Supported |
| Svelte | Flowbite-Svelte, Custom | Fully Supported |
| Web Components | Shoelace, Custom | Fully Supported |
| Provider | Models | Default |
|---|---|---|
| Claude (Anthropic) | Claude Opus 4.6, Claude Sonnet 4.6, Claude Haiku 4.5 | claude-sonnet-4-6 |
| GPT (OpenAI) | GPT-5.4, GPT-5.4 Mini, o4 Mini | gpt-5.4 |
| Gemini (Google) | Gemini 3.1 Pro Preview, Gemini 3 Flash Preview, Gemini 2.5 Flash | gemini-3.1-pro-preview |
npx story-ui init
The installer prompts for:
Create story-ui.config.js in your project root:
module.exports = {
// Framework: 'react' | 'vue' | 'angular' | 'svelte' | 'web-components'
componentFramework: 'react',
// Component library import path
importPath: '@mantine/core',
// Generated stories location
generatedStoriesPath: './src/stories/generated/',
// LLM provider: 'claude' | 'openai' | 'gemini'
llmProvider: 'claude',
// Import style: 'barrel' (default) or 'individual'
// Use 'individual' for libraries without barrel exports (shadcn/ui, Radix Vue, Angular Material)
// Use 'barrel' for libraries with index.ts barrel exports (Mantine, Chakra, Vuetify)
importStyle: 'barrel',
// Story configuration
storyPrefix: 'Generated/',
defaultAuthor: 'Story UI AI',
// Layout rules for multi-component compositions
layoutRules: {
multiColumnWrapper: 'SimpleGrid',
columnComponent: 'div',
containerComponent: 'Container',
},
};
For component libraries with non-standard import paths, use importExamples to teach the AI your patterns:
module.exports = {
framework: 'web-components',
importPath: '../../../components',
importExamples: [
"import '../../../components/button/button'; // For <my-button>",
"import '../../../components/card/card'; // For <my-card>",
],
};
Start the Story UI server:
npm run story-ui
Open Storybook and navigate to the Story UI panel. Describe what you want:
Create a product card with image, title, price, and add to cart button
Story UI generates a complete .stories.tsx file using your design system's components, writes it to your generated stories directory, and Storybook picks it up automatically via file watcher.
Continue the conversation to refine:
Make the button green and add a quantity selector
Story UI modifies only what you requested, preserving the rest of the story.
Switch to Voice Canvas mode in the panel header. Speak your component ideas and see them rendered live. The canvas uses react-live for instant rendering without page reloads.
Story UI can connect to Storybook MCP (@storybook/addon-mcp) to fetch component documentation, UI building guidelines, and existing story patterns. This enhances generation quality by ensuring output matches your codebase.
@storybook/addon-mcp and enable experimentalComponentsManifest in .storybook/main.js:export default {
features: {
experimentalComponentsManifest: true,
},
addons: [
'@storybook/addon-mcp',
// ... other addons
],
};
story-ui.config.js:module.exports = {
// ... other config
storybookMcpUrl: 'http://localhost:6006',
storybookMcpTimeout: 5000,
};
When both Story UI and Storybook are running, context is fetched automatically during generation, resulting in more accurate component usage and consistent code style.
Story UI includes a Model Context Protocol (MCP) server for direct integration with AI clients like Claude Desktop and Claude Code.
/mcp-remote/mcp# Production deployment
claude mcp add --transport http story-ui https://your-app.up.railway.app/mcp-remote/mcp
# Local development
claude mcp add --transport http story-ui-local http://localhost:4001/mcp-remote/mcp
Once connected, these tools are available in Claude conversations:
generate-story — Generate Storybook stories from natural languagelist-components — Discover available componentslist-stories — View existing generated storiesget-story / update-story / delete-story — Manage storiesget-component-props — Get component property informationtest-connection — Verify MCP connectionFor Claude Desktop local integration without a deployed server:
{
"mcpServers": {
"story-ui": {
"command": "npx",
"args": ["@tpitre/story-ui", "mcp"]
}
}
}
This requires the HTTP server running on port 4001 (npm run story-ui).
Story UI can be deployed as a standalone web application. Railway is recommended for its simplicity.
npm install -g @railway/cli
railway login
railway init
railway up
Environment Variables:
ANTHROPIC_API_KEY — Required for Claude modelsOPENAI_API_KEY — Optional, for OpenAI modelsGEMINI_API_KEY — Optional, for Gemini modelsSTORYBOOK_PROXY_ENABLED — Enable Storybook proxy mode for live demosSTORYBOOK_PROXY_PORT — Internal Storybook port (default: 6006)See DEPLOYMENT.md for detailed instructions and troubleshooting.
Story UI reads your design system guidelines before every generation to produce better output.
Create a story-ui-docs/ directory with guidelines, tokens, and component documentation:
story-ui-docs/
├── guidelines/
│ ├── accessibility.md
│ └── responsive-design.md
├── tokens/
│ ├── colors.json
│ └── spacing.md
└── components/
├── button.md
└── forms.md
For simpler setups, create story-ui-considerations.md in your project root with design system rules, color usage, and component preferences.
npx story-ui init # Initialize Story UI in your project
npx story-ui start # Start the MCP server (default port: 4001)
npx story-ui mcp # Start STDIO MCP server for Claude Desktop
npx story-ui status # Check installation status and version
npx story-ui update # Update Story UI files to latest version
# .env
LLM_PROVIDER=claude
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-... # optional
GEMINI_API_KEY=... # optional
VITE_STORY_UI_PORT=4001
| Method | Endpoint | Description |
|---|---|---|
POST |
/mcp/generate-story |
Generate story from prompt |
POST |
/mcp/generate-story-stream |
Streaming story generation |
POST |
/mcp/canvas-generate |
Generate + write voice canvas story |
POST |
/mcp/canvas-save |
Save canvas to named story file |
| Method | Endpoint | Description |
|---|---|---|
GET |
/mcp/components |
List discovered components |
GET |
/mcp/props |
Get component props |
GET |
/mcp/frameworks |
List supported frameworks |
GET |
/mcp/frameworks/detect |
Detect current project framework |
| Method | Endpoint | Description |
|---|---|---|
GET |
/mcp/stories |
List generated stories |
GET |
/mcp/stories/:storyId |
Get a specific story |
GET |
/mcp/stories/:storyId/content |
Get story file content |
DELETE |
/mcp/stories/:storyId |
Delete a story |
| Method | Endpoint | Description |
|---|---|---|
GET |
/mcp/providers |
List available LLM providers |
GET |
/mcp/providers/models |
List models per provider |
POST |
/mcp/providers/configure |
Configure a provider |
POST |
/mcp/providers/validate |
Validate an API key |
POST |
/mcp/providers/model |
Set active model |
| Method | Endpoint | Description |
|---|---|---|
GET |
/story-ui/manifest |
Get story manifest |
GET |
/story-ui/manifest/poll |
Poll for manifest changes |
POST |
/story-ui/manifest/reconcile |
Reconcile manifest with filesystem |
DELETE |
/story-ui/manifest/:fileName |
Remove entry from manifest |
All endpoints are also available under the /story-ui/ prefix.
{
prompt: string; // User's request
provider?: string; // 'claude' | 'openai' | 'gemini'
model?: string; // Specific model ID
previousCode?: string; // For iterations
history?: Message[]; // Conversation history
imageData?: string; // Base64 image for vision
}
We welcome contributions! See our Contributing Guide.
git clone https://github.com/southleft/story-ui.git
cd story-ui
npm install
npm run build
# Test in a consumer project (important: run from the consumer directory)
cd /path/to/your-storybook-project
PORT=4001 node /path/to/story-ui/dist/mcp-server/index.js
MIT - Story UI Contributors