@monoharada/wcf-mcp 0.1.2 → 0.2.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,7 @@ 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 スニペットを検証し、未知要素・不正enum値・不正スロット名・必須属性欠落(error)、未知属性・トークン誤用・`aria-live`/`role="alert"` 誤用・親子関係違反・空インタラクティブ要素(warning)を検出し、`suggestion` を返す |
74
104
 
75
105
  ### UI パターン
76
106
 
@@ -84,10 +114,141 @@ claude mcp add wcf -- npx @monoharada/wcf-mcp
84
114
 
85
115
  | ツール | 説明 |
86
116
  |--------|------|
87
- | `get_design_tokens` | デザイントークンを type/category/query で検索 |
117
+ | `get_design_tokens` | デザイントークンを type/category/query/theme で検索(`theme=light` のみ。`dark/all` はエラー) |
118
+ | `get_design_token_detail` | 単一トークンの詳細(references/referencedBy/relatedTokens/usageExamples)を取得 |
88
119
  | `get_accessibility_docs` | component/topic/wcagLevel で A11y チェックリストとガイドライン要点を検索(`topic=all` では両ソースを混在返却) |
89
120
  | `search_guidelines` | ガイドライン(topic/query)をスコア付きで検索 |
90
121
 
122
+ #### `get_design_tokens` の使用例
123
+
124
+ **リクエスト:**
125
+ ```json
126
+ {
127
+ "name": "get_design_tokens",
128
+ "arguments": {
129
+ "type": "color",
130
+ "category": "semantic",
131
+ "theme": "light"
132
+ }
133
+ }
134
+ ```
135
+
136
+ **レスポンス(抜粋):**
137
+ ```json
138
+ {
139
+ "summary": {
140
+ "totalCount": 42,
141
+ "types": { "color": 42 }
142
+ },
143
+ "tokens": [
144
+ {
145
+ "name": "--color-primary",
146
+ "type": "color",
147
+ "category": "semantic",
148
+ "value": "#0017C1",
149
+ "cssVariable": "var(--color-primary)"
150
+ }
151
+ ],
152
+ "themes": {
153
+ "requested": "light",
154
+ "resolved": "light",
155
+ "available": ["light"]
156
+ }
157
+ }
158
+ ```
159
+
160
+ #### `get_design_token_detail` の使用例
161
+
162
+ **リクエスト:**
163
+ ```json
164
+ {
165
+ "name": "get_design_token_detail",
166
+ "arguments": {
167
+ "name": "--color-primary",
168
+ "theme": "light"
169
+ }
170
+ }
171
+ ```
172
+
173
+ **レスポンス(抜粋):**
174
+ ```json
175
+ {
176
+ "token": {
177
+ "name": "--color-primary",
178
+ "type": "color",
179
+ "category": "semantic",
180
+ "value": "#0017C1",
181
+ "cssVariable": "var(--color-primary)",
182
+ "group": "color"
183
+ },
184
+ "references": [
185
+ { "name": "--primitive-blue-700", "type": "color", "category": "primitive" }
186
+ ],
187
+ "referencedBy": [
188
+ { "name": "--button-primary-bg", "type": "color", "category": "semantic" }
189
+ ],
190
+ "relatedTokens": ["--button-primary-bg"],
191
+ "usageExamples": [
192
+ ".example { color: var(--color-primary); }",
193
+ ".example { background-color: var(--color-primary); }"
194
+ ],
195
+ "theme": {
196
+ "requested": "light",
197
+ "resolved": "light",
198
+ "available": ["light"]
199
+ }
200
+ }
201
+ ```
202
+
203
+ > **注意**: `theme` は `"light"` のみサポート。`"dark"` や `"all"` を指定すると `INVALID_THEME` エラーが返ります。
204
+
205
+ ### Prompt
206
+
207
+ | 名前 | 説明 |
208
+ |------|------|
209
+ | `figma_to_wcf` | Figma URL を入力に、`overview → tokens → component api → snippet → validate` の実行順を返す |
210
+
211
+ ### Resources (`wcf://`)
212
+
213
+ | URI | 説明 |
214
+ |-----|------|
215
+ | `wcf://components` | コンポーネントカタログのスナップショット |
216
+ | `wcf://tokens` | トークン summary(type/category/themes/sample) |
217
+ | `wcf://guidelines/{topic}` | topic 別ガイドライン要約(`accessibility`,`css`,`patterns`,`all`) |
218
+ | `wcf://llms-full` | `llms-full.txt` の全文 |
219
+
220
+ ### Figma MCP との併用
221
+
222
+ Figma Dev Mode MCP Server (`@anthropic/figma-dev-mode-mcp-server`) と wcf-mcp を並行で利用すると、Figma デザインから WCF コンポーネントへの変換ワークフローが実現できます。
223
+
224
+ **推奨ワークフロー:**
225
+
226
+ 1. **Figma MCP** → `get_design_context` でデザインの構造・カラー・スペーシングを取得
227
+ 2. **wcf-mcp** → `get_design_system_overview` で利用可能なコンポーネントを確認
228
+ 3. **wcf-mcp** → `get_design_tokens` で Figma カラー値に対応するトークンを検索
229
+ 4. **wcf-mcp** → `get_component_api` でコンポーネント仕様を取得
230
+ 5. **wcf-mcp** → `generate_usage_snippet` でコード生成
231
+ 6. **wcf-mcp** → `validate_markup` で生成コードを検証
232
+
233
+ **Claude Desktop 設定例:**
234
+
235
+ ```json
236
+ {
237
+ "mcpServers": {
238
+ "wcf": {
239
+ "command": "npx",
240
+ "args": ["@monoharada/wcf-mcp"]
241
+ },
242
+ "figma": {
243
+ "command": "npx",
244
+ "args": ["@anthropic/figma-dev-mode-mcp-server"]
245
+ }
246
+ }
247
+ }
248
+ ```
249
+
250
+ > `figma_to_wcf` プロンプトは wcf-mcp に組み込まれており、Figma URL を入力として上記ワークフローの実行順序をガイドします。
251
+
91
252
  ## transport
92
253
 
93
254
  標準は stdio です。HTTP transport も利用できます(localhost のみ)。
@@ -99,9 +260,64 @@ npx @monoharada/wcf-mcp --transport=http --port=3100
99
260
  - bind: `127.0.0.1`
100
261
  - endpoint: `http://127.0.0.1:3100/mcp`
101
262
 
263
+ ## 設定ファイル
264
+
265
+ `wcf-mcp.config.json` を使うと、データソース差し替えとカスタムツール追加ができます。
266
+
267
+ - デフォルト探索パス: カレントディレクトリの `wcf-mcp.config.json`
268
+ - 明示指定: `npx @monoharada/wcf-mcp --config=./wcf-mcp.config.json`
269
+ - 互換性: 設定ファイルが無ければ従来どおり標準データで起動
270
+
271
+ `dataSources` の相対パス基準:
272
+
273
+ - ルート `dataSources`: config ファイルのディレクトリ基準
274
+ - `plugins[].staticTools` を持つ static plugin の `dataSources`: config ファイルのディレクトリ基準
275
+ - `plugins[].module` が export する plugin の `dataSources`: plugin module ファイルのディレクトリ基準
276
+
277
+ ### config 例
278
+
279
+ ```json
280
+ {
281
+ "dataSources": {
282
+ "guidelines-index.json": "./guidelines-index.local.json"
283
+ },
284
+ "plugins": [
285
+ {
286
+ "module": "./plugins/custom-validation-plugin.mjs"
287
+ },
288
+ {
289
+ "name": "static-tools-plugin",
290
+ "version": "0.1.0",
291
+ "staticTools": [
292
+ {
293
+ "name": "plugin_healthcheck",
294
+ "payload": { "ok": true }
295
+ }
296
+ ]
297
+ }
298
+ ]
299
+ }
300
+ ```
301
+
302
+ ※ `./plugins/custom-validation-plugin.mjs` は利用側プロジェクトに配置してください。
303
+ このリポジトリには参照用として `packages/mcp-server/examples/plugins/custom-validation-plugin.mjs` を同梱しています。
304
+
305
+ ### plugin 契約(v1)
306
+
307
+ 詳細仕様: [docs/plugin-contract-v1.md](../../docs/plugin-contract-v1.md)
308
+
309
+ - `plugins[].name` / `plugins[].version` は必須
310
+ - tool 名は組み込みツール名と重複不可(例: `list_components` など)
311
+ - `dataSources` で差し替え可能な key は次のみ
312
+ - `custom-elements.json`
313
+ - `install-registry.json`
314
+ - `pattern-registry.json`
315
+ - `design-tokens.json`
316
+ - `guidelines-index.json`
317
+
102
318
  ## structuredContent rollback
103
319
 
104
- `get_component_api` / `get_design_tokens` / `get_accessibility_docs` / `search_guidelines` は通常 `structuredContent` を返します。
320
+ `get_component_api` / `get_design_tokens` / `get_design_token_detail` / `get_accessibility_docs` / `search_guidelines` は通常 `structuredContent` を返します。
105
321
 
106
322
  - 100KB 制限を超える場合は自動的に `structuredContent` を省略し、`content` のみ返します
107
323
  - 緊急切り戻し時は環境変数 `WCF_MCP_DISABLE_STRUCTURED_CONTENT=1` を設定してください
@@ -139,8 +355,48 @@ Claude Desktop 設定例:
139
355
  prefix: "myui" → dads-button → myui-button
140
356
  ```
141
357
 
358
+ ## v0.2.0 マイグレーション
359
+
360
+ ### `list_components` のデフォルトページネーション変更
361
+
362
+ v0.2.0 から `list_components` のデフォルト返却件数が **全件 → 20件** に変更されました。
363
+
364
+ - `limit` を省略すると 20件が返り、`_notice` フィールドで変更を通知します
365
+ - 全件取得が必要な場合: `limit: 200` を指定してください
366
+ - `hasMore: true` の場合、`offset` で次のページを取得できます
367
+
368
+ ```json
369
+ // 全件取得
370
+ { "name": "list_components", "arguments": { "limit": 200 } }
371
+ // ページネーション
372
+ { "name": "list_components", "arguments": { "limit": 20, "offset": 20 } }
373
+ ```
374
+
142
375
  ## ツール使用例
143
376
 
377
+ ### コンポーネント一覧を取得
378
+
379
+ ```json
380
+ {
381
+ "name": "list_components",
382
+ "arguments": { "category": "Form", "limit": 20 }
383
+ }
384
+ ```
385
+
386
+ レスポンス(抜粋):
387
+ ```json
388
+ {
389
+ "items": [
390
+ { "tagName": "dads-input-text", "className": "DadsInputText", "category": "Form" },
391
+ { "tagName": "dads-textarea", "className": "DadsTextarea", "category": "Form" }
392
+ ],
393
+ "total": 8,
394
+ "limit": 20,
395
+ "offset": 0,
396
+ "hasMore": false
397
+ }
398
+ ```
399
+
144
400
  ### コンポーネント API を取得
145
401
 
146
402
  ```json
@@ -150,15 +406,14 @@ prefix: "myui" → dads-button → myui-button
150
406
  }
151
407
  ```
152
408
 
153
- レスポンス:
409
+ レスポンス(抜粋):
154
410
  ```json
155
411
  {
156
412
  "tagName": "dads-button",
157
413
  "className": "DadsButton",
158
414
  "attributes": [
159
415
  { "name": "variant", "type": "'solid' | 'outlined' | 'text'" },
160
- { "name": "size", "type": "'x-small' | 'small' | 'medium' | 'large'" },
161
- ...
416
+ { "name": "size", "type": "'x-small' | 'small' | 'medium' | 'large'" }
162
417
  ],
163
418
  "slots": [...],
164
419
  "cssParts": [...],
@@ -167,6 +422,43 @@ prefix: "myui" → dads-button → myui-button
167
422
  }
168
423
  ```
169
424
 
425
+ ### 使い方スニペットを生成
426
+
427
+ ```json
428
+ {
429
+ "name": "generate_usage_snippet",
430
+ "arguments": { "component": "dads-button" }
431
+ }
432
+ ```
433
+
434
+ レスポンス(テキスト形式 — HTML スニペットをそのまま返します):
435
+ ```html
436
+ <dads-button variant="solid">Label</dads-button>
437
+ ```
438
+
439
+ ### インストール手順を取得
440
+
441
+ ```json
442
+ {
443
+ "name": "get_install_recipe",
444
+ "arguments": { "component": "dads-combobox" }
445
+ }
446
+ ```
447
+
448
+ レスポンス(抜粋):
449
+ ```json
450
+ {
451
+ "componentId": "combobox",
452
+ "tagNames": ["dads-combobox"],
453
+ "deps": ["avatar", "chip-tag", "icon"],
454
+ "transitiveDeps": ["avatar", "chip-tag", "icon"],
455
+ "define": "defineCombobox",
456
+ "installHint": "wcf add combobox"
457
+ }
458
+ ```
459
+
460
+ > `transitiveDeps` は BFS で解決された全推移的依存(自身を除く)の配列です。
461
+
170
462
  ### HTML バリデーション
171
463
 
172
464
  ```json
@@ -192,6 +484,54 @@ prefix: "myui" → dads-button → myui-button
192
484
  }
193
485
  ```
194
486
 
487
+ ### ガイドライン検索
488
+
489
+ ```json
490
+ {
491
+ "name": "search_guidelines",
492
+ "arguments": { "query": "keyboard", "topic": "accessibility" }
493
+ }
494
+ ```
495
+
496
+ レスポンス(抜粋):
497
+ ```json
498
+ {
499
+ "query": "keyboard",
500
+ "topic": "accessibility",
501
+ "totalHits": 3,
502
+ "results": [
503
+ {
504
+ "score": 5,
505
+ "title": "Keyboard Navigation",
506
+ "topic": "accessibility",
507
+ "heading": "Keyboard Navigation",
508
+ "snippet": "All interactive elements must be operable via keyboard..."
509
+ }
510
+ ]
511
+ }
512
+ ```
513
+
514
+ ## スニペット vs レシピ
515
+
516
+ | 用途 | ツール | 返すもの |
517
+ |------|--------|----------|
518
+ | 最小限 HTML を素早く確認 | `generate_usage_snippet` | 単一コンポーネントの HTML 断片 |
519
+ | 画面パターン全体を構築 | `get_pattern_recipe` | 必要コンポーネント群 + 依存解決 + 完全 HTML |
520
+
521
+ **使い分け**: 1 コンポーネントだけ使う場合は `generate_usage_snippet`。複数コンポーネントを組み合わせた UI パターン(フォーム、カード一覧など)には `get_pattern_recipe` を使用。
522
+
523
+ ## noscript ガイダンス
524
+
525
+ WCF コンポーネントは JavaScript が必須です。`<noscript>` タグを使い、JavaScript 無効環境に対してフォールバックを提供してください。
526
+
527
+ ```html
528
+ <noscript>
529
+ <p>このページは JavaScript を有効にする必要があります。</p>
530
+ </noscript>
531
+ ```
532
+
533
+ `get_design_system_overview` の `setupInfo.noscriptGuidance` にも同様の案内が含まれています。
534
+
195
535
  ## 開発者向け
196
536
 
197
537
  ### リポジトリからの起動
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(