@monoharada/wcf-mcp 0.1.2 → 0.5.0

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.
package/README.md CHANGED
@@ -48,7 +48,37 @@ claude mcp add wcf -- npx @monoharada/wcf-mcp
48
48
  }
49
49
  ```
50
50
 
51
- ## 提供ツール(13個)
51
+ ### VS Code (GitHub Copilot) で使う
52
+
53
+ `.vscode/mcp.json` に追加:
54
+
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "wcf": {
59
+ "command": "npx",
60
+ "args": ["@monoharada/wcf-mcp"]
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### Windsurf で使う
67
+
68
+ `.windsurf/mcp_config.json` に追加:
69
+
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "wcf": {
74
+ "command": "npx",
75
+ "args": ["@monoharada/wcf-mcp"]
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ## 提供機能(14 tools + 1 prompt + 4 resources)
52
82
 
53
83
  ### ガードレール
54
84
 
@@ -60,7 +90,7 @@ claude mcp add wcf -- npx @monoharada/wcf-mcp
60
90
 
61
91
  | ツール | 説明 |
62
92
  |--------|------|
63
- | `list_components` | カテゴリ/クエリ/limit/offset でコンポーネントを段階的に取得(互換維持のため limit 未指定時は全件) |
93
+ | `list_components` | カテゴリ/クエリ/limit/offset でコンポーネントを段階的に取得(デフォルト20件。全件取得は `limit: 200`) |
64
94
  | `search_icons` | アイコン名をキーワード検索し、usage example を返す |
65
95
  | `get_component_api` | tagName or className で属性・スロット・イベント・CSS Parts・CSS Custom Properties を取得(`relatedComponents` を含む) |
66
96
  | `generate_usage_snippet` | コンポーネントの最小限 HTML スニペットを生成 |
@@ -70,7 +100,24 @@ claude mcp add wcf -- npx @monoharada/wcf-mcp
70
100
 
71
101
  | ツール | 説明 |
72
102
  |--------|------|
73
- | `validate_markup` | HTML スニペットを検証し、未知要素(error)・未知属性(warning)・禁止属性/トークン誤用/`aria-live`・`role="alert"` の誤用(warning)を検出し、可能な場合は `suggestion` を返す |
103
+ | `validate_markup` | HTML スニペットを検証し、セマンティック検証(下表)で `suggestion` 付き診断を返す |
104
+
105
+ #### validate_markup 検出コード一覧
106
+
107
+ | Code | Severity | 説明 | 例 |
108
+ |------|----------|------|----|
109
+ | `unknownElement` | error | CEM に未登録のカスタム要素。prefix 補完提案あり | `<input-text>` → `dads-input-text` |
110
+ | `unknownAttribute` | warning | CEM に未登録の属性 | `<dads-button foo="x">` |
111
+ | `invalidEnumValue` | error | enum 属性に不正な値 | `type="banana"` |
112
+ | `invalidSlotName` | error | CEM に未登録のスロット名 | `slot="nonexistent"` |
113
+ | `missingRequiredAttribute` | error | フォーム要素の必須属性欠落 | `<dads-input-text>` without `label` |
114
+ | `orphanedChildComponent` | warning | 親要素なしの子コンポーネント | `<dads-breadcrumb-item>` without `<dads-breadcrumb>` |
115
+ | `emptyInteractiveElement` | warning | accessible name が空の操作要素 | `<dads-button></dads-button>` |
116
+ | `canonicalLowercaseRecommendation` | warning | 大文字を含む属性名(lowercase が canonical) | `Variant="solid"` → `variant` |
117
+ | `tokenMisuse` | warning | inline style でのトークン誤用 | `color: #000` → `var(--color-*)` |
118
+ | `ariaLiveNotRecommended` | warning | `aria-live` の使用(DADS 非推奨) | `aria-live="polite"` |
119
+ | `roleAlertNotRecommended` | warning | `role="alert"` の使用(DADS 非推奨) | `role="alert"` |
120
+ | `forbiddenAttribute` | warning | 禁止属性 | `placeholder` |
74
121
 
75
122
  ### UI パターン
76
123
 
@@ -84,10 +131,141 @@ claude mcp add wcf -- npx @monoharada/wcf-mcp
84
131
 
85
132
  | ツール | 説明 |
86
133
  |--------|------|
87
- | `get_design_tokens` | デザイントークンを type/category/query で検索 |
134
+ | `get_design_tokens` | デザイントークンを type/category/query/theme で検索(`theme=light` のみ。`dark/all` はエラー) |
135
+ | `get_design_token_detail` | 単一トークンの詳細(references/referencedBy/relatedTokens/usageExamples)を取得 |
88
136
  | `get_accessibility_docs` | component/topic/wcagLevel で A11y チェックリストとガイドライン要点を検索(`topic=all` では両ソースを混在返却) |
89
137
  | `search_guidelines` | ガイドライン(topic/query)をスコア付きで検索 |
90
138
 
139
+ #### `get_design_tokens` の使用例
140
+
141
+ **リクエスト:**
142
+ ```json
143
+ {
144
+ "name": "get_design_tokens",
145
+ "arguments": {
146
+ "type": "color",
147
+ "category": "semantic",
148
+ "theme": "light"
149
+ }
150
+ }
151
+ ```
152
+
153
+ **レスポンス(抜粋):**
154
+ ```json
155
+ {
156
+ "summary": {
157
+ "totalCount": 42,
158
+ "types": { "color": 42 }
159
+ },
160
+ "tokens": [
161
+ {
162
+ "name": "--color-primary",
163
+ "type": "color",
164
+ "category": "semantic",
165
+ "value": "#0017C1",
166
+ "cssVariable": "var(--color-primary)"
167
+ }
168
+ ],
169
+ "themes": {
170
+ "requested": "light",
171
+ "resolved": "light",
172
+ "available": ["light"]
173
+ }
174
+ }
175
+ ```
176
+
177
+ #### `get_design_token_detail` の使用例
178
+
179
+ **リクエスト:**
180
+ ```json
181
+ {
182
+ "name": "get_design_token_detail",
183
+ "arguments": {
184
+ "name": "--color-primary",
185
+ "theme": "light"
186
+ }
187
+ }
188
+ ```
189
+
190
+ **レスポンス(抜粋):**
191
+ ```json
192
+ {
193
+ "token": {
194
+ "name": "--color-primary",
195
+ "type": "color",
196
+ "category": "semantic",
197
+ "value": "#0017C1",
198
+ "cssVariable": "var(--color-primary)",
199
+ "group": "color"
200
+ },
201
+ "references": [
202
+ { "name": "--primitive-blue-700", "type": "color", "category": "primitive" }
203
+ ],
204
+ "referencedBy": [
205
+ { "name": "--button-primary-bg", "type": "color", "category": "semantic" }
206
+ ],
207
+ "relatedTokens": ["--button-primary-bg"],
208
+ "usageExamples": [
209
+ ".example { color: var(--color-primary); }",
210
+ ".example { background-color: var(--color-primary); }"
211
+ ],
212
+ "theme": {
213
+ "requested": "light",
214
+ "resolved": "light",
215
+ "available": ["light"]
216
+ }
217
+ }
218
+ ```
219
+
220
+ > **注意**: `theme` は `"light"` のみサポート。`"dark"` や `"all"` を指定すると `INVALID_THEME` エラーが返ります。
221
+
222
+ ### Prompt
223
+
224
+ | 名前 | 説明 |
225
+ |------|------|
226
+ | `figma_to_wcf` | Figma URL を入力に、`overview → tokens → component api → snippet → validate` の実行順を返す |
227
+
228
+ ### Resources (`wcf://`)
229
+
230
+ | URI | 説明 |
231
+ |-----|------|
232
+ | `wcf://components` | コンポーネントカタログのスナップショット |
233
+ | `wcf://tokens` | トークン summary(type/category/themes/sample) |
234
+ | `wcf://guidelines/{topic}` | topic 別ガイドライン要約(`accessibility`,`css`,`patterns`,`all`) |
235
+ | `wcf://llms-full` | `llms-full.txt` の全文 |
236
+
237
+ ### Figma MCP との併用
238
+
239
+ Figma Dev Mode MCP Server (`@anthropic/figma-dev-mode-mcp-server`) と wcf-mcp を並行で利用すると、Figma デザインから WCF コンポーネントへの変換ワークフローが実現できます。
240
+
241
+ **推奨ワークフロー:**
242
+
243
+ 1. **Figma MCP** → `get_design_context` でデザインの構造・カラー・スペーシングを取得
244
+ 2. **wcf-mcp** → `get_design_system_overview` で利用可能なコンポーネントを確認
245
+ 3. **wcf-mcp** → `get_design_tokens` で Figma カラー値に対応するトークンを検索
246
+ 4. **wcf-mcp** → `get_component_api` でコンポーネント仕様を取得
247
+ 5. **wcf-mcp** → `generate_usage_snippet` でコード生成
248
+ 6. **wcf-mcp** → `validate_markup` で生成コードを検証
249
+
250
+ **Claude Desktop 設定例:**
251
+
252
+ ```json
253
+ {
254
+ "mcpServers": {
255
+ "wcf": {
256
+ "command": "npx",
257
+ "args": ["@monoharada/wcf-mcp"]
258
+ },
259
+ "figma": {
260
+ "command": "npx",
261
+ "args": ["@anthropic/figma-dev-mode-mcp-server"]
262
+ }
263
+ }
264
+ }
265
+ ```
266
+
267
+ > `figma_to_wcf` プロンプトは wcf-mcp に組み込まれており、Figma URL を入力として上記ワークフローの実行順序をガイドします。
268
+
91
269
  ## transport
92
270
 
93
271
  標準は stdio です。HTTP transport も利用できます(localhost のみ)。
@@ -99,9 +277,64 @@ npx @monoharada/wcf-mcp --transport=http --port=3100
99
277
  - bind: `127.0.0.1`
100
278
  - endpoint: `http://127.0.0.1:3100/mcp`
101
279
 
280
+ ## 設定ファイル
281
+
282
+ `wcf-mcp.config.json` を使うと、データソース差し替えとカスタムツール追加ができます。
283
+
284
+ - デフォルト探索パス: カレントディレクトリの `wcf-mcp.config.json`
285
+ - 明示指定: `npx @monoharada/wcf-mcp --config=./wcf-mcp.config.json`
286
+ - 互換性: 設定ファイルが無ければ従来どおり標準データで起動
287
+
288
+ `dataSources` の相対パス基準:
289
+
290
+ - ルート `dataSources`: config ファイルのディレクトリ基準
291
+ - `plugins[].staticTools` を持つ static plugin の `dataSources`: config ファイルのディレクトリ基準
292
+ - `plugins[].module` が export する plugin の `dataSources`: plugin module ファイルのディレクトリ基準
293
+
294
+ ### config 例
295
+
296
+ ```json
297
+ {
298
+ "dataSources": {
299
+ "guidelines-index.json": "./guidelines-index.local.json"
300
+ },
301
+ "plugins": [
302
+ {
303
+ "module": "./plugins/custom-validation-plugin.mjs"
304
+ },
305
+ {
306
+ "name": "static-tools-plugin",
307
+ "version": "0.1.0",
308
+ "staticTools": [
309
+ {
310
+ "name": "plugin_healthcheck",
311
+ "payload": { "ok": true }
312
+ }
313
+ ]
314
+ }
315
+ ]
316
+ }
317
+ ```
318
+
319
+ ※ `./plugins/custom-validation-plugin.mjs` は利用側プロジェクトに配置してください。
320
+ このリポジトリには参照用として `packages/mcp-server/examples/plugins/custom-validation-plugin.mjs` を同梱しています。
321
+
322
+ ### plugin 契約(v1)
323
+
324
+ 詳細仕様: [docs/plugin-contract-v1.md](../../docs/plugin-contract-v1.md)
325
+
326
+ - `plugins[].name` / `plugins[].version` は必須
327
+ - tool 名は組み込みツール名と重複不可(例: `list_components` など)
328
+ - `dataSources` で差し替え可能な key は次のみ
329
+ - `custom-elements.json`
330
+ - `install-registry.json`
331
+ - `pattern-registry.json`
332
+ - `design-tokens.json`
333
+ - `guidelines-index.json`
334
+
102
335
  ## structuredContent rollback
103
336
 
104
- `get_component_api` / `get_design_tokens` / `get_accessibility_docs` / `search_guidelines` は通常 `structuredContent` を返します。
337
+ `get_component_api` / `get_design_tokens` / `get_design_token_detail` / `get_accessibility_docs` / `search_guidelines` は通常 `structuredContent` を返します。
105
338
 
106
339
  - 100KB 制限を超える場合は自動的に `structuredContent` を省略し、`content` のみ返します
107
340
  - 緊急切り戻し時は環境変数 `WCF_MCP_DISABLE_STRUCTURED_CONTENT=1` を設定してください
@@ -139,8 +372,81 @@ Claude Desktop 設定例:
139
372
  prefix: "myui" → dads-button → myui-button
140
373
  ```
141
374
 
375
+ ## v0.3.0 新機能 — ランタイムセットアップ情報
376
+
377
+ v0.3.0 では、AI エージェントが CDN 非対応の vendor-local 配信モデルを正しく理解できるよう、3つのツールにランタイムセットアップ情報を追加しました。
378
+
379
+ ### `get_design_system_overview` — setupInfo 新フィールド
380
+
381
+ | フィールド | 型 | 説明 |
382
+ |-----------|-----|------|
383
+ | `noCDN` | `true` | CDN 配信が利用不可であることを示すフラグ |
384
+ | `deliveryModel` | `"vendor-local"` | 配信モデルの種別(将来拡張可能) |
385
+ | `importMapHint` | `string` | import map のパターン説明 |
386
+ | `bootScript` | `string` | boot.js の役割説明 |
387
+ | `vendorSetup` | `object` | `init`/`add`/`workflow` の2段階セットアップガイド |
388
+ | `htmlSetup` | `string` | import map + boot.js を含む完全な HTML head テンプレート |
389
+
390
+ > 既存の `htmlBoilerplate` は変更なし(後方互換性)
391
+
392
+ ### `get_install_recipe` — 新フィールド
393
+
394
+ | フィールド | 型 | 説明 |
395
+ |-----------|-----|------|
396
+ | `usageContext` | `"body-only"` | `usageSnippet` が body 用 HTML であることを明示 |
397
+ | `vendorHint` | `object` | `install`(CLI コマンド)、`importMap`(テンプレート)、`boot`(ブートスクリプト説明)。`importmap`(小文字 m)は非推奨エイリアス — v1.0 で削除予定 |
398
+
399
+ ### `get_pattern_recipe` — 新フィールド
400
+
401
+ | フィールド | 型 | 説明 |
402
+ |-----------|-----|------|
403
+ | `entryHints` | `string[]` | パターンのエントリポイント(`["boot"]` など) |
404
+ | `scaffoldHint` | `object` | `doctype`、`importMap`、`bootScript`、`noscript`、`serveOverHttp` を含むページ雛形情報 |
405
+
406
+ > `scaffoldHint.serveOverHttp` は `file://` プロトコルでの実行を防止するガイダンスです。
407
+
408
+ ## v0.2.0 マイグレーション
409
+
410
+ ### `list_components` のデフォルトページネーション変更
411
+
412
+ v0.2.0 から `list_components` のデフォルト返却件数が **全件 → 20件** に変更されました。
413
+
414
+ - `limit` を省略すると 20件が返り、`_notice` フィールドで変更を通知します
415
+ - 全件取得が必要な場合: `limit: 200` を指定してください
416
+ - `hasMore: true` の場合、`offset` で次のページを取得できます
417
+
418
+ ```json
419
+ // 全件取得
420
+ { "name": "list_components", "arguments": { "limit": 200 } }
421
+ // ページネーション
422
+ { "name": "list_components", "arguments": { "limit": 20, "offset": 20 } }
423
+ ```
424
+
142
425
  ## ツール使用例
143
426
 
427
+ ### コンポーネント一覧を取得
428
+
429
+ ```json
430
+ {
431
+ "name": "list_components",
432
+ "arguments": { "category": "Form", "limit": 20 }
433
+ }
434
+ ```
435
+
436
+ レスポンス(抜粋):
437
+ ```json
438
+ {
439
+ "items": [
440
+ { "tagName": "dads-input-text", "className": "DadsInputText", "category": "Form" },
441
+ { "tagName": "dads-textarea", "className": "DadsTextarea", "category": "Form" }
442
+ ],
443
+ "total": 8,
444
+ "limit": 20,
445
+ "offset": 0,
446
+ "hasMore": false
447
+ }
448
+ ```
449
+
144
450
  ### コンポーネント API を取得
145
451
 
146
452
  ```json
@@ -150,15 +456,14 @@ prefix: "myui" → dads-button → myui-button
150
456
  }
151
457
  ```
152
458
 
153
- レスポンス:
459
+ レスポンス(抜粋):
154
460
  ```json
155
461
  {
156
462
  "tagName": "dads-button",
157
463
  "className": "DadsButton",
158
464
  "attributes": [
159
465
  { "name": "variant", "type": "'solid' | 'outlined' | 'text'" },
160
- { "name": "size", "type": "'x-small' | 'small' | 'medium' | 'large'" },
161
- ...
466
+ { "name": "size", "type": "'x-small' | 'small' | 'medium' | 'large'" }
162
467
  ],
163
468
  "slots": [...],
164
469
  "cssParts": [...],
@@ -167,6 +472,43 @@ prefix: "myui" → dads-button → myui-button
167
472
  }
168
473
  ```
169
474
 
475
+ ### 使い方スニペットを生成
476
+
477
+ ```json
478
+ {
479
+ "name": "generate_usage_snippet",
480
+ "arguments": { "component": "dads-button" }
481
+ }
482
+ ```
483
+
484
+ レスポンス(テキスト形式 — HTML スニペットをそのまま返します):
485
+ ```html
486
+ <dads-button variant="solid">Label</dads-button>
487
+ ```
488
+
489
+ ### インストール手順を取得
490
+
491
+ ```json
492
+ {
493
+ "name": "get_install_recipe",
494
+ "arguments": { "component": "dads-combobox" }
495
+ }
496
+ ```
497
+
498
+ レスポンス(抜粋):
499
+ ```json
500
+ {
501
+ "componentId": "combobox",
502
+ "tagNames": ["dads-combobox"],
503
+ "deps": ["avatar", "chip-tag", "icon"],
504
+ "transitiveDeps": ["avatar", "chip-tag", "icon"],
505
+ "define": "defineCombobox",
506
+ "installHint": "wcf add combobox"
507
+ }
508
+ ```
509
+
510
+ > `transitiveDeps` は BFS で解決された全推移的依存(自身を除く)の配列です。
511
+
170
512
  ### HTML バリデーション
171
513
 
172
514
  ```json
@@ -192,6 +534,54 @@ prefix: "myui" → dads-button → myui-button
192
534
  }
193
535
  ```
194
536
 
537
+ ### ガイドライン検索
538
+
539
+ ```json
540
+ {
541
+ "name": "search_guidelines",
542
+ "arguments": { "query": "keyboard", "topic": "accessibility" }
543
+ }
544
+ ```
545
+
546
+ レスポンス(抜粋):
547
+ ```json
548
+ {
549
+ "query": "keyboard",
550
+ "topic": "accessibility",
551
+ "totalHits": 3,
552
+ "results": [
553
+ {
554
+ "score": 5,
555
+ "title": "Keyboard Navigation",
556
+ "topic": "accessibility",
557
+ "heading": "Keyboard Navigation",
558
+ "snippet": "All interactive elements must be operable via keyboard..."
559
+ }
560
+ ]
561
+ }
562
+ ```
563
+
564
+ ## スニペット vs レシピ
565
+
566
+ | 用途 | ツール | 返すもの |
567
+ |------|--------|----------|
568
+ | 最小限 HTML を素早く確認 | `generate_usage_snippet` | 単一コンポーネントの HTML 断片 |
569
+ | 画面パターン全体を構築 | `get_pattern_recipe` | 必要コンポーネント群 + 依存解決 + 完全 HTML |
570
+
571
+ **使い分け**: 1 コンポーネントだけ使う場合は `generate_usage_snippet`。複数コンポーネントを組み合わせた UI パターン(フォーム、カード一覧など)には `get_pattern_recipe` を使用。
572
+
573
+ ## noscript ガイダンス
574
+
575
+ WCF コンポーネントは JavaScript が必須です。`<noscript>` タグを使い、JavaScript 無効環境に対してフォールバックを提供してください。
576
+
577
+ ```html
578
+ <noscript>
579
+ <p>このページは JavaScript を有効にする必要があります。</p>
580
+ </noscript>
581
+ ```
582
+
583
+ `get_design_system_overview` の `setupInfo.noscriptGuidance` にも同様の案内が含まれています。
584
+
195
585
  ## 開発者向け
196
586
 
197
587
  ### リポジトリからの起動
package/bin.mjs CHANGED
@@ -16,12 +16,14 @@ const USAGE = [
16
16
  ' wcf-mcp',
17
17
  ' wcf-mcp --transport=stdio',
18
18
  ' wcf-mcp --transport=http [--port=3100]',
19
+ ' wcf-mcp --config=./wcf-mcp.config.json',
19
20
  ' wcf-mcp --help',
20
21
  ].join('\n');
21
22
 
22
23
  function parseArgs(argv) {
23
24
  let transport = 'stdio';
24
25
  let port = 3100;
26
+ let configPath;
25
27
 
26
28
  for (let index = 0; index < argv.length; index += 1) {
27
29
  const arg = argv[index];
@@ -54,11 +56,26 @@ function parseArgs(argv) {
54
56
  continue;
55
57
  }
56
58
 
59
+ if (arg === '--config') {
60
+ const value = argv[index + 1];
61
+ if (!value || value.startsWith('--')) {
62
+ throw new Error('--config requires a file path');
63
+ }
64
+ configPath = value;
65
+ index += 1;
66
+ continue;
67
+ }
68
+
57
69
  if (arg.startsWith('--port=')) {
58
70
  port = Number(arg.slice('--port='.length));
59
71
  continue;
60
72
  }
61
73
 
74
+ if (arg.startsWith('--config=')) {
75
+ configPath = arg.slice('--config='.length);
76
+ continue;
77
+ }
78
+
62
79
  throw new Error(`Unknown argument: ${arg}`);
63
80
  }
64
81
 
@@ -70,7 +87,7 @@ function parseArgs(argv) {
70
87
  throw new Error(`Invalid port: ${String(port)} (expected: integer 1-65535)`);
71
88
  }
72
89
 
73
- return { help: false, transport, port };
90
+ return { help: false, transport, port, configPath };
74
91
  }
75
92
 
76
93
  async function main() {
@@ -89,7 +106,7 @@ async function main() {
89
106
  return;
90
107
  }
91
108
 
92
- const { server } = await createServer();
109
+ const { server } = await createServer({ configPath: parsed.configPath });
93
110
 
94
111
  if (parsed.transport === 'http') {
95
112
  const { StreamableHTTPServerTransport } = await import(