STEP 1589 — MCP tool migration audit
目的
藤本さん directive「82+ 全 MCP tool の migration 自動化 script」 応答。 STEP 1533 wrapper factory + STEP 1571/1576/1579/1584 積み上げの 適用対象を audit script で明示化する。
Non-goal (別 STEP): .ts 自動生成 / MCP server case handler 直接修正 (別 tab 衝突リスク) / 実 hardware 呼出。 本 script は migration candidate list を出力するのみ、 実 wrap 追加は手動 review を強制。
分類 3 軸
| 軸 | 値 | 判定 heuristic |
|---|---|---|
| hazard | blocked | power_ / firmware_ / kikusui_cr_mode / scpi_write_ / wipe_ |
| caution | benchtop_probe / d8_verdict / disk_health / environment_read / smart_ / update_ / write_ 等 | |
| safe | _verdict / read_ / query_ / get_ / list_ / inspect_ / search_ 等 (default) | |
| protocol shape | uniqueness-check | puzzle_verify (STEP 1536) |
| uniqueness-necessity | verify_mystery / mystery_reasoning (STEP 1538) | |
| single-verdict | _verdict / get_ / list_ / search_ / find_ / describe_ / explain_ | |
| unknown | heuristic 不一致 → manual review | |
| migration | already-wrapped | PILOT_TOOL_NAMES (STEP 1533、 3 tool) |
| wrappable | shape 判定成功 + pilot 外 | |
| manual-review-needed | shape = unknown |
現状 audit 結果 (2026-08-30)
- Total tools: 80 (source scan で 検出)
- Coverage: 3.8% (3 pilot / 80)
| Hazard | 数 | Shape | 数 | Migration | 数 |
|---|---|---|---|---|---|
| safe | ~78 | single-verdict | 35 | already-wrapped | 3 |
| caution | 少数 | uniqueness-check | 1 | wrappable | 33 |
| blocked | 0 | uniqueness-necessity | 0 | manual-review | 44 |
| unknown | 44 |
Manifest: data/mcp-migration/audit-2026-08-30.json (80 tool の完全 classification)
Usage
# Human report
npm run audit:mcp-migration
# → 統計 + top 20 wrappable + top 10 manual-review-needed
# JSON manifest
npx tsx scripts/audit-mcp-tool-migration.ts --json
# JSON to file
npx tsx scripts/audit-mcp-tool-migration.ts --json --out data/mcp-migration/audit-YYYY-MM-DD.json
Migration workflow (推奨)
npm run audit:mcp-migrationで最新 status 確認- Wrappable top N を選択 (例: 5-10 tool、 hazard=safe 優先)
- 各 tool を
src/mcp/wrapped-tools.tsに手動追加 (import + wrapAsMsgTool) - test/step1533-msg-tool-wrapper-test.ts に coverage 追加 (optional)
- Manual-review-needed は shape 判定 (return 実 shape を source から確認) → shape 判明後 wrappable として再分類
- Re-run audit で coverage% 上昇確認
Test — 55/55 PASS
- classifyHazard — 15 pattern (blocked / caution / safe)
- classifyShape — 11 pattern (4 shape)
- classifyMigration — pilot / wrappable / manual (3 assertion + 3 pilot)
- scanToolDeclarations — MCP server から 30+ tool parse + STEP marker + duplicate なし
- summarize — aggregate counts + coverage %
- End-to-end audit — real MCP server scan で 30+ tool + ≥3 already-wrapped
- Pilots are classified as already-wrapped in real audit
Honest scope
- Regex + heuristic の shallow scan (AST 解析なし)。 exotic な tool 宣言 pattern は miss する可能性、 その場合は 手動追加
- 44 tool が manual-review-needed = shape 判定 heuristic 不足を露呈。 追加 heuristic (return type 深掘り、 exports 追跡) は v0.2 candidate
- Coverage 3.8% (3/80) は pilot pattern 実証段階。 実 migration 進行に応じて上昇
- rei-mcp-server.ts (3000+ 行) は 不変 = wrapper と registry は既存 case handler と 共存
- Migration の実行 (追加 wrap 生成) は 別 STEP + 手動 review 前提 (安全策)