Commit fa3d329
authored
fix: repair get_component_html, upgrade SDK 0.5 -> 1.29 and refresh toolchain (#11)
Two pre-existing bugs made get_component_html — the reason this server exists —
fail on most real design systems. Both were found while verifying the
dependency upgrade against a real Storybook 10 build, and both reproduce on
main with the old SDK and Puppeteer.
1. The render check required more than 100 characters of HTML
A rendered button is 76 characters. Badges, chips, icons and inputs are
smaller still, so the poll loop never accepted them, ran its full 15 x 1s,
and blew past the 10s caller timeout. Every compact component — the bulk of
a design system — returned "Operation timed out after 10000ms".
Content now counts as rendered when it is non-empty and is not Storybook's
own no-preview placeholder. The loop is also bounded by a deadline instead
of an attempt count that could exceed the caller's budget, and polls every
100ms instead of sleeping a full second before even looking.
2. Concurrent jobs corrupted each other
The job queue runs maxConcurrent = 2, but PuppeteerClient shared a single
page: two simultaneous fetches navigated the same tab and whichever started
second tore the first one's document away. On top of that,
getPuppeteerClient() had an async-init race — two callers both saw a null
field, both launched a browser, and the second assignment orphaned the
first mid-request. Either way one of any two parallel jobs failed with a
spurious connection error.
Each fetch now gets its own page (closed in a finally, so tabs cannot leak)
and the launch caches its in-flight promise rather than the resolved client.
Verified against Storybook 10.5.4: before, one job timed out at 10s and the
other failed; after, two concurrent extractions both complete in ~2.4s with
correct HTML.
Toolchain, which is what prompted all of the above:
- @modelcontextprotocol/sdk 0.5.0 -> 1.29.0. The server was two years behind
on a pre-1.0 SDK; it now negotiates protocol 2025-06-18. No API changes were
needed, the low-level Server surface is unchanged.
- Node 18 dropped (EOL) — engines, CI matrix now 20/22/24, publish workflow
and tsup target follow.
- eslint 8 -> 10 with a flat config matching the other repos, typescript-eslint
6 -> 8, vitest 3 -> 4, puppeteer 24 -> 25, node-html-parser 6 -> 9, zod 3 -> 4,
@types/node 20 -> 26.
- eslint 10's new rules found real defects, fixed rather than silenced: five
throw sites discarded the caught error instead of chaining it via `cause`,
and isSSLCertificateError() ran String() over an unknown value, so a thrown
plain object stringified to "[object Object]" and every certificate check
silently missed.
- Server version was hardcoded in index.ts and had already drifted (1.1.0 there
vs 1.1.1 in package.json); it is now injected from package.json at build.
- Coverage: added the lcov reporter and coverage.all, so CI can upload and the
denominator is the whole source tree rather than whatever tests imported.
Thresholds are set to today's real numbers, which are ~6%. They were 80 but
never enforced, because CI ran `vitest run` without --coverage.
- server.json plus mcpName and the registry publish workflow, so the package
appears in the MCP Registry like mcp-gsheets and openclaw-mcp.
- README documents Storybook 7-10 support, verified by building Storybook
10.5.4 and extracting from it.
21 tests pass. The new ones pin the length regression directly: a 76-character
button must read as rendered, and a long no-preview placeholder must not.1 parent 5b285c3 commit fa3d329
17 files changed
Lines changed: 3521 additions & 2316 deletions
File tree
- .github/workflows
- src
- tools
- utils
- tests/unit
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
263 | 276 | | |
264 | 277 | | |
265 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
0 commit comments