Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
36a9e1d
add e2e tests
JReinhold Nov 18, 2025
310f3a1
improve e2e scripting
JReinhold Nov 19, 2025
c153b93
add tests for mcp index
JReinhold Nov 19, 2025
f3a467f
add preset tests
JReinhold Nov 19, 2025
d67a038
add telemetry tests
JReinhold Nov 19, 2025
c807fe7
simplify tool test mocks
JReinhold Nov 19, 2025
61baa0f
simplify mcp-handler tests, improve disableTelemetry handling
JReinhold Nov 19, 2025
e01da53
add tests for manifest availability
JReinhold Nov 19, 2025
1d4fbfd
exclude evals from coverage
JReinhold Nov 19, 2025
1cc6bbd
cleanup
JReinhold Nov 19, 2025
23daa64
changeset
JReinhold Nov 19, 2025
54d5157
Merge branch 'next' of https://github.com/storybookjs/mcp into improv…
JReinhold Nov 19, 2025
ba47326
fix preset registering handlers instead of middlewares
JReinhold Nov 19, 2025
35859a4
update tests to match changes in base branch
JReinhold Nov 19, 2025
f38a3bf
cleanup
JReinhold Nov 19, 2025
85c6076
await sb process kill
JReinhold Nov 19, 2025
d615a8d
refactor formatter, splitting into markdown and xml, configurable, de…
JReinhold Nov 19, 2025
02e2914
globally mock storybook deps
JReinhold Nov 19, 2025
6f01bc6
clean lock file
JReinhold Nov 19, 2025
4d1c0c2
Merge branch 'next' of https://github.com/storybookjs/mcp into improv…
JReinhold Nov 19, 2025
716e1f3
Merge branch 'improve-test-coverage' of https://github.com/storybookj…
JReinhold Nov 19, 2025
58e0a75
fix context arg
JReinhold Nov 19, 2025
920dea2
fix tests
JReinhold Nov 19, 2025
26a9874
fix types
JReinhold Nov 19, 2025
ca77d82
"Examples" -> "Stories", simplify tests
JReinhold Nov 19, 2025
d6065b5
simplify tests and types
JReinhold Nov 19, 2025
18a51dd
simplify
JReinhold Nov 20, 2025
c7150af
use ts-like prop type docs format
JReinhold Nov 20, 2025
80a488e
add script to clean experiments
JReinhold Nov 20, 2025
7ed1dfd
add changeset
JReinhold Nov 20, 2025
8cf05b5
Merge branch 'next' of https://github.com/storybookjs/mcp into markdo…
JReinhold Nov 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/plain-hands-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@storybook/addon-mcp': patch
---

improve handling of disableTelemetry option
31 changes: 27 additions & 4 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ The addon supports configuring which toolsets are enabled:
toolsets: {
dev: true, // get-story-urls, get-ui-building-instructions
docs: true, // list-all-components, get-component-documentation
}
},
experimentalFormat: 'markdown' // Output format: 'markdown' (default) or 'xml'
}
}
```
Expand Down Expand Up @@ -73,6 +74,11 @@ The `@storybook/mcp` package (in `packages/mcp`) is framework-agnostic:
- `onSessionInitialize`: Called when an MCP session is initialized
- `onListAllComponents`: Called when the list-all-components tool is invoked
- `onGetComponentDocumentation`: Called when the get-component-documentation tool is invoked
- **Output Format**: The `format` property in context controls output format:
- `'markdown'` (default): Token-efficient markdown with adaptive formatting
- `'xml'`: Legacy XML format
- Format is configurable via addon options or directly in `StorybookContext`
- Formatters are implemented in `packages/mcp/src/utils/manifest-formatter/` with separate files for XML and markdown

## Development Environment

Expand All @@ -95,9 +101,26 @@ The `@storybook/mcp` package (in `packages/mcp`) is framework-agnostic:

**Testing:**

- Only `packages/mcp` has tests (Vitest with coverage)
- Run `pnpm test run --coverage` in mcp package
- Prefer TDD when adding new tools
- **Unit tests**: Both `packages/mcp` and `packages/addon-mcp` have unit tests (Vitest with coverage)
- Run `pnpm test run --coverage` in individual package directories
- Run `pnpm test:run` at root to run all unit tests
- Prefer TDD when adding new tools
- **E2E tests**: `apps/internal-storybook/tests` contains E2E tests for the addon
- Run `pnpm test` in `apps/internal-storybook` directory
- Tests verify MCP endpoint works with latest Storybook prereleases
- Uses inline snapshots for response validation
- **When to update E2E tests**:
- Adding or modifying MCP tools (update tool discovery snapshots)
- Changing MCP protocol implementation (update session init tests)
- Modifying tool responses or schemas (update tool-specific tests)
- Adding new toolsets or changing toolset behavior (update filtering tests)
- **Running tests**:
- `pnpm test` in apps/internal-storybook - run E2E tests
- `pnpm vitest run -u` - update snapshots when responses change
- Tests start Storybook server automatically, wait for MCP endpoint, then run
- **Test structure**:
- `mcp-endpoint.e2e.test.ts` - MCP protocol and tool tests
- `check-deps.e2e.test.ts` - Storybook version validation

**Type checking:**

Expand Down
1 change: 0 additions & 1 deletion .github/instructions/addon-mcp.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ This addon implements MCP using `tmcp`:

- `storybook` - Peer dependency (Storybook framework)
- `valibot` - Schema validation for tool inputs/outputs
- `ts-dedent` - Template string formatting
- `tsdown` - Build tool (rolldown-based)
- `vite` - Peer dependency for middleware injection

Expand Down
2 changes: 2 additions & 0 deletions apps/internal-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build-storybook": "storybook build",
"storybook": "storybook dev --port 6006 --loglevel debug --no-open",
"test": "cd ../.. && pnpm vitest --project=e2e",
"typecheck": "tsc"
},
"devDependencies": {
Expand All @@ -18,6 +19,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "catalog:",
"tinyexec": "^1.0.2",
"vite": "catalog:"
}
}
55 changes: 55 additions & 0 deletions apps/internal-storybook/tests/check-deps.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { describe, it } from 'vitest';
import { x } from 'tinyexec';

const PACKAGES_TO_CHECK = [
'@storybook/addon-docs',
'@storybook/react-vite',
'storybook',
];

describe('Storybook Dependencies', () => {
it('should be using latest versions from registry', async () => {
const outdated: Array<{ pkg: string; current: string; latest: string }> =
[];

for (const pkg of PACKAGES_TO_CHECK) {
// Get local version
const listResult = await x('pnpm', ['list', pkg, '--json'], {
nodeOptions: { cwd: process.cwd() },
});
const listData = JSON.parse(listResult.stdout);
const currentVersion =
listData[0]?.devDependencies?.[pkg]?.version ||
listData[0]?.dependencies?.[pkg]?.version;

if (!currentVersion) {
continue;
}

// Get registry version for @next tag
const viewResult = await x('pnpm', ['view', `${pkg}@next`, 'version'], {
nodeOptions: { cwd: process.cwd() },
});
const latestVersion = viewResult.stdout.trim();

// Compare versions
if (currentVersion !== latestVersion) {
outdated.push({ pkg, current: currentVersion, latest: latestVersion });
}
}

// If there are outdated packages, fail the test with instructions
if (outdated.length > 0) {
const outdatedList = outdated
.map(({ pkg, current, latest }) => ` - ${pkg}: ${current} → ${latest}`)
.join('\n');

const currentVersion = outdated[0]!.current.replace(/\./g, '\\.');
const latestVersion = outdated[0]!.latest;

throw new Error(
`Storybook dependencies are outdated. Update the catalog in pnpm-workspace.yaml:\n\n sed -i '' 's/${currentVersion}/${latestVersion}/g' pnpm-workspace.yaml && pnpm install\n\nOutdated packages:\n${outdatedList}`,
);
}
});
});
Loading
Loading