@shoplflow/mcp 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +587 -55
  2. package/dist/index.js +102 -5
  3. package/package.json +23 -5
package/README.md CHANGED
@@ -1,92 +1,624 @@
1
1
  # @shoplflow/mcp
2
2
 
3
3
  Model Context Protocol (MCP) server that exposes the shoplflow design system to AI coding agents
4
- (Claude Code, Cursor, …) so they generate UI against **real** tokens, components, and icons instead
4
+ (Claude Code, Cursor, Codex, …) so they generate UI against **real** tokens, components, and icons instead
5
5
  of hallucinating them.
6
6
 
7
- ## Architecture
7
+ ```tsx
8
+ // Without the MCP — plausible, but nothing here exists
9
+ <Button variant="primary" size="medium" color="#3B82F6" />
10
+ <Icon name="plus" />
8
11
 
9
- Metadata is **generated at build time** from the same sources that produce the shipped library, then
10
- served by a thin stdio server. This makes drift structurally impossible — the MCP can never describe a
11
- token or component that differs from what actually ships.
12
+ // With the MCP — looked up from the shipped library
13
+ <Button styleVar="PRIMARY" sizeVar="M" />
14
+ <Icon iconSource={AddIcon} sizeVar="S" color="neutral500" />
15
+ ```
16
+
17
+ > 내부 구조·설계 결정·확장 가이드는 [아키텍쳐.md](./아키텍쳐.md)를 참고하세요.
18
+
19
+ **Contents:** [Quick start](#quick-start) · [Verify](#verify-the-connection) · [Tools](#tool-reference) · [Resources](#resources) · [Working with an agent](#working-with-an-agent) · [What's served](#whats-served) · [Development](#local-development) · [Troubleshooting](#troubleshooting)
20
+
21
+ ---
22
+
23
+ ## Quick start
24
+
25
+ The server runs over **stdio** and needs no auth, no network, and no config — the whole design-system
26
+ catalog is bundled into the published binary.
27
+
28
+ ### Claude Code
29
+
30
+ Easiest path — install the plugin, which wires up this MCP **and** the [`@shoplflow/skills`](../skills) agent skills in one step:
31
+
32
+ ```bash
33
+ /plugin marketplace add shopl/shoplflow
34
+ /plugin install shoplflow@shoplflow-marketplace
35
+ ```
36
+
37
+ MCP only:
38
+
39
+ ```bash
40
+ claude mcp add shoplflow -- npx -y @shoplflow/mcp
41
+ ```
42
+
43
+ Or commit it to the project so the whole team gets it — `.mcp.json` at the repo root:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "shoplflow": {
49
+ "type": "stdio",
50
+ "command": "npx",
51
+ "args": ["-y", "@shoplflow/mcp"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ### Cursor
58
+
59
+ `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "shoplflow": {
65
+ "command": "npx",
66
+ "args": ["-y", "@shoplflow/mcp"]
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ ### Codex
73
+
74
+ `~/.codex/config.toml`:
75
+
76
+ ```toml
77
+ [mcp_servers.shoplflow]
78
+ command = "npx"
79
+ args = ["-y", "@shoplflow/mcp"]
80
+ ```
81
+
82
+ ### VS Code (GitHub Copilot)
83
+
84
+ `.vscode/mcp.json`:
85
+
86
+ ```json
87
+ {
88
+ "servers": {
89
+ "shoplflow": {
90
+ "type": "stdio",
91
+ "command": "npx",
92
+ "args": ["-y", "@shoplflow/mcp"]
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ ### Any other MCP client
99
+
100
+ Anything that speaks stdio MCP works — the command is always:
101
+
102
+ ```bash
103
+ npx -y @shoplflow/mcp
104
+ ```
105
+
106
+ Or install it and use the bin directly:
107
+
108
+ ```bash
109
+ npm i -g @shoplflow/mcp && shoplflow-mcp
110
+ ```
111
+
112
+ Requires **Node ≥ 18**.
113
+
114
+ ---
115
+
116
+ ## Verify the connection
117
+
118
+ After restarting your agent, ask it something only this server can answer:
119
+
120
+ > "shoplflow에서 primary300 토큰 값이 뭐야?"
121
+
122
+ A working connection returns `#3299fe` **via a `get_token` call** (you should see the tool invocation).
123
+ If the agent answers from guesswork without calling a tool, it isn't connected.
124
+
125
+ In Claude Code you can also list it explicitly:
126
+
127
+ ```bash
128
+ claude mcp list # shoplflow should appear as connected
129
+ ```
130
+
131
+ **Connect-time preflight.** On connect, the server hands the client an `instructions` string that the agent
132
+ keeps in context for the whole session:
133
+
134
+ > MANDATORY shoplflow setup before rendering ANY `@shoplflow/base` component: (1) import `@shoplflow/base/styles`
135
+ > at the app entry; (2) wrap the tree in `<ShoplflowProvider domain="SHOPL" | "HADA">`. These components are
136
+ > CLIENT-ONLY … Next.js App Router requires a `'use client'` boundary plus an Emotion registry.
137
+
138
+ This is why the agent won't forget the provider even if you never mention it.
139
+
140
+ ---
141
+
142
+ ## Tool reference
143
+
144
+ Eight tools, organised as **discover → detail**. List tools return summaries; detail tools return everything.
145
+ That split keeps the agent's context small — pulling all 65 component APIs at once would cost tens of
146
+ thousands of tokens.
147
+
148
+ | Tool | Use it to | Returns |
149
+ | ----------------------------------------- | ------------------------------- | ------------------------------- |
150
+ | [`list_tokens`](#list_tokens) | discover token names/values | summaries |
151
+ | [`get_token`](#get_token) | get one token in full | full record |
152
+ | [`search_icon`](#search_icon) | find an icon by name or meaning | name + alias + import |
153
+ | [`search_component`](#search_component) | discover components | summaries + variants |
154
+ | [`get_component_api`](#get_component_api) | get one component's full API | props + variants + polymorphism |
155
+ | [`get_usage_example`](#get_usage_example) | get real usage code | story-derived examples |
156
+ | [`get_setup_guide`](#get_setup_guide) | scaffold correct setup | provider + CSS + snippet |
157
+ | [`check_environment`](#check_environment) | check framework support | support status + workaround |
158
+
159
+ ---
160
+
161
+ ### `list_tokens`
162
+
163
+ Discover exact token names and values before writing UI code.
164
+
165
+ | Param | Type | Required | Description |
166
+ | -------- | ------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------- |
167
+ | `domain` | `"shared" \| "shopl" \| "hada"` | – | `shared` = palette/spacing/radius/weights/shadows (brand-agnostic). `shopl`/`hada` = typography + primary/semantic colors. |
168
+ | `type` | `string` | – | One of `color`, `spacing`, `borderRadius`, `fontWeights`, `typography`, `boxShadow`. |
169
+ | `query` | `string` | – | Case-insensitive substring against the token **name or value**. |
170
+
171
+ ```jsonc
172
+ // list_tokens({ type: "color", query: "primary" })
173
+ {
174
+ "count": 10, // primary100/150/200/300/400 × shopl + hada
175
+ "tokens": [
176
+ {
177
+ "name": "primary300",
178
+ "type": "color",
179
+ "domain": "shopl",
180
+ "value": "#3299fe",
181
+ "cssVar": "--primary300",
182
+ "className": null,
183
+ },
184
+ ],
185
+ }
186
+ ```
187
+
188
+ > **`cssVar` vs `className`.** Most tokens are CSS custom properties (`var(--primary300)`).
189
+ > Typography tokens are **not** — they're applied as a class or via the `typography` prop
190
+ > (`<Text typography="body1_700" />`), so they carry `className` instead. The agent uses this
191
+ > field to pick the right consumption pattern.
192
+
193
+ ---
194
+
195
+ ### `get_token`
196
+
197
+ Full record for one token by exact name.
198
+
199
+ | Param | Type | Required | Description |
200
+ | -------- | ------------------------------- | -------- | -------------------------------------------------------------- |
201
+ | `name` | `string` | ✅ | Exact token name, e.g. `primary300`, `body1_700`, `spacing08`. |
202
+ | `domain` | `"shared" \| "shopl" \| "hada"` | – | Disambiguate — the same name can exist per brand. |
203
+
204
+ A miss returns suggestions rather than an error, so the agent can self-correct:
205
+
206
+ ```jsonc
207
+ // get_token({ name: "primaryX" })
208
+ { "found": false, "name": "primaryX", "suggestions": ["primary100 (shopl)", "primary200 (shopl)", …] }
209
+ ```
210
+
211
+ ---
212
+
213
+ ### `search_icon`
214
+
215
+ Find icons by name **or meaning**. Both the raw name (`IcAdd`) and the public alias (`AddIcon`) are
216
+ importable and both are returned.
217
+
218
+ | Param | Type | Required | Description |
219
+ | -------- | ------------------- | -------- | ------------------------------------------------------- |
220
+ | `query` | `string` | ✅ | Name or keywords — `"add"`, `"chat bot"`, `"calendar"`. |
221
+ | `domain` | `"shopl" \| "hada"` | – | Restrict to one brand's icon set. |
222
+ | `limit` | `number` (≤50) | – | Max results, default 15. |
223
+
224
+ ```jsonc
225
+ // search_icon({ query: "trash", domain: "shopl" })
226
+ {
227
+ "query": "trash",
228
+ "count": 2,
229
+ "icons": [
230
+ {
231
+ "name": "IcTrash",
232
+ "alias": "TrashIcon",
233
+ "domain": "shopl",
234
+ "importFrom": "@shoplflow/shopl-assets",
235
+ },
236
+ {
237
+ "name": "IcTrashLine",
238
+ "alias": "TrashLineIcon",
239
+ "domain": "shopl",
240
+ "importFrom": "@shoplflow/shopl-assets",
241
+ },
242
+ ],
243
+ }
244
+ ```
245
+
246
+ > **Multi-word queries narrow, they don't broaden.** Every term must match — `"chat bot"` returns only
247
+ > `IcAiChatBot`, not everything chat-related. Search first, then use `<Icon iconSource={TrashIcon} />`.
248
+ >
249
+ > **Icon sets differ per brand.** An icon in `shopl` may not exist in `hada`. Pass `domain` when the app
250
+ > targets one brand.
251
+
252
+ ---
253
+
254
+ ### `search_component`
255
+
256
+ Discover components by name, module, prop name, or variant value.
257
+
258
+ | Param | Type | Required | Description |
259
+ | ------- | -------------- | -------- | ---------------------------------------------------------------- |
260
+ | `query` | `string` | ✅ | e.g. `"button"`, `"modal"`, `"date"`, `"styleVar"`, `"loading"`. |
261
+ | `group` | `string` | – | Restrict to one module (the component folder, e.g. `"Modal"`). |
262
+ | `limit` | `number` (≤50) | – | Max results, default 20. |
263
+
264
+ Compound components are listed **per part** — searching `"modal"` returns `ModalContainer`,
265
+ `ModalHeader`, `ModalContents`, … not a single `Modal` entry.
266
+
267
+ ```jsonc
268
+ // search_component({ query: "button" })
269
+ {
270
+ "count": 11, // Button, ChipButton, DropdownButton, IconButton, SplitButton, ToggleButton, …
271
+ "components": [
272
+ {
273
+ "name": "Button",
274
+ "group": "Button",
275
+ "polymorphic": true,
276
+ "variants": [
277
+ { "prop": "sizeVar", "values": ["S", "M", "XS"] },
278
+ {
279
+ "prop": "styleVar",
280
+ "values": ["PRIMARY", "SECONDARY", "SOLID", "GHOST"],
281
+ },
282
+ ],
283
+ "propCount": 9,
284
+ },
285
+ ],
286
+ }
287
+ ```
288
+
289
+ ---
290
+
291
+ ### `get_component_api`
292
+
293
+ Everything about one component.
294
+
295
+ | Param | Type | Required | Description |
296
+ | ------ | -------- | -------- | ------------------------------------------------------------------------ |
297
+ | `name` | `string` | ✅ | Exact component name, case-insensitive — `"Button"`, `"ModalContainer"`. |
298
+
299
+ ```jsonc
300
+ // get_component_api({ name: "Button" })
301
+ {
302
+ "found": true,
303
+ "component": {
304
+ "name": "Button",
305
+ "group": "Button",
306
+ "importFrom": "@shoplflow/base",
307
+ "polymorphic": true, // accepts `as`
308
+ "defaultElement": "button", // renders <button> by default
309
+ "nativeAttrs": "button", // forwards native <button> attributes
310
+ "variants": [
311
+ { "prop": "sizeVar", "values": ["S", "M", "XS"] },
312
+ {
313
+ "prop": "styleVar",
314
+ "values": ["PRIMARY", "SECONDARY", "SOLID", "GHOST"],
315
+ },
316
+ ],
317
+ "props": [
318
+ {
319
+ "name": "color",
320
+ "optional": true,
321
+ "type": "ColorTokens",
322
+ "description": "텍스트 혹은 아이콘의 색상을 설정합니다. styleVar이 있는 경우 메인색상을 설정합니다.",
323
+ },
324
+ {
325
+ "name": "isLoading",
326
+ "optional": true,
327
+ "type": "boolean",
328
+ "description": "로딩 여부를 설정합니다.",
329
+ },
330
+ ],
331
+ },
332
+ }
333
+ ```
334
+
335
+ Field meanings:
336
+
337
+ | Field | Meaning |
338
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
339
+ | `polymorphic` | Accepts an `as` prop — `<Button as="a" href="…">`. |
340
+ | `defaultElement` | The element rendered when `as` is omitted. |
341
+ | `nativeAttrs` | Forwards that element's native HTML attributes (`onClick`, `type`, `aria-*`, …). Not enumerated — there are hundreds. |
342
+ | `variants` | The **exact** allowed values, read from the `as const` enums in the source. Nothing else is valid. |
343
+ | `props` | Component-specific props with JSDoc (Korean, straight from the library) and optionality. Types longer than 80 chars are elided with `…`. |
344
+
345
+ Misses return `suggestions`, same as `get_token`.
346
+
347
+ ---
348
+
349
+ ### `get_usage_example`
350
+
351
+ Real, copy-pasteable usage extracted from the component's Storybook stories — `args` and `render` JSX,
352
+ with `play`/`parameters`/`argTypes` test noise stripped.
353
+
354
+ | Param | Type | Required | Description |
355
+ | ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
356
+ | `name` | `string` | ✅ | Module name (`"Button"`, `"Modal"`) **or** a component name from `get_component_api` (`"ModalContainer"` resolves to the `Modal` stories). |
357
+
358
+ ```jsonc
359
+ // get_usage_example({ name: "Button" })
360
+ {
361
+ "found": true,
362
+ "component": "Button",
363
+ "group": "Button",
364
+ "examples": [
365
+ {
366
+ "story": "Playground",
367
+ "args": "{ styleVar: 'PRIMARY', sizeVar: 'M', children: 'Button', disabled: false }",
368
+ },
369
+ {
370
+ "story": "Variants",
371
+ "code": "<div style={flexWrap}>\n <Button {...args} styleVar='PRIMARY'>Primary</Button>\n <Button {...args} styleVar='SOLID' color='neutral300'>Solid</Button>\n</div>",
372
+ },
373
+ ],
374
+ }
375
+ ```
376
+
377
+ > Stories are the best usage source because they're rendered in CI — an example that broke would fail the build.
378
+ > Up to 8 examples per module; long code is clipped at ~1200 chars.
379
+
380
+ ---
381
+
382
+ ### `get_setup_guide`
383
+
384
+ The prerequisite setup before **any** `@shoplflow/base` component renders. Takes no arguments.
385
+
386
+ ```jsonc
387
+ {
388
+ "provider": {
389
+ "name": "ShoplflowProvider",
390
+ "importFrom": "@shoplflow/base",
391
+ "clientOnly": true,
392
+ "clientReasons": [
393
+ "framer-motion (LazyMotion)",
394
+ "Modal/Popper portals",
395
+ "DOM theming hook (data-shoplflow)",
396
+ "Emotion CSS-in-JS",
397
+ ],
398
+ "props": [
399
+ {
400
+ "name": "domain",
401
+ "type": "DomainType",
402
+ "optional": true,
403
+ "default": "SHOPL",
404
+ "values": ["SHOPL", "HADA"],
405
+ },
406
+ ],
407
+ },
408
+ "styles": [
409
+ {
410
+ "specifier": "@shoplflow/base/styles",
411
+ "role": "design-token CSS vars + typography classes (required)",
412
+ },
413
+ { "specifier": "@shoplflow/base/reset", "role": "CSS reset (optional)" },
414
+ ],
415
+ "peerDependencies": {
416
+ "@emotion/react": "^11",
417
+ "@emotion/styled": "^11",
418
+ "react": "^18",
419
+ "react-dom": "^18",
420
+ },
421
+ "setupSteps": ["…"],
422
+ "snippet": "import { ShoplflowProvider } from '@shoplflow/base';\nimport '@shoplflow/base/styles';\n\n<ShoplflowProvider domain=\"SHOPL\">\n <App />\n</ShoplflowProvider>",
423
+ }
424
+ ```
425
+
426
+ > The `snippet` is **synthesised from the real provider and package exports**, so it can never reference a
427
+ > wrong import path or a prop that doesn't exist.
428
+
429
+ Call this before scaffolding a project. For framework-specific caveats, pair it with `check_environment`.
430
+
431
+ ---
432
+
433
+ ### `check_environment`
434
+
435
+ Whether — and how — shoplflow works in a given framework. Components are client-only, so SSR/RSC
436
+ frameworks have caveats.
437
+
438
+ | Param | Type | Required | Description |
439
+ | ----------- | -------- | -------- | ----------------------------------------------------------------------------------- |
440
+ | `framework` | `string` | – | e.g. `"next app router"`, `"vite"`, `"next pages"`. Omit to list every environment. |
441
+
442
+ | Environment | Support | Summary |
443
+ | -------------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
444
+ | Vite / CRA (SPA, CSR) | ✅ supported | Recommended. Import the styles and wrap with the provider at the entry point. |
445
+ | Next.js — Pages Router | ⚠️ constrained | Renders, but FOUC without Emotion SSR. Workaround: wrap in `_app.tsx`, add `extractCriticalToChunks` in `_document.tsx`. |
446
+ | Next.js — App Router (RSC) | ⛔ needs workaround | Cannot render inside a Server Component. Workaround: `'use client'` provider wrapper + Emotion registry (`useServerInsertedHTML`); keep every consumer inside the client boundary. |
447
+
448
+ Unknown input returns the full list rather than an empty result.
449
+
450
+ ---
451
+
452
+ ## Resources
453
+
454
+ For clients that prefer reading a document over calling tools.
455
+
456
+ | URI | Content |
457
+ | ------------------------ | --------------------------------------------------------------------------------- |
458
+ | `shoplflow://tokens` | The entire token catalog as JSON (all 114 records with counts by type/domain). |
459
+ | `shoplflow://components` | Compact index of every component — name, group, polymorphism, variant prop names. |
460
+
461
+ ---
462
+
463
+ ## Working with an agent
464
+
465
+ You don't need to name the tools — the descriptions steer the agent. But knowing the flow helps you
466
+ diagnose a bad result.
467
+
468
+ ```
469
+ "shoplflow로 삭제 버튼 만들어줘"
470
+ ├ search_component("button") → Button, IconButton, SplitButton, ToggleButton, …
471
+ ├ get_component_api("Button") → exact styleVar/sizeVar values + props
472
+ ├ get_usage_example("Button") → real JSX from the stories
473
+ ├ search_icon("trash") → IcTrash / TrashIcon + import path
474
+ └ list_tokens({type:"color"}) → exact color token keys
475
+ ```
476
+
477
+ **Prompts that use the server well**
478
+
479
+ | Goal | Ask |
480
+ | ------------------- | --------------------------------------------------------------------------------- |
481
+ | Correct scaffolding | "Vite 앱에 shoplflow 셋업해줘" → triggers `get_setup_guide` + `check_environment` |
482
+ | Exact variants | "Button에 어떤 styleVar 값이 있어?" → `get_component_api` |
483
+ | Find an icon | "휴지통 아이콘 뭐 써야 해?" → `search_icon` |
484
+ | Match the design | "이 카드 배경을 shoplflow 뉴트럴 토큰으로 바꿔줘" → `list_tokens` |
485
+ | Framework check | "Next.js App Router에서 shoplflow 써도 돼?" → `check_environment` |
486
+
487
+ **Pair with the skills package.** The MCP gives an agent _facts_; [`@shoplflow/skills`](../skills) gives it
488
+ _idioms_ — the setup order, the KEY-vs-VALUE distinction, the `styleVar`/`sizeVar` convention. Installing the
489
+ plugin gets both. See [../skills/README.md](../skills/README.md).
490
+
491
+ ---
492
+
493
+ ## What's served
494
+
495
+ Everything is generated at build time from the same files that produce the shipped library, so the served
496
+ metadata can't describe something that differs from what ships.
497
+
498
+ | Surface | Count | Source |
499
+ | -------------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------- |
500
+ | Design tokens | **114** (color 44 · typography 47 · spacing 13 · borderRadius 6 · fontWeights 3 · boxShadow 1) | `base/src/styles/tokens.json` |
501
+ | Icons | **473** (shopl 369 · hada 104) | `{shopl,hada}-assets` barrels |
502
+ | Component APIs | **65 cards** across 43 modules (19 with variants) | `base/src/components/**/*.types.ts` |
503
+ | Usage examples | **149** across 42 modules | `base/src/components/**/*.stories.tsx` |
504
+ | Setup & environments | provider + 2 CSS exports + 3 frameworks | `base` provider/package.json + `setup.curated.json` |
12
505
 
13
506
  ```
14
507
  tokens.json ─┐
15
508
  *-assets barrel ─┤ scripts/generate-metadata.cjs ─► src/data/*.generated.json ─► MCP server (stdio)
16
- *.types.ts ─┘ (build step) (bundled into the bin)
509
+ *.types.ts ─┤ (build step, ts-morph) (inlined into the bin)
510
+ *.stories.tsx ─┘
511
+ ```
512
+
513
+ Full pipeline details in [아키텍쳐.md](./아키텍쳐.md).
514
+
515
+ ---
516
+
517
+ ## Local development
518
+
519
+ ```bash
520
+ pnpm --filter @shoplflow/mcp generate:metadata # regenerate metadata from the library sources
521
+ pnpm --filter @shoplflow/mcp build:package # generate + bundle to dist/
522
+ pnpm --filter @shoplflow/mcp dev # generate + tsup --watch
523
+ pnpm --filter @shoplflow/mcp start # run the built server over stdio
524
+ pnpm --filter @shoplflow/mcp check:wiring # verify the base-release coupling is intact
17
525
  ```
18
526
 
19
- ## Roadmap
527
+ `build:package` always runs `generate:metadata` first, so a normal build can't ship stale data.
20
528
 
21
- | Phase | Surface | Source | Status |
22
- |-------|---------|--------|--------|
23
- | 1 | Design tokens (`list_tokens`, `get_token`, `shoplflow://tokens`) | `tokens.json` | ✅ done |
24
- | 2 | Icon search (`search_icon`) | `*-assets` barrels | ✅ done |
25
- | 3 | Component API (`search_component`, `get_component_api`) | `*.types.ts` | ✅ done |
26
- | 4 | Usage examples (`get_usage_example`) | `*.stories.tsx` | ✅ done |
27
- | 5 | Setup & environment (`get_setup_guide`, `check_environment`, server `instructions`) | provider + `setup.curated.json` | ✅ done |
529
+ ### Smoke test
28
530
 
29
- ## Develop
531
+ The only end-to-end check — spins up `dist/index.js` with a real MCP client and exercises every tool:
30
532
 
31
533
  ```bash
32
- pnpm --filter @shoplflow/mcp generate:metadata # regenerate metadata from sources
33
- pnpm --filter @shoplflow/mcp build:package # generate + bundle to dist/
34
- pnpm --filter @shoplflow/mcp start # run the built server over stdio
534
+ pnpm --filter @shoplflow/mcp build:package
535
+ node packages/mcp/scripts/smoke.mjs
35
536
  ```
36
537
 
37
- ## Connect (consuming app)
538
+ Expected tail: `✓ smoke test passed`. Run it after touching `server.ts` or any extractor.
539
+
540
+ ### Point your agent at the local build
38
541
 
39
- Add to the client's MCP config (Claude Code shown):
542
+ The repo root `.mcp.json` already does this for monorepo development:
40
543
 
41
544
  ```json
42
545
  {
43
546
  "mcpServers": {
44
547
  "shoplflow": {
45
- "command": "npx",
46
- "args": ["-y", "@shoplflow/mcp"]
548
+ "type": "stdio",
549
+ "command": "node",
550
+ "args": ["packages/mcp/dist/index.js"]
47
551
  }
48
552
  }
49
553
  }
50
554
  ```
51
555
 
52
- ## Tools
556
+ Rebuild (`build:package`) and restart the agent to pick up changes.
557
+
558
+ ### After changing the library
559
+
560
+ Regenerate and **commit the generated JSON** — it's tracked in git so releases are reproducible and diffs
561
+ are reviewable.
562
+
563
+ | You changed | Regenerate affects |
564
+ | ------------------------------------ | --------------------------- |
565
+ | `tokens.json` | `tokens.generated.json` |
566
+ | SVG assets (after `build:assets`) | `icons.generated.json` |
567
+ | a `*.types.ts` | `components.generated.json` |
568
+ | a `*.stories.tsx` | `stories.generated.json` |
569
+ | provider / `base` exports / peerDeps | `setup.generated.json` |
570
+
571
+ Sanity-check the console summary (`✓ tokens: 114 …`) — a sudden drop in a count means an extractor's
572
+ assumption broke.
573
+
574
+ **CI enforces this.** `build-test.yml` regenerates the metadata on every PR and fails if the committed
575
+ JSON differs, with the exact command to fix it. Without that gate the committed copy silently rots and
576
+ the "review the effect of a base change in the PR diff" benefit disappears.
577
+
578
+ ### Release coupling (why `check:wiring` exists)
579
+
580
+ A `@shoplflow/base` release automatically republishes this package with freshly extracted metadata. That
581
+ behaviour isn't declared in one place — it emerges from settings spread across `package.json`,
582
+ `turbo.json`, and `.changeset/config.json`:
583
+
584
+ | Piece | Removing it… |
585
+ | ------------------------------------------------------------ | ---------------------------------------------------------------- |
586
+ | `@shoplflow/{base,shopl-assets,hada-assets}` in devDeps | stops changesets from bumping mcp → **mcp is never republished** |
587
+ | `generate:metadata &&` in `build:package` | allows a build path that bundles previously generated JSON |
588
+ | turbo scheduling `mcp#build:package` under `turbo run build` | means CI's `pnpm build` never produces `dist/` before publish |
589
+
590
+ Each removal keeps the build green — the failure is silent, and consumers just keep receiving stale
591
+ metadata. `check:wiring` asserts all three and runs on every PR. Details in
592
+ [아키텍쳐.md §6](./아키텍쳐.md).
593
+
594
+ ### Editing the setup guidance
53
595
 
54
- **Tokens (Phase 1)**
55
- - **`list_tokens`** — discover token names/values; filter by `domain` (`shared` | `shopl` | `hada`), `type`, or a `query` substring.
56
- - **`get_token`** — full record for one token by exact `name` (+ optional `domain`).
57
- - Resource **`shoplflow://tokens`** — the entire catalog as JSON.
596
+ `setup.curated.json` is the **one file the team edits by hand**. It holds `setupSteps`, per-framework
597
+ `environments`, and the connect-time `instructions`. Everything else (provider props, CSS exports, peer deps)
598
+ is extracted from code and must not be duplicated there.
58
599
 
59
- Typography tokens (e.g. `body1_700`) are applied via the `typography` prop / CSS class, not a CSS variable —
60
- the served records carry `className` for those and `cssVar` for the rest.
600
+ Keep the Next.js entries in sync with the library's actual support stance — the App Router entry currently
601
+ carries a `verify` note flagging it as an inferred, unratified position.
61
602
 
62
- **Icons (Phase 2)**
63
- - **`search_icon`** — find icons by name or meaning; filter by `domain` (`shopl` | `hada`) and `limit`.
64
- Returns the raw name (`IcAdd`) and public alias (`AddIcon`), both importable from the brand asset
65
- package and usable as `<Icon iconSource={AddIcon} />`. Icon sets differ per brand.
603
+ ---
66
604
 
67
- **Components (Phase 3)**
68
- - **`search_component`** — discover `@shoplflow/base` components by name, module, prop, or variant value;
69
- filter by `group` (module) and `limit`. Compound components are listed per part (e.g. `ModalContainer`, `ModalHeader`).
70
- - **`get_component_api`** — full API for one component by exact name: props (with JSDoc + optionality),
71
- exact variant values (`sizeVar`/`styleVar`/…), polymorphism (`as` + default element), and native-HTML-attr passthrough.
72
- - Resource **`shoplflow://components`** — compact index of every component.
605
+ ## Troubleshooting
73
606
 
74
- Component metadata is extracted from `*.types.ts` via ts-morph (build-time only), mirroring how the library
75
- composes props from the documented mixins in `utils/type/ComponentProps.ts`.
607
+ | Symptom | Cause | Fix |
608
+ | --------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
609
+ | Agent doesn't call any tool | Server not connected | `claude mcp list` / check the client's MCP panel. Restart the agent after editing config. |
610
+ | `npx` fails or hangs | Node < 18, or no network on first fetch | `node -v`; run `npx -y @shoplflow/mcp` in a terminal to see the real error. First run downloads the package. |
611
+ | Connection drops immediately | Something wrote to stdout | stdout is reserved for JSON-RPC. Any `console.log` in the server corrupts the protocol — logs must go to `stderr`. |
612
+ | Tools work but data looks stale | Metadata not regenerated | `pnpm --filter @shoplflow/mcp build:package`, restart the agent. Published versions ship the metadata frozen at release time — bump the package. |
613
+ | An icon isn't found | Wrong brand | Icon sets differ per brand; retry `search_icon` without `domain`, or with the other one. |
614
+ | A component isn't found | Compound part name | Search the module (`search_component({ query: "modal" })`) to see the real part names. |
615
+ | Agent still skips the provider | Client ignores `instructions` | Some clients don't surface server instructions. Install [`@shoplflow/skills`](../skills) so the setup rule arrives as a skill too. |
616
+ | Multi-word search returns nothing | AND semantics | Every term must match. Try fewer/shorter terms. |
76
617
 
77
- **Usage examples (Phase 4)**
78
- - **`get_usage_example`** — real, copy-pasteable examples for a component, extracted from its stories
79
- (`args` + `render` JSX, with `play`/test code stripped). Accepts a module name (`Button`, `Modal`) or a
80
- component name from `get_component_api` (`ModalContainer` resolves to the `Modal` stories).
618
+ ---
81
619
 
82
- **Setup & environment (Phase 5)**
83
- - Server **`instructions`** — an always-on preflight (surfaced at connect) so the agent never skips the
84
- mandatory `ShoplflowProvider` + global-CSS setup, or the client-only / Next.js constraint.
85
- - **`get_setup_guide`** — required style import, the Provider wrapper + `domain` prop, peer deps, and a
86
- ready-to-paste snippet (synthesized from the real provider/exports, so it can't reference a wrong import).
87
- - **`check_environment`** — per-framework support (Vite/CRA supported; Next.js Pages constrained; Next.js
88
- App Router needs a `'use client'` boundary + Emotion registry), with workarounds.
620
+ ## Related
89
621
 
90
- Auto facts (provider props, CSS exports, peer deps) come from `@shoplflow/base`; the curated guidance
91
- (setup steps, framework constraints, the `instructions` text) lives in **`setup.curated.json`** — the one
92
- file the team edits. Keep the `Next.js` entries in sync with the library's actual support stance.
622
+ - [아키텍쳐.md](./아키텍쳐.md) — internal architecture, design decisions, extension guide
623
+ - [`@shoplflow/skills`](../skills) — agent skills + the plugin that bundles this server
624
+ - [CLAUDE.md](../../CLAUDE.md) — monorepo guide
package/dist/index.js CHANGED
@@ -15,18 +15,18 @@ var tokens_generated_default = {
15
15
  "shopl",
16
16
  "hada"
17
17
  ],
18
- count: 113,
18
+ count: 114,
19
19
  countByType: {
20
20
  color: 44,
21
21
  borderRadius: 6,
22
22
  fontWeights: 3,
23
23
  spacing: 13,
24
24
  boxShadow: 1,
25
- typography: 46
25
+ typography: 47
26
26
  },
27
27
  countByDomain: {
28
28
  shared: 55,
29
- shopl: 29,
29
+ shopl: 30,
30
30
  hada: 29
31
31
  },
32
32
  tokens: [
@@ -901,6 +901,20 @@ var tokens_generated_default = {
901
901
  className: null,
902
902
  value: "#2d89e4"
903
903
  },
904
+ {
905
+ name: "caption2_700",
906
+ type: "typography",
907
+ domain: "shopl",
908
+ path: "caption2_700",
909
+ cssVar: null,
910
+ className: ".caption2_700",
911
+ value: {
912
+ fontWeight: "{fontWeight.bold}",
913
+ fontSize: "10",
914
+ lineHeight: "15",
915
+ fontFamily: "Pretendard"
916
+ }
917
+ },
904
918
  {
905
919
  name: "heading1_700",
906
920
  type: "typography",
@@ -1290,9 +1304,9 @@ var icons_generated_default = {
1290
1304
  "shopl",
1291
1305
  "hada"
1292
1306
  ],
1293
- count: 467,
1307
+ count: 473,
1294
1308
  countByDomain: {
1295
- shopl: 363,
1309
+ shopl: 369,
1296
1310
  hada: 104
1297
1311
  },
1298
1312
  icons: [
@@ -1686,6 +1700,16 @@ var icons_generated_default = {
1686
1700
  "medium"
1687
1701
  ]
1688
1702
  },
1703
+ {
1704
+ name: "IcBookmarkFill",
1705
+ alias: "BookmarkFillIcon",
1706
+ domain: "shopl",
1707
+ importFrom: "@shoplflow/shopl-assets",
1708
+ keywords: [
1709
+ "bookmark",
1710
+ "fill"
1711
+ ]
1712
+ },
1689
1713
  {
1690
1714
  name: "IcBookmarkFilledMedium",
1691
1715
  alias: "BookmarkFilledMediumIcon",
@@ -2487,6 +2511,18 @@ var icons_generated_default = {
2487
2511
  "page"
2488
2512
  ]
2489
2513
  },
2514
+ {
2515
+ name: "IcFlexibleWorkingHoursSystem",
2516
+ alias: "FlexibleWorkingHoursSystemIcon",
2517
+ domain: "shopl",
2518
+ importFrom: "@shoplflow/shopl-assets",
2519
+ keywords: [
2520
+ "flexible",
2521
+ "working",
2522
+ "hours",
2523
+ "system"
2524
+ ]
2525
+ },
2490
2526
  {
2491
2527
  name: "IcFlexibleWorking",
2492
2528
  alias: "FlexibleWorkingIcon",
@@ -2497,6 +2533,15 @@ var icons_generated_default = {
2497
2533
  "working"
2498
2534
  ]
2499
2535
  },
2536
+ {
2537
+ name: "IcFlexitime",
2538
+ alias: "FlexitimeIcon",
2539
+ domain: "shopl",
2540
+ importFrom: "@shoplflow/shopl-assets",
2541
+ keywords: [
2542
+ "flexitime"
2543
+ ]
2544
+ },
2500
2545
  {
2501
2546
  name: "IcFullScreenMedium",
2502
2547
  alias: "FullScreenMediumIcon",
@@ -3342,6 +3387,16 @@ var icons_generated_default = {
3342
3387
  "workplace"
3343
3388
  ]
3344
3389
  },
3390
+ {
3391
+ name: "IcInfoXsmall",
3392
+ alias: "InfoXsmallIcon",
3393
+ domain: "shopl",
3394
+ importFrom: "@shoplflow/shopl-assets",
3395
+ keywords: [
3396
+ "info",
3397
+ "xsmall"
3398
+ ]
3399
+ },
3345
3400
  {
3346
3401
  name: "IcInfo",
3347
3402
  alias: "InfoIcon",
@@ -3932,6 +3987,16 @@ var icons_generated_default = {
3932
3987
  "check"
3933
3988
  ]
3934
3989
  },
3990
+ {
3991
+ name: "IcPinCluster",
3992
+ alias: "PinClusterIcon",
3993
+ domain: "shopl",
3994
+ importFrom: "@shoplflow/shopl-assets",
3995
+ keywords: [
3996
+ "pin",
3997
+ "cluster"
3998
+ ]
3999
+ },
3935
4000
  {
3936
4001
  name: "IcPinXlarge",
3937
4002
  alias: "PinXlargeIcon",
@@ -4666,6 +4731,16 @@ var icons_generated_default = {
4666
4731
  "arrow"
4667
4732
  ]
4668
4733
  },
4734
+ {
4735
+ name: "IcUploadXsmall",
4736
+ alias: "UploadXsmallIcon",
4737
+ domain: "shopl",
4738
+ importFrom: "@shoplflow/shopl-assets",
4739
+ keywords: [
4740
+ "upload",
4741
+ "xsmall"
4742
+ ]
4743
+ },
4669
4744
  {
4670
4745
  name: "IcUserNameLine",
4671
4746
  alias: "UserNameLineIcon",
@@ -6432,6 +6507,12 @@ var components_generated_default = {
6432
6507
  polymorphic: false,
6433
6508
  variants: [],
6434
6509
  props: [
6510
+ {
6511
+ name: "autoPlacement",
6512
+ optional: true,
6513
+ type: "AutoPlacementOptions",
6514
+ description: "\uD654\uBA74 \uBDF0\uC5D0 \uB530\uB77C \uC790\uB3D9\uC73C\uB85C \uC704\uCE58\uB97C \uC870\uC815\uD569\uB2C8\uB2E4. `placement` \uB610\uB294 `middlewares`\uAC00 \uC9C0\uC815\uB418\uBA74 \uBB34\uC2DC\uB429\uB2C8\uB2E4. Ref: https://floating-ui.com/docs/autoplacement"
6515
+ },
6435
6516
  {
6436
6517
  name: "disabled",
6437
6518
  optional: true,
@@ -6443,6 +6524,12 @@ var components_generated_default = {
6443
6524
  type: "boolean",
6444
6525
  description: "\uC678\uBD80\uC5D0\uC11C `isOpen`\uC744 \uC81C\uC5B4\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."
6445
6526
  },
6527
+ {
6528
+ name: "middlewares",
6529
+ optional: true,
6530
+ type: "Array<Middleware | null | undefined | false>",
6531
+ description: "floating ui\uC758 middleware\uB97C \uC124\uC815\uD569\uB2C8\uB2E4. \uC9C0\uC815 \uC2DC \uAE30\uBCF8 `autoPlacement`\uB294 \uC801\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. Ref: https://floating-ui.com/docs/useFloating#middleware"
6532
+ },
6446
6533
  {
6447
6534
  name: "offset",
6448
6535
  optional: true,
@@ -6464,6 +6551,11 @@ var components_generated_default = {
6464
6551
  optional: true,
6465
6552
  type: "ReactNode"
6466
6553
  },
6554
+ {
6555
+ name: "strategy",
6556
+ optional: true,
6557
+ type: "Strategy"
6558
+ },
6467
6559
  {
6468
6560
  name: "trigger",
6469
6561
  optional: true,
@@ -7471,6 +7563,11 @@ var components_generated_default = {
7471
7563
  optional: false,
7472
7564
  type: "Array<{ label: string; value: string }>"
7473
7565
  },
7566
+ {
7567
+ name: "middlewares",
7568
+ optional: true,
7569
+ type: "Array<Middleware | null | undefined | false>"
7570
+ },
7474
7571
  {
7475
7572
  name: "pageSize",
7476
7573
  optional: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoplflow/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Model Context Protocol server exposing the shoplflow design system (tokens, components, icons) to AI coding agents.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -27,18 +27,35 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
+ "//scripts": [
31
+ "build:package MUST keep `generate:metadata &&` at the front. It is what guarantees the",
32
+ "published bundle can never carry stale design-system metadata — there is no build path",
33
+ "that skips extraction. Verified by `check:wiring`."
34
+ ],
30
35
  "dependencies": {
31
36
  "@modelcontextprotocol/sdk": "^1.12.0",
32
37
  "zod": "^3.23.8"
33
38
  },
39
+ "//devDependencies": [
40
+ "DO NOT REMOVE the three @shoplflow/* workspace deps below just because nothing imports them.",
41
+ "They are not runtime deps — they are the wire that couples this package to a base release:",
42
+ " 1. turbo reads them to order `build:package` after base/assets have built.",
43
+ " 2. changesets reads them to treat mcp as a dependent of base, so a base version bump",
44
+ " patch-bumps mcp too (.changeset/config.json -> updateInternalDependents: always).",
45
+ " That is the ONLY reason a base-only change republishes mcp with fresh metadata.",
46
+ "Removing them breaks NOTHING visibly: extraction still works (scripts read ../../base/src",
47
+ "by relative path), the build still passes — but mcp silently stops being republished and",
48
+ "consumers keep receiving stale metadata forever. Guarded by `pnpm check:wiring`.",
49
+ "See 아키텍쳐.md section 6."
50
+ ],
34
51
  "devDependencies": {
35
52
  "@types/node": "^22.0.0",
36
53
  "ts-morph": "^24.0.0",
37
54
  "tsup": "7.2.0",
38
- "typescript": "^5.9.0",
39
- "@shoplflow/base": "0.48.0",
40
- "@shoplflow/hada-assets": "0.1.10",
41
- "@shoplflow/shopl-assets": "0.12.44"
55
+ "typescript": "6.0.3",
56
+ "@shoplflow/base": "0.48.11",
57
+ "@shoplflow/shopl-assets": "0.12.49",
58
+ "@shoplflow/hada-assets": "0.1.11"
42
59
  },
43
60
  "repository": {
44
61
  "type": "git",
@@ -54,6 +71,7 @@
54
71
  "build:package": "pnpm generate:metadata && rm -rf dist/ && tsup",
55
72
  "dev": "pnpm generate:metadata && tsup --watch",
56
73
  "start": "node dist/index.js",
74
+ "check:wiring": "node scripts/check-release-wiring.cjs",
57
75
  "type-check": "tsc --noEmit || true"
58
76
  }
59
77
  }