Skip to content

Commit 5512ad2

Browse files
committed
Merge branch 'next' of https://github.com/storybookjs/mcp into single-component-doc
2 parents c052778 + cf4ef86 commit 5512ad2

40 files changed

Lines changed: 1263 additions & 2377 deletions

.changeset/sour-colts-retire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@storybook/addon-mcp': patch
3+
---
4+
5+
Handle GET responses in the MCP server

.github/actions/setup-node-and-install/action.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
name: 'Setup Node.js and Dependencies'
2-
description: 'Sets up Node.js, caches and installs dependencies'
2+
description: 'Sets up Node.js, caches, installs dependencies and turbo cache'
33

44
runs:
55
using: 'composite'
66
steps:
7-
- name: Setup Node.js
8-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
9-
with:
10-
node-version-file: '.nvmrc'
11-
127
- name: Install pnpm
138
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
149

15-
- name: Setup Node.js
10+
- name: Use Node.js 24
1611
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
1712
with:
18-
node-version: 24
19-
cache: 'pnpm'
13+
cache: pnpm
14+
node-version-file: '.nvmrc'
15+
16+
- name: Cache for Turbo
17+
uses: rharkor/caching-for-turbo@2b4b5b14a8d16b8556a58993a8ac331d56d8906d # v2.3.2
2018

2119
- name: Install dependencies
2220
shell: bash

.github/instructions/addon-mcp.instructions.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,24 @@ Launches the MCP inspector for debugging the addon's MCP server using the config
149149

150150
### Testing
151151

152-
The addon has comprehensive unit tests covering all utilities and tools:
152+
The addon has comprehensive unit tests covering all utilities and tools. Tests can be run at the package level or from the monorepo root:
153153

154154
```bash
155+
# From the package directory
155156
pnpm test # Run tests in watch mode
156157
pnpm test run # Run tests once
157158
pnpm test run --coverage # Run tests with coverage report
159+
160+
# From the monorepo root (runs tests across all packages)
161+
pnpm test # Run all tests in watch mode
162+
pnpm test:run # Run all tests once
163+
pnpm test:ci # Run tests with coverage and CI reporters
158164
```
159165

160166
**Test Infrastructure:**
161167

162-
- **Framework**: Vitest 3.2.4 with @vitest/coverage-v8
168+
- **Framework**: Vitest with @vitest/coverage-v8
169+
- **Configuration**: Root-level vitest.config.ts with per-package projects
163170
- **Fixtures**: JSON fixtures in `fixtures/` directory for story index data
164171

165172
**Test Coverage Baseline:**
@@ -212,11 +219,11 @@ When adding new functionality:
212219
3. Mock external dependencies (fetch, logger, telemetry)
213220
4. Use fixtures for complex data structures
214221
5. Test both success and error paths
215-
6. Run `pnpm test run --coverage` to verify coverage
222+
6. Run `pnpm test run --coverage` (from package) or `pnpm test:ci` (from root) to verify coverage
216223

217224
**CI Integration:**
218225

219-
Tests run automatically on PRs and main branch pushes via `.github/workflows/check.yml` as the `test-addon-mcp` job.
226+
Tests run automatically on PRs and main branch pushes via `.github/workflows/check.yml` in the `test` job, which runs `pnpm turbo run test:ci` across all packages.
220227

221228
## Code Style and Conventions
222229

.github/instructions/mcp.instructions.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,23 @@ Formats code using prettier.
118118
To check formatting without applying changes:
119119

120120
```bash
121-
pnpm format --check
121+
pnpm format:check
122122
```
123123

124124
### Testing
125125

126-
```bash
127-
pnpm test run
128-
```
129-
130-
Or with coverage enabled:
126+
Tests can be run at the package level or from the monorepo root:
131127

132128
```bash
133-
pnpm test run --coverage
129+
# From the package directory
130+
pnpm test # Run tests in watch mode
131+
pnpm test run # Run tests once
132+
pnpm test run --coverage # Run tests with coverage
133+
134+
# From the monorepo root (runs tests across all packages)
135+
pnpm test # Run all tests in watch mode
136+
pnpm test:run # Run all tests once
137+
pnpm test:ci # Run tests with coverage and CI reporters
134138
```
135139

136140
**Important**: Vitest automatically clears all mocks between tests, so you should never need to call `vi.clearAllMocks()` in a `beforeEach` hook.

.github/workflows/check.yml

Lines changed: 33 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ on:
77
- main
88
- next
99

10-
permissions:
11-
id-token: write # used to upload artifacts to codecov
10+
env:
11+
TURBO_ENV_MODE: loose
1212

1313
jobs:
14-
build-mcp:
15-
name: Build @storybook/mcp
14+
build:
15+
name: Build
1616
runs-on: ubuntu-latest
17+
permissions:
18+
id-token: write # used to upload artifacts to codecov
1719
steps:
1820
- name: Checkout
1921
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -24,22 +26,7 @@ jobs:
2426
uses: ./.github/actions/setup-node-and-install
2527

2628
- name: Build
27-
run: pnpm build --env-mode=loose --filter @storybook/mcp
28-
29-
build-addon-mcp:
30-
name: Build @storybook/addon-mcp
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Checkout
34-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
35-
with:
36-
fetch-depth: 2 # see https://docs.codecov.com/docs/environment-specific-requirements#github-actions
37-
38-
- name: Setup Node.js and Install Dependencies
39-
uses: ./.github/actions/setup-node-and-install
40-
41-
- name: Build
42-
run: pnpm build --env-mode=loose --filter @storybook/addon-mcp
29+
run: pnpm turbo run build
4330

4431
build-storybook:
4532
name: Build internal Storybook
@@ -52,70 +39,44 @@ jobs:
5239
uses: ./.github/actions/setup-node-and-install
5340

5441
- name: Build
55-
run: pnpm build-storybook
42+
run: pnpm turbo run build-storybook
5643

57-
test-mcp:
58-
name: Test @storybook/mcp
44+
test:
45+
name: Test
5946
runs-on: ubuntu-latest
47+
permissions:
48+
id-token: write # used to upload artifacts to codecov
6049
steps:
6150
- name: Checkout
6251
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
52+
with:
53+
fetch-depth: 2 # see https://docs.codecov.com/docs/environment-specific-requirements#github-actions
6354

6455
- name: Setup Node.js and Install Dependencies
6556
uses: ./.github/actions/setup-node-and-install
6657

6758
- name: Run tests with coverage
68-
run: pnpm --filter @storybook/mcp test run --coverage --reporter=default --reporter=junit --outputFile=test-report.junit.xml
59+
run: pnpm turbo run test:ci
6960

70-
- name: Upload test and coverage artifact
71-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
72-
if: always()
61+
- name: Upload coverage to Codecov
62+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
7363
with:
74-
name: test-mcp
75-
path: |
76-
packages/mcp/coverage/
77-
packages/mcp/test-report.junit.xml
78-
79-
test-addon-mcp:
80-
name: Test @storybook/addon-mcp
81-
runs-on: ubuntu-latest
82-
steps:
83-
- name: Checkout
84-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
85-
86-
- name: Setup Node.js and Install Dependencies
87-
uses: ./.github/actions/setup-node-and-install
88-
89-
- name: Build @storybook/mcp (dependency)
90-
run: pnpm build --filter @storybook/mcp
91-
92-
- name: Run tests with coverage
93-
run: pnpm --filter @storybook/addon-mcp test run --coverage --reporter=default --reporter=junit --outputFile=test-report.junit.xml
64+
use_oidc: true
65+
fail_ci_if_error: true
66+
files: |
67+
coverage/lcov.info
9468
95-
- name: Upload test and coverage artifact
96-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
69+
- name: Upload test results to Codecov
70+
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1
9771
if: always()
9872
with:
99-
name: test-addon-mcp
100-
path: |
101-
packages/addon-mcp/coverage/
102-
packages/addon-mcp/test-report.junit.xml
103-
104-
typecheck-mcp:
105-
name: Type check @storybook/mcp
106-
runs-on: ubuntu-latest
107-
steps:
108-
- name: Checkout
109-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
110-
111-
- name: Setup Node.js and Install Dependencies
112-
uses: ./.github/actions/setup-node-and-install
113-
114-
- name: Run type checking
115-
run: pnpm --filter @storybook/mcp typecheck
73+
use_oidc: true
74+
fail_ci_if_error: true
75+
files: |
76+
test-report.junit.xml
11677
117-
typecheck-addon-mcp:
118-
name: Type check @storybook/addon-mcp
78+
typecheck:
79+
name: Type check
11980
runs-on: ubuntu-latest
12081
steps:
12182
- name: Checkout
@@ -124,11 +85,8 @@ jobs:
12485
- name: Setup Node.js and Install Dependencies
12586
uses: ./.github/actions/setup-node-and-install
12687

127-
- name: Build @storybook/mcp (dependency)
128-
run: pnpm build --filter @storybook/mcp
129-
13088
- name: Run type checking
131-
run: pnpm --filter @storybook/addon-mcp typecheck
89+
run: pnpm turbo run typecheck
13290

13391
publint:
13492
name: Publint
@@ -141,7 +99,7 @@ jobs:
14199
uses: ./.github/actions/setup-node-and-install
142100

143101
- name: Run linting
144-
run: pnpm publint
102+
run: pnpm turbo run publint
145103

146104
lint:
147105
name: Lint
@@ -154,7 +112,7 @@ jobs:
154112
uses: ./.github/actions/setup-node-and-install
155113

156114
- name: Run linting
157-
run: pnpm lint
115+
run: pnpm turbo run lint:ci
158116

159117
format-check:
160118
name: Check formatting
@@ -167,44 +125,4 @@ jobs:
167125
uses: ./.github/actions/setup-node-and-install
168126

169127
- name: Check formatting
170-
run: pnpm format --check
171-
172-
collect-coverage:
173-
name: Collect coverage and test results
174-
runs-on: ubuntu-latest
175-
needs: [test-mcp, test-addon-mcp]
176-
if: always()
177-
steps:
178-
- name: Checkout
179-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
180-
with:
181-
fetch-depth: 2 # see https://docs.codecov.com/docs/environment-specific-requirements#github-actions
182-
183-
- name: Download @storybook/mcp coverage
184-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
185-
with:
186-
name: test-mcp
187-
path: packages/mcp/
188-
189-
- name: Download @storybook/addon-mcp coverage
190-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
191-
with:
192-
name: test-addon-mcp
193-
path: packages/addon-mcp/
194-
195-
- name: Upload coverage to Codecov
196-
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
197-
with:
198-
use_oidc: true
199-
fail_ci_if_error: true
200-
files: |
201-
packages/mcp/coverage/lcov.info
202-
packages/addon-mcp/coverage/lcov.info
203-
- name: Upload test results to Codecov
204-
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1
205-
with:
206-
use_oidc: true
207-
fail_ci_if_error: true
208-
files: |
209-
packages/mcp/test-report.junit.xml
210-
packages/addon-mcp/test-report.junit.xml
128+
run: pnpm turbo run format:check

.github/workflows/publish-preview.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- main
88
- next
99

10+
env:
11+
TURBO_ENV_MODE: loose
12+
1013
jobs:
1114
release-preview:
1215
name: Publish preview releases

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- main
77
- next
88

9+
env:
10+
TURBO_ENV_MODE: loose
11+
912
jobs:
1013
release:
1114
permissions:

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm-lock.yaml

0 commit comments

Comments
 (0)