@viantotech/mcp-storybook
This server lets AI agents explore and use a deployed Storybook through MCP tools.
List, search, and fetch stories (full content, sections, metadata, concise context).
List and fetch components with docs overview and variant IDs.
Get component configs (argTypes, controls, style presets) and copy-paste usage code (import + JSX).
Extract design tokens (colors, spacing, typography, etc.) from CSS variables.
Analyze component dependency graphs and reverse-lookup stories by source file.
Map Figma components/URLs to Storybook components with suggested props.
Build Storybook iframe preview URLs with args, globals, and viewport.
Get CSF3 story authoring instructions.
Compare two Storybook deployments for structured diffs.
Provides tools for browsing, searching, and retrieving Storybook component library content, including story metadata, full story content, sections, component details, and component configuration from a Storybook deployment.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@@viantotech/mcp-storybook list all components in the design system"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@viantotech/mcp-storybook
A Model Context Protocol server that gives AI agents (Claude, Cursor, and any MCP client) structured access to a deployed Storybook — including private, authenticated ones.
Agents can browse and search components, read docs and prop contracts, pull design tokens, generate correct usage code, and — new in v0.5 — check their own UI code against the design system before you ever see it.
Contents
Related MCP server: Storybook MCP
Why
AI coding agents are good at writing UI and bad at knowing your UI. Without context they:
rebuild a
<div>-based button when<Button>already exists,invent props and values (
<Button kind="danger">when the prop isvariant="destructive"),hardcode
#1a73e8instead ofvar(--color-primary).
This server turns your Storybook into the agent's source of truth: what exists, how to import it, which props are valid, and which tokens to use.
Features
Area | What you get |
Browse & search | List and full-text search stories and components, read docs sections, get concise context for natural-language questions |
Component contracts | argTypes (props, controls, options), style presets, dependency graph, copy-paste usage code |
Design tokens | CSS custom properties extracted and categorized (colors, spacing, typography, radius, shadows, …) |
Usage guardrails | Token-cheap catalog for "check before you build", and deterministic validation of agent-written JSX |
Token drift | Find hardcoded colors/lengths that should be tokens, with |
Story scaffolding | Generate CSF3 stories for new components in your house style |
Local memory | Components created by agents are visible to other tools before Storybook is redeployed |
Figma & previews | Map Figma components to Storybook, build iframe preview URLs with args/globals/viewport |
Versioning | Structured diff between two Storybook deployments |
Auth |
|
Requirements: Node.js ≥ 20, a deployed Storybook 8 (static build). Storybook is read-only: the server never writes to your deployment.
Quick start
Run without installing:
STORYBOOK_BASE_URL=https://your-storybook.example.com npx -y @viantotech/mcp-storybookOr install globally:
npm install -g @viantotech/mcp-storybook
mcp-storybookThe server speaks MCP over stdio, so you normally don't run it by hand — your MCP client starts it. See below.
Client configuration
Claude Code
claude mcp add storybook \
-e STORYBOOK_BASE_URL=https://your-storybook.example.com \
-- npx -y @viantotech/mcp-storybookClaude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"storybook": {
"command": "npx",
"args": ["-y", "@viantotech/mcp-storybook"],
"env": {
"STORYBOOK_BASE_URL": "https://your-storybook.example.com"
}
}
}
}Cursor
Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global) — same shape as above.
Authentication examples
"env": {
"STORYBOOK_BASE_URL": "https://your-storybook.example.com",
"STORYBOOK_AUTH_TYPE": "basic",
"STORYBOOK_BASIC_AUTH_USERNAME": "your-username",
"STORYBOOK_BASIC_AUTH_PASSWORD": "your-password"
}"env": {
"STORYBOOK_BASE_URL": "https://your-storybook.example.com",
"STORYBOOK_AUTH_TYPE": "bearer",
"STORYBOOK_ACCESS_TOKEN": "your-token"
}"env": {
"STORYBOOK_BASE_URL": "https://your-storybook.example.com",
"STORYBOOK_AUTH_TYPE": "cookie",
"STORYBOOK_SESSION_COOKIE": "session=abc123"
}"env": {
"STORYBOOK_BASE_URL": "https://your-storybook.example.com",
"STORYBOOK_AUTH_TYPE": "oauth",
"STORYBOOK_CLIENT_ID": "your-client-id",
"STORYBOOK_CLIENT_SECRET": "your-client-secret",
"STORYBOOK_REFRESH_TOKEN": "your-refresh-token"
}Docker
docker build -t mcp-storybook .
docker run --rm -i -e STORYBOOK_BASE_URL=https://your-storybook.example.com mcp-storybookUse -i (stdin open) — the server communicates over stdio.
Configuration reference
All configuration is via environment variables.
Connection
Variable | Default | Description |
| — (required) | URL of the deployed Storybook. Must be |
|
|
|
|
| Per-request timeout |
|
| Maximum response size (5 MB) |
|
| Retries for transient upstream failures (0–10) |
Authentication
Variable | Required when | Description |
| — |
|
|
| Username |
|
| Password |
|
| Bearer token |
|
| Cookie header value |
|
| OAuth client ID |
|
| OAuth client secret |
| — | OAuth refresh token |
Caching
Variable | Default | Description |
|
| In-memory cache for index, chunks, and tokens |
|
| Cache TTL in seconds |
Features
Variable | Default | Description |
| — | Path to a JSON file with explicit Figma → Storybook component mappings |
|
| Local pending-component memory file (relative to the server's working directory), or |
|
| Age after which a pending component is flagged |
REST API mode (advanced)
Only used when STORYBOOK_DATA_SOURCE=rest-api or auto-detection falls back.
Variable | Description |
| Path to an API discovery document |
| Override endpoint for listing stories |
| Override endpoint for a single story |
| Override endpoint for search |
Tools
24 tools, grouped by purpose. All return JSON text.
Stories
Tool | Inputs | Description |
|
| List stories, metadata only |
|
| Full-text search over title, description, tags, sections, content |
|
| Full story content, optionally capped |
|
| One section of a story |
|
| Metadata without body |
|
| Concise context for a natural-language question |
Components
Tool | Inputs | Description |
|
| Components grouped from story titles (e.g. |
|
| Docs overview, sections, variant story IDs |
|
| argTypes (controls, options, descriptions) and style presets with args |
|
| Copy-paste import + JSX built from story presets |
|
| Which components it uses / is used by |
|
| Reverse lookup: source path → stories |
Design tokens
Tool | Inputs | Description |
|
| CSS custom properties, categorized: |
|
| Hardcoded literals that match token values |
Usage guardrails
Tool | Inputs | Description |
|
| Compact catalog: name, import, short description, key props. Includes pending components |
|
| Validate JSX/TSX against argTypes |
Authoring & memory
Tool | Inputs | Description |
| — | Opinionated CSF3 authoring guide |
|
| Generate a CSF3 story in house style; also remembers the component |
|
| Record a not-yet-deployed component |
| — | Remembered components; deployed ones are dropped, old ones flagged |
|
| Remove from memory |
Integration
Tool | Inputs | Description |
|
| Storybook iframe URL with encoded args/globals |
|
| Matching Storybook component and suggested props |
|
| Diff two deployments: added/removed components, variant and argType changes |
Guardrail details
Issue kind | Example | Notes |
|
| Suggests closest name |
|
| Suggests closest declared prop |
|
| Lists allowed enum values |
|
| String passed to a boolean prop |
|
| Pending components only (Storybook argTypes don't record required-ness) |
Not flagged: dynamic expressions (variant={v}), spread props, standard attributes (className, style, id, aria-*, data-*, on* handlers, …). Components without argTypes are listed under unvalidated instead of producing errors.
Example response:
{
"valid": false,
"issues": [
{
"component": "Button",
"line": 3,
"kind": "invalid_value",
"message": "variant=\"danger\" not allowed. Allowed: primary | secondary | destructive",
"suggestion": "variant=\"destructive\""
}
],
"unvalidated": []
}Colors: hex (3/4/6/8 digits),
rgb()/rgba(),hsl()/hsla()are normalized, sorgb(26,115,232)matches a token of#1A73E8.Lengths:
pxandrem(remBase, default 16) are compared in px. Matched againstspacing,radius, andtypographytokens.0is ignored.Token aliases:
--color-primary: var(--blue-500)is resolved; all tokens with the same value are returned (token+alternatives).Near matches: off by default.
toleranceis ΔE (CIE76) for colors and px for lengths. Treat near matches as hints.Literals already inside
var(...)are skipped.
Props are read from an interface or type named <Component>Props (falls back to the first *Props declaration).
Prop type | Generated argType |
|
|
|
|
|
|
function |
|
other | none, with a warning |
Title prefix, tags: ["autodocs"], and decorators are copied from referenceComponent, or inferred from the most common pattern in the index. The tool returns file content only; write it to disk yourself.
New components only reach Storybook after a rebuild and redeploy. Until then, remember_component (called implicitly by scaffold_story) stores them in STORYBOOK_LOCAL_MEMORY. get_catalog_summary and validate_usage merge them in with source: "pending".
Entries are removed automatically once a component with the same name appears in the deployed Storybook.
Entries older than
STORYBOOK_LOCAL_MEMORY_STALE_DAYSare flaggedstale, not deleted.The file is per working directory. Commit it to share with your team, or keep it in
.gitignore.Set
STORYBOOK_LOCAL_MEMORY=offto disable the memory tools entirely.
Recommended agent workflow
Add something like this to your CLAUDE.md, .cursorrules, or agent instructions:
When writing UI code:
1. Call `get_catalog_summary` first. Reuse existing components; don't build new ones that duplicate them.
2. Use `get_component_usage` or `get_component_config` for the components you pick.
3. After writing JSX, call `validate_usage` on it and fix every issue.
4. Run `find_token_drift` on new styles and replace hardcoded values with tokens.
5. If you created a new component, call `scaffold_story` and save the returned story file.Resources
URI | Description |
| All stories |
| A single story |
| A single section |
How it works
MCP client (Claude, Cursor, …)
│ stdio
▼
mcp-storybook ──► tools / resources
│
├─ services (component, usage, tokens, catalog, validation, drift, scaffold, memory, …)
├─ repository (storybook-static | rest-api) ── in-memory cache
└─ HTTP client + auth provider ──► your Storybook deployment
/index.json, /assets/*, /iframe.html, CSS
local file (optional): .storybook-mcp/memory.jsonStatic mode reads Storybook 8's
/index.json, then fetches story chunks from/assets/*to extract argTypes, presets, docs, and dependencies.Design tokens come from stylesheets linked in
/iframe.html.JSX and TypeScript are parsed with
@babel/parser; no code is executed.
Security
The Storybook deployment is never modified. The only write is the optional local memory file.
Credentials are read from environment variables only; credentials embedded in
STORYBOOK_BASE_URLare rejected.Logs go to stderr and drop fields that look sensitive (authorization, cookies, tokens, passwords, secrets).
Responses are size-limited (
STORYBOOK_MAX_RESPONSE_BYTES) and requests time out (STORYBOOK_REQUEST_TIMEOUT_MS).compare_versionsreuses the configured auth when onlybaseUrlis given — only point it at deployments you trust with those credentials.
Troubleshooting
Symptom | Likely cause / fix |
| Missing required env var for the chosen |
| Wrong or expired credentials; for cookie auth, refresh the session cookie |
| Using REST mode. Set |
| No stylesheets with CSS custom properties in |
| It loads every component's config once; later calls hit the cache ( |
| It has no argTypes; check the |
Agent never calls the guardrail tools | Add the recommended workflow to your agent instructions |
Development
git clone https://github.com/viantonugroho11/mcp-story-books.git
cd mcp-story-books
npm installCommand | Description |
| Run from source with |
| Compile to |
| Run tests (Vitest) |
| Type-check without emitting |
| Probe a Storybook deployment's API |
Test locally with the MCP Inspector:
npx @modelcontextprotocol/inspector -e STORYBOOK_BASE_URL=https://your-storybook.example.com -- npx tsx src/index.tsProject layout:
src/
├── api/ HTTP client
├── auth/ auth providers
├── config/ env parsing (zod)
├── mcp/ server, tool + resource registration, input schemas
├── repository/ storybook-static and rest-api data sources
├── services/ one service per feature
└── storybook/ parsers: CSF config, tokens, dependencies, JSX/TS, value normalization
docs/adr/ architecture decision recordsArchitecture decisions
Design rationale lives in docs/adr/, including features that were deliberately rejected and how this server compares to the official Storybook MCP.
Changelog
See CHANGELOG.md.
License
Available Tools
24 toolscompare_versionsB
Compare two Storybook deployments and return structured diff (added/removed/modified components, prop changes).
Inputs: baseUrl (required), targetUrl, components.
find_stories_by_source_fileA
Reverse lookup: given a component source file path, find matching Storybook stories.
Inputs: sourceFile (required).
find_token_driftB
Find hardcoded colors, spacing, radius, and font sizes in CSS/JSX that match design tokens, with var(--token) replacements. Near matches (tolerance > 0) are hints only.
Inputs: code (required), remBase, filename, tolerance, +1 more.
forget_componentB
Remove a component from local pending-component memory.
Inputs: componentName (required).
get_catalog_summaryA
Call BEFORE writing any UI code: compact catalog of every design-system component (name, import, short description, key props). Use it to reuse existing components instead of building new ones. Entries marked source=pending exist in code but are not in Storybook yet.
Inputs: category, maxDescriptionLength.
get_componentB
Get one component by name or path (Alert, Components/Alert). Includes docs overview and story variant ids.
Inputs: component (required), maxContentLength, includeOverviewContent.
get_component_configA
Storybook Controls config per component: argTypes (variant, size, …) and stylePresets (Default, Secondary, …) with args.
Inputs: component (required).
get_component_dependenciesB
Get component dependency graph: which components a component uses, and which components use it.
Inputs: componentName (required), depth, direction.
get_component_usageB
Get copy-paste-ready component usage code (import + JSX) built from story argTypes and preset args.
Inputs: componentName (required), format, variant.
get_design_tokensA
Extract design tokens (colors, spacing, typography, shadows, etc.) from Storybook CSS variables.
Inputs: category.
get_storyB
Get a full story with optional content length cap.
Inputs: storyId (required), maxContentLength.
get_story_contextB
Retrieve concise Story Book context for a natural-language question.
Inputs: query (required), storyId, maxResults.
get_story_instructionsA
Get best-practice instructions for writing Storybook stories (CSF3, argTypes, play functions).
Inputs: no named parameters.
get_story_metadataB
Get story metadata without loading full content.
Inputs: storyId (required).
get_story_sectionC
Get one section from a story.
Inputs: storyId (required), sectionId (required).
list_componentsB
List UI components from Storybook (grouped), e.g. Components/Button, Components/Alert. Metadata only.
Inputs: limit, query, offset, category.
list_pending_componentsA
List locally remembered components not yet in the deployed Storybook. Entries now present in Storybook are dropped automatically; old entries are flagged stale.
Inputs: no named parameters.
list_storiesC
List Story Book entries (metadata only, no full content).
Inputs: tags, limit, query, offset, +1 more.
map_figma_componentA
Map a Figma component name/node/URL to the corresponding Storybook component with suggested props.
Inputs: figmaUrl, figmaName, figmaNodeId.
preview_storyB
Build a Storybook iframe preview URL for a story with optional args, globals, and viewport.
Inputs: storyId (required), args, globals, viewport.
remember_componentA
Record a component that exists in code but is not yet in the deployed Storybook, so catalog and validation tools include it. Stored in a local file only.
Inputs: import (required), description (required), componentName (required), sourcePath, +1 more.
scaffold_storyA
Call after creating a new component: generates a CSF3 *.stories.tsx file that follows this Storybook's conventions, and remembers the component locally so other tools see it before Storybook is redeployed. Returns file content only; write it yourself.
Inputs: componentName (required), componentSource (required), title, importPath, +2 more.
search_storiesB
Search stories by title, description, tags, sections, and content.
Inputs: query (required), limit.
validate_usageA
Call AFTER writing JSX/TSX that uses design-system components: checks component names, props, and enum values against Storybook argTypes and reports invalid usage with suggestions.
Inputs: code (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 24 tools
Most tools have clearly distinct purposes (catalog, validation, story retrieval, token analysis, pending memory) and descriptions give usage timing. However, get_catalog_summary vs list_components and several story-context tools overlap enough that an agent may need to read descriptions carefully to choose correctly.
All tool names use lower snake_case and predictable verb_noun patterns (get_component, list_stories, validate_usage, scaffold_story). No mixed conventions.
24 tools is on the heavy end for a single MCP server; while the domain is broad, several read-only listing/context tools could be consolidated. The rubric treats 16-25 tools as borderline heavy.
Surface covers catalog, components, stories, tokens, validation, version diffing, Figma mapping, and pending component memory, which is extensive. Minor gaps remain around direct story update/delete or component source retrieval, but core workflows are supported.
Maintenance
Related MCP Connectors
Search your team's Storybook components by text or image, so agents reuse what exists.
Software component catalog: search your org's services, docs, APIs, dependencies, and ownership.
Find UI components and themes, retrieve code, and generate with hosted 21st AI when enabled.
Access and maintain design system docs, tokens, components, skills, and contexts across any project.
Related MCP Servers
- AlicenseAqualityBmaintenanceServer that enables AI assistants to interact with Storybook design systems. Extract component HTML, analyze styles, and help with design system adoption and refactoring.9424 npm73MIT

Storybook MCPofficial
AlicenseNot gradedqualityFmaintenanceEnables AI agents to interact with Storybook by exposing UI component information and development workflows through the Model Context Protocol.272MIT- AlicenseAqualityDmaintenanceIntegrates with a running Storybook instance to let AI-powered coding tools browse, inspect, and scaffold components from natural language.4MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to search, understand, and generate code for design system components by syncing and indexing a component library.ISC