@first-ch/tools-mcp 0.50.0 → 0.51.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
@@ -93,6 +93,7 @@ This server is also registered in the [MCP Registry](https://registry.modelconte
93
93
  | `invoice_nebiki_check` | For a freelancer in Japan who is **not a registered invoice issuer** and is asked for a price cut (same logic as tools.first-ch.com/invoice-nebiki/). From three answers — the client's consumption tax `method` (`general` / `simplified` / `niwari` 20% rule / `sanwari` 30% rule / `exempt` / `unknown`), `party` (`individual` / `corporation`, required for the special rules) and `small` (is one invoice under ¥10,000 incl. tax) — returns `rows` per period from `today`: `diff` (monthly difference = amount × 10/110 × 20/30/50/70/100%, rounded down), `none` or `check`. The 20% rule gives no difference to 2026 for sole proprietors and to the tax period including Sep 30, 2026 for corporations; the 30% rule covers sole proprietors' 2027–2028 only; after that `recheck: true` (no assumption of simplified taxation). Purchases that may fall under the small-amount rule (to Sep 30, 2029) are `check`. Optional `monthly`, `cutRate` / `cutAmount` add a comparison; `message` asks only the open points (`format: "md"` for Markdown) and always carries the four assumptions; `showAmount: false` hides yen amounts. |
94
94
  | `reply_check` | Checks an AI-drafted reply against the email it answers before you send it (same logic as tools.first-ch.com/okurumae/). From `reply` it picks up **dates, weekdays, times, amounts, quantities (guests, nights, %), phone numbers, emails, URLs, names** (〇〇様, Dear Ms. …) and other numbers; those found in neither `received` nor your optional `facts` (hours, prices, dates) are `red` (`missing`), matches are `green` with the matching spots in `hits`, and leftover placeholders (`[Customer 1]`, 〇〇, XX, 【】, `{name}`) are `yellow`. A weekday that does not fit the date (e.g. Friday, November 8 in 2026) or a date that does not exist is `red` too (`weekday` / `nodate`, with the actual weekday). Dates without a year are checked in the year that falls between 60 days before and 305 days after `today`. Full-/half-width forms, commas, 18時30分 vs 18:30 and 3千円 vs 3,000円 are aligned for matching only — the text is never rewritten, and `start`/`end`/`line`/`column` point into `reply` as written. `count` covers every item; `items` stops at 500 (`truncated`). A `note` always says that 0 red does not mean the reply is correct. No auto-fix, no tone editing. Up to 20,000 characters per field | `reply`, `received?`, `facts?`, `today?` (YYYY-MM-DD), `includeGreen?` (default true), `lang?` (`ja` default / `en`) |
95
95
  | `comfy_png_leak_scan` | Checks a ComfyUI PNG you received or posted for **API key formats** (Google `AIza`, OpenAI-style `sk-`, Anthropic `sk-ant-`, Hugging Face `hf_`, Replicate `r8_`) in its embedded data (same logic as tools.first-ch.com/en/comfy-key-leak/). Chunks are read in order with CRC checks; tEXt and uncompressed iTXt are searched. `status` is `found`, `none` (not a claim that the image is safe), `unchecked` (zTXt, compressed iTXt, eXIf, caBX, unknown chunks, data after IEND, over 30 MB) or `failed` (CRC mismatch, truncated, not a PNG). Each finding gives the place — node ID, `classType` and `input` from prompt, or node ID and `widgetIndex` when only a workflow exists (`fieldUnknown`) — plus flags for duplicate JSON keys, items outside inputs and bypassed/muted nodes. Node titles are not used. **Values are never returned**: only `masked` (first 4 characters) and `length`. `notice` is a heads-up message for the key owner (no values or file name; states that validity and cause were not checked) and `revoke` lists the official pages to disable each key type. With `outPath` it writes a copy without tEXt/iTXt/zTXt after re-reading it (0 text chunks, kept chunks byte-identical); the original is never changed, caBX (C2PA) PNGs are not rewritten. It does not test keys or fetch URLs, and sends nothing itself. Prefer `path`: with `base64` the image bytes (including any raw key) go into the AI conversation and to the model provider, and the result carries an `inputNote` saying so | `path` (absolute) or `base64`, `outPath?`, `overwrite?`, `includeUrl?`, `lang?` |
96
+ | `ai_vs_search` | Compares visitors from AI with visitors from search in **your own GA4 data** (same logic as tools.first-ch.com/en/ai-vs-search/). Pass the CSV exported from Traffic acquisition (Session default channel group, no comparison or filter) as `csv` text or an absolute `path`; Japanese and English column names are read. Returns, for Google's `AI Assistant` and `Organic Search` rows and the total of all other channels, sessions, engagement rate (engaged sessions ÷ sessions), average engagement time per session (session-weighted) and key event rate (key events ÷ sessions — not GA4's Session key event rate), plus `ratios` (AI ÷ search; `null` under 30 AI sessions), `totals.basis` (`matched` with the grand total row / `read` when rows were skipped or totals differ / `noTotal`), `excluded` line numbers, `notes` (e.g. the period includes dates before 2026-05-13, when the AI Assistant channel was added) and a `summary` to paste. No outside study figures, own AI-service list or GA4 API. Local only, nothing is sent. |
96
97
 
97
98
  ### App tools (`app_*`, sent to apps.first-ch.com)
98
99
 
@@ -285,6 +286,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
285
286
  | `invoice_nebiki_check` | インボイス未登録のまま取引先から値下げを求められた個人の制作者向け(tools.first-ch.com/invoice-nebiki/ と同一ロジック)。取引先の申告方式 `method`(`general` 一般課税・`simplified` 簡易課税・`niwari` 2割特例・`sanwari` 3割特例・`exempt` 免税・`unknown`)、`party`(個人・法人。特例では必須)、`small`(1回の請求が税込1万円未満か)の3問から、`today` を含む時期以降を `diff`(差あり・月額=税込×10/110×20/30/50/70/100% の1円未満切り捨て)・`none`(差なし)・`check`(要確認)で返す。2割特例は個人2026年分・法人は2026年9月30日を含む課税期間まで、3割特例は個人の2027・2028年分だけで、期限後は `recheck: true`(簡易課税へ移ったとは仮定しない)。少額特例(2029年9月30日まで)が効きうる取引は要確認。任意の `monthly`・`cutRate`/`cutAmount` で値下げと比べ、`message` は要確認の点だけを尋ねる確認文(前提4点つき・`format: "md"` で Markdown)。`showAmount: false` で金額を出さない。 |
286
287
  | `reply_check` | 届いたメール(`received`)と任意の「自分で決めた事実」(`facts`:営業時間・料金・日程など)を、AI が書いた返信案(`reply`)と照らし合わせる(tools.first-ch.com/okurumae/ と同一ロジック)。返信案の**日付・曜日・時刻・金額・数量(〇名・〇泊・%)・電話番号・メールアドレス・URL・宛名(〇〇様・Dear Ms. …)・番号**のうち、原文のどちらにも無いものを `red`(`missing`)、あるものを `green`(一致した箇所は `hits`)、`[お客様1]`・〇〇・XX・【】・`{name}` などの消し忘れを `yellow` で返す。日付と曜日の食い違い(例: 2026年の11月8日(金))と存在しない日付も `red`(`weekday` / `nodate`・実際の曜日つき)。年の無い日付は `today` の60日前〜305日後に入る年で確かめる。全角/半角・カンマ・「18時30分」と「18:30」・「3千円」と「3,000円」は照合のときだけそろえ、本文は書き換えない(`start`/`end`/`line`/`column` は元の返信案の位置)。`count` は全件、`items` は500件まで(`truncated`)。「赤が0件でも内容の正しさは保証しない」注意(`note`)を常に付ける。自動修正・文体の添削はしない。各欄2万字まで | `reply`、`received?`、`facts?`、`today?`(YYYY-MM-DD)、`includeGreen?`(既定 true)、`lang?`(既定 `ja` / `en`) |
287
288
  | `comfy_png_leak_scan` | 受け取った・投稿した ComfyUI の PNG の埋め込みデータから **APIキーの形**(Google の `AIza`・OpenAI などの `sk-`・Anthropic の `sk-ant-`・Hugging Face の `hf_`・Replicate の `r8_`)を探す(tools.first-ch.com/comfy-key-leak/ と同一ロジック)。チャンクを順に読んで CRC を確かめ、tEXt と非圧縮の iTXt を調べる。`status` は `found`・`none`(安全という意味ではない)・`unchecked`(zTXt・圧縮 iTXt・eXIf・caBX・不明なチャンク・IEND の後ろ・30MB超)・`failed`(CRC 不一致・途中で切れた・PNG でない)。場所は prompt ならノードID・`classType`・`input`、workflow だけならノードIDと `widgetIndex`(`fieldUnknown`)で、JSON の重複キー・inputs の外の項目・迂回/無効のノードの印つき。ノードの表示名は使わない。**値は返さない**(`masked`=先頭4字と `length` だけ)。`notice` はキーの持ち主へのお知らせ文(値・ファイル名なし、有効性と原因は確認していないと書く)、`revoke` は種類ごとの公式の無効化画面。`outPath` で tEXt・iTXt・zTXt を抜いたコピーを、読み直して確かめてから書く(元は変えない・caBX 付きは書き換えない)。キーの有効性の確認・URL の取得はしない(ツール自体は何も送らない)。入力は `path` を優先する: `base64` だと画像のバイト列(生のキーを含む)が AI との会話に載りモデルの提供元へ渡るため、返り値の `inputNote` でそれを伝える | `path`(絶対パス)か `base64`、`outPath?`、`overwrite?`、`includeUrl?`、`lang?` |
289
+ | `ai_vs_search` | **自分のサイトの GA4** で、AI から来た人と検索から来た人を比べる(tools.first-ch.com/ai-vs-search/ と同一ロジック)。[トラフィック獲得](セッションのデフォルト チャネル グループ・比較とフィルタなし)から書き出した CSV を `csv`(文字列)か `path`(絶対パス)で渡す。列名は日本語・英語とも読む。Google が分類した `AI Assistant`・`Organic Search` とそれ以外の合計について、セッション・エンゲージメント率(エンゲージのあったセッション÷セッション)・セッションあたりの平均エンゲージメント時間(セッションで重み付け)・キーイベント率(キーイベント÷セッション。GA4 の「セッションのキーイベント率」とは別)を返し、`ratios`(AI ÷ 検索。AI が30セッション未満なら `null`)、`totals.basis`(総計行と一致 `matched`/除外・ずれありの `read`/総計行なし `noTotal`)、除外した行番号 `excluded`、`notes`(2026-05-13=AI Assistant チャネルの追加日より前を含む期間など)、貼り付け用の `summary` を返す。外部の調査値・独自の AI サービス一覧・GA4 API は使わない。完全ローカル処理・送信なし。 |
288
290
 
289
291
  #### apps のツール(`app_*`・apps.first-ch.com へ送信)
290
292
 
@@ -0,0 +1,365 @@
1
+ /* AIから来た人は検索より読む?(ai_vs_search)
2
+ * 集計のコアは FirstCHTools の site/ai-vs-search/lib.mjs と同一
3
+ * (2箇所ルール: site側が正本・片方を直したらもう片方も同じ内容で反映する)。
4
+ * 両ファイルの「ここからコア」〜「ここまでコア」はバイト一致する(どちらも ES module):
5
+ * diff <(sed -n '/^\/\/ ===== ここから/,/^\/\/ ===== ここまで/p' site/ai-vs-search/lib.mjs) <(sed -n '/^\/\/ ===== ここから/,/^\/\/ ===== ここまで/p' ai-vs-search.mjs)
6
+ *
7
+ * GA4「トラフィック獲得」(セッションのデフォルト チャネル グループ)の CSV を読み、Google が分類した AI Assistant と
8
+ * Organic Search、それ以外の合計を、エンゲージメント率・平均エンゲージメント時間・キーイベント率(キーイベント÷セッション)で並べる。
9
+ * 総計行は足さず突き合わせにだけ使う。外部の調査値・独自の AI サービスの一覧は使わない。完全ローカル処理・ネットワーク送信なし。 */
10
+ import { readFile, stat } from 'node:fs/promises';
11
+ import path from 'node:path';
12
+
13
+ // ===== ここからコア =====
14
+ export const AI_MIN_SESSIONS = 30; // これ未満の AI Assistant は倍率を出さない
15
+ export const AI_CHANNEL_SINCE = '2026-05-13'; // GA4 のデフォルト チャネル グループに AI Assistant が加わった日
16
+ export const MAX_CSV_CHARS = 5000000;
17
+
18
+ export class AiVsSearchError extends Error {
19
+ constructor(code, message) { super(message); this.code = code; }
20
+ }
21
+
22
+ const norm = (s) => String(s == null ? '' : s).normalize('NFKC').replace(/^/, '').replace(/[\s "]/g, '').toLowerCase();
23
+
24
+ /** CSV(RFC 4180 の引用符・"" のエスケープ・引用符の中の改行)を行に分ける。line は行の始まりの物理行(1から) */
25
+ export function parseCsv(text, delim) {
26
+ const src = String(text).replace(/^/, '');
27
+ const d = delim || sniffDelimiter(src);
28
+ const rows = [];
29
+ let cells = [], cell = '', q = false, line = 1, start = 1, i = 0, quoted = false;
30
+ const push = () => { cells.push(quoted ? cell : cell.trim()); cell = ''; quoted = false; };
31
+ const end = () => { push(); rows.push({ line: start, cells }); cells = []; };
32
+ while (i < src.length) {
33
+ const c = src[i];
34
+ if (q) {
35
+ if (c === '"') { if (src[i + 1] === '"') { cell += '"'; i += 2; continue; } q = false; i++; continue; }
36
+ if (c === '\r' || c === '\n') { line++; if (c === '\r' && src[i + 1] === '\n') i++; cell += '\n'; i++; continue; }
37
+ cell += c; i++; continue;
38
+ }
39
+ if (c === '"' && cell.trim() === '') { q = true; quoted = true; cell = ''; i++; continue; }
40
+ if (c === d) { push(); i++; continue; }
41
+ if (c === '\r' || c === '\n') { end(); if (c === '\r' && src[i + 1] === '\n') i++; i++; line++; start = line; continue; }
42
+ cell += c; i++;
43
+ }
44
+ if (cell !== '' || cells.length || quoted) end();
45
+ return rows;
46
+ }
47
+
48
+ function sniffDelimiter(src) {
49
+ const first = src.split(/\r\n|\r|\n/).find((l) => l.trim() && !l.trim().startsWith('#')) || '';
50
+ return (first.match(/\t/g) || []).length > (first.match(/,/g) || []).length ? '\t' : ',';
51
+ }
52
+
53
+ // 列名(NFKC・空白なし・小文字で比べる)。日本語と英語の GA4 の表示名と、以前の名前(コンバージョン)を受け付ける
54
+ function colKind(name) {
55
+ const n = norm(name);
56
+ if (!n) return null;
57
+ if (/チャネルグループ|channelgroup/.test(n)) return /最初のユーザー|firstuser/.test(n) ? 'userChannel' : 'channel';
58
+ if (n === 'セッション' || n === 'セッション数' || n === 'sessions') return 'sessions';
59
+ if (n === 'エンゲージのあったセッション数' || n === 'エンゲージのあったセッション' || n === 'engagedsessions') return 'engaged';
60
+ if (n === 'セッションあたりの平均エンゲージメント時間' || n === 'averageengagementtimepersession') return 'avgTime';
61
+ if (/^(キーイベント|keyevents|コンバージョン|conversions)/.test(n) && !/率|あたり|rate|per/.test(n)) return 'keyEvents';
62
+ return null;
63
+ }
64
+
65
+ /** 数("1,234"・"12.5")。空・記号だけ・負の数は NaN */
66
+ export function parseCount(s) {
67
+ const t = String(s == null ? '' : s).normalize('NFKC').replace(/[\s,]/g, '');
68
+ if (!/^\d+(\.\d+)?$/.test(t)) return NaN;
69
+ return Number(t);
70
+ }
71
+
72
+ /** 平均エンゲージメント時間を秒で。"45.2"(秒)・"1m 05s"・"1分05秒"・"0:01:05"・"01:05" */
73
+ export function parseSeconds(s) {
74
+ const t = String(s == null ? '' : s).normalize('NFKC').trim().toLowerCase().replace(/,/g, '');
75
+ if (!t) return NaN;
76
+ if (/^\d+(\.\d+)?$/.test(t)) return Number(t);
77
+ let m = t.match(/^(\d+):(\d{1,2})(?::(\d{1,2}(?:\.\d+)?))?$/);
78
+ if (m) return m[3] != null ? Number(m[1]) * 3600 + Number(m[2]) * 60 + Number(m[3]) : Number(m[1]) * 60 + Number(m[2]);
79
+ m = t.replace(/\s+/g, '').match(/^(?:(\d+)(?:h|時間))?(?:(\d+)(?:m|min|分))?(?:(\d+(?:\.\d+)?)(?:s|sec|秒))?$/);
80
+ if (m && (m[1] || m[2] || m[3])) return Number(m[1] || 0) * 3600 + Number(m[2] || 0) * 60 + Number(m[3] || 0);
81
+ return NaN;
82
+ }
83
+
84
+ const TOTAL_NAMES = new Set(['', 'grandtotal', 'total', 'totals', '総計', '合計', '全体']);
85
+ /** チャネル名を ai / search / other に。Google が付けた名前(AI Assistant・Organic Search)だけで分ける */
86
+ export function channelGroup(name) {
87
+ const n = norm(name);
88
+ if (n === 'aiassistant' || n === 'aiアシスタント') return 'ai';
89
+ if (n === 'organicsearch' || n === 'オーガニック検索') return 'search';
90
+ return 'other';
91
+ }
92
+
93
+ // 先頭のコメント行(# 開始日: 20261001 / # Start date: 20261001)から期間を読む
94
+ function readPeriod(rows) {
95
+ let start = null, end = null;
96
+ for (const r of rows) {
97
+ const s = r.cells.join(',').normalize('NFKC');
98
+ if (!s.trim().startsWith('#')) continue;
99
+ const m = s.match(/(開始日|startdate|終了日|enddate)\s*[::]\s*(\d{4})[-/]?(\d{2})[-/]?(\d{2})/i) || s.replace(/\s+/g, '').match(/(開始日|startdate|終了日|enddate)[::](\d{4})[-/]?(\d{2})[-/]?(\d{2})/i);
100
+ if (!m) continue;
101
+ const d = m[2] + '-' + m[3] + '-' + m[4];
102
+ if (/開始|start/i.test(m[1])) start = start || d; else end = end || d;
103
+ }
104
+ return { start, end };
105
+ }
106
+
107
+ const emptyGroup = () => ({ sessions: 0, engaged: 0, timeSum: 0, keyEvents: 0, rows: 0, channels: [] });
108
+
109
+ /**
110
+ * GA4 のトラフィック獲得の CSV を集計する(ai_vs_search)。
111
+ * 返り値の数は CSV の中の数だけから作り、外部の調査値は使わない。総計行は足さず、明細の合計との突き合わせにだけ使う。
112
+ */
113
+ export function aiVsSearch(text) {
114
+ if (typeof text !== 'string' || !text.trim()) throw new AiVsSearchError('EMPTY', 'CSV is empty');
115
+ if (text.length > MAX_CSV_CHARS) throw new AiVsSearchError('TOO_LARGE', 'CSV is larger than ' + MAX_CSV_CHARS + ' characters');
116
+ const rows = parseCsv(text);
117
+ const period = readPeriod(rows);
118
+ // 見出し行: チャネル グループの列とセッションの列がある最初の行
119
+ let hi = -1, cols = null, userChannel = false;
120
+ for (let i = 0; i < rows.length; i++) {
121
+ const kinds = rows[i].cells.map(colKind);
122
+ if (kinds.includes('userChannel') && kinds.includes('sessions')) userChannel = true;
123
+ if (kinds.includes('channel') && kinds.includes('sessions')) {
124
+ cols = {};
125
+ kinds.forEach((k, j) => { if (k && cols[k] == null) cols[k] = j; });
126
+ hi = i; break;
127
+ }
128
+ }
129
+ if (hi < 0) throw new AiVsSearchError(userChannel ? 'USER_ACQUISITION' : 'NO_HEADER', userChannel
130
+ ? 'this looks like the User acquisition report; export Traffic acquisition (Session default channel group) instead'
131
+ : 'no header row with a channel group column and a Sessions column');
132
+ const width = rows[hi].cells.length;
133
+ const groups = { ai: emptyGroup(), search: emptyGroup(), other: emptyGroup() };
134
+ const excluded = [], seen = new Map(), totals = [];
135
+ const read = { sessions: 0, engaged: 0, keyEvents: 0, rows: 0 };
136
+ for (let i = hi + 1; i < rows.length; i++) {
137
+ const r = rows[i];
138
+ const first = (r.cells[0] || '').trim();
139
+ if (r.cells.every((c) => !String(c).trim())) break; // 空行で表が終わる
140
+ if (first.startsWith('#')) break; // 次のコメント(別の表)
141
+ if (r.cells.length !== width) { excluded.push({ line: r.line, reason: 'columns', name: (r.cells[cols.channel] || '').slice(0, 60) }); continue; }
142
+ const name = String(r.cells[cols.channel]).trim();
143
+ const sessions = parseCount(r.cells[cols.sessions]);
144
+ const engaged = cols.engaged == null ? NaN : parseCount(r.cells[cols.engaged]);
145
+ const avg = cols.avgTime == null ? NaN : parseSeconds(r.cells[cols.avgTime]);
146
+ const key = cols.keyEvents == null ? NaN : parseCount(r.cells[cols.keyEvents]);
147
+ const bad = !Number.isFinite(sessions) || (cols.engaged != null && !Number.isFinite(engaged))
148
+ || (cols.avgTime != null && !Number.isFinite(avg)) || (cols.keyEvents != null && !Number.isFinite(key));
149
+ if (TOTAL_NAMES.has(norm(name))) {
150
+ if (!bad) totals.push({ line: r.line, sessions, engaged, keyEvents: key });
151
+ else excluded.push({ line: r.line, reason: 'number', name: name.slice(0, 60) });
152
+ continue;
153
+ }
154
+ if (bad) { excluded.push({ line: r.line, reason: 'number', name: name.slice(0, 60) }); continue; }
155
+ if (Number.isFinite(engaged) && engaged > sessions) { excluded.push({ line: r.line, reason: 'engagedOverSessions', name: name.slice(0, 60) }); continue; }
156
+ const g = groups[channelGroup(name)];
157
+ g.sessions += sessions; g.rows++;
158
+ if (Number.isFinite(engaged)) g.engaged += engaged;
159
+ if (Number.isFinite(avg)) g.timeSum += avg * sessions;
160
+ if (Number.isFinite(key)) g.keyEvents += key;
161
+ if (!g.channels.includes(name)) g.channels.push(name);
162
+ seen.set(norm(name), (seen.get(norm(name)) || 0) + 1);
163
+ read.sessions += sessions; read.rows++;
164
+ if (Number.isFinite(engaged)) read.engaged += engaged;
165
+ if (Number.isFinite(key)) read.keyEvents += key;
166
+ }
167
+ if (!read.rows) throw new AiVsSearchError('NO_ROWS', 'no readable channel rows under the header');
168
+ const has = { engaged: cols.engaged != null, avgTime: cols.avgTime != null, keyEvents: cols.keyEvents != null };
169
+ const metric = (g) => ({
170
+ sessions: g.sessions,
171
+ engagedSessions: has.engaged ? g.engaged : null,
172
+ engagementRate: has.engaged && g.sessions ? g.engaged / g.sessions : null,
173
+ avgEngagementTime: has.avgTime && g.sessions ? g.timeSum / g.sessions : null,
174
+ keyEvents: has.keyEvents ? g.keyEvents : null,
175
+ keyEventRate: has.keyEvents && g.sessions ? g.keyEvents / g.sessions : null,
176
+ rows: g.rows,
177
+ channels: g.channels,
178
+ });
179
+ const out = { ai: metric(groups.ai), search: metric(groups.search), other: metric(groups.other) };
180
+ // 総計との突き合わせ(1未満の差は丸めとみなす)
181
+ const total = totals[0] || null;
182
+ const near = (a, b) => !Number.isFinite(a) || !Number.isFinite(b) || Math.abs(a - b) < 1;
183
+ const totalMatches = total ? near(total.sessions, read.sessions) && (!has.engaged || near(total.engaged, read.engaged)) && (!has.keyEvents || near(total.keyEvents, read.keyEvents)) : null;
184
+ const basis = excluded.length || totalMatches === false ? 'read' : total ? 'matched' : 'noTotal';
185
+ // 倍率(AI ÷ 検索)。AI が30セッション未満・検索の値が0のときは出さない
186
+ const enough = out.ai.sessions >= AI_MIN_SESSIONS;
187
+ const ratio = (k) => enough && out.search.sessions > 0 && out.ai[k] != null && out.search[k] ? out.ai[k] / out.search[k] : null;
188
+ const ratios = { engagementRate: ratio('engagementRate'), avgEngagementTime: ratio('avgEngagementTime'), keyEventRate: ratio('keyEventRate') };
189
+ const notes = [];
190
+ if (!period.start || !period.end) notes.push('periodUnknown');
191
+ else if (period.end < AI_CHANNEL_SINCE) notes.push('allBeforeAiChannel');
192
+ else if (period.start < AI_CHANNEL_SINCE) notes.push('beforeAiChannel');
193
+ if (out.ai.sessions === 0) notes.push('aiZero');
194
+ else if (!enough) notes.push('lowSample');
195
+ if (out.search.sessions === 0) notes.push('searchZero');
196
+ if ([...seen.values()].some((n) => n > 1) || totals.length > 1) notes.push('duplicate');
197
+ if (!has.engaged) notes.push('noEngaged');
198
+ if (!has.avgTime) notes.push('noAvgTime');
199
+ if (!has.keyEvents) notes.push('noKeyEvents');
200
+ return {
201
+ ok: true,
202
+ period,
203
+ groups: out,
204
+ ratios,
205
+ lowSample: out.ai.sessions > 0 && !enough,
206
+ aiZero: out.ai.sessions === 0,
207
+ minSessions: AI_MIN_SESSIONS,
208
+ totals: { basis, read, total: total ? { line: total.line, sessions: total.sessions, engagedSessions: has.engaged ? total.engaged : null, keyEvents: has.keyEvents ? total.keyEvents : null } : null, matches: totalMatches },
209
+ excluded,
210
+ notes,
211
+ columns: { header: rows[hi].line, found: Object.keys(cols) },
212
+ };
213
+ }
214
+
215
+ // ---- 文言(画面・共有画像・要約・MCP で共通) ----
216
+ export const T = {
217
+ ja: {
218
+ groups: { ai: 'AI Assistant', search: 'Organic Search', other: 'その他の合計' },
219
+ groupSub: { ai: 'AIから', search: '検索から', other: 'Direct・Referral など' },
220
+ metrics: { engagementRate: 'エンゲージメント率', avgEngagementTime: '平均エンゲージメント時間', keyEventRate: 'キーイベント率' },
221
+ metricSub: { engagementRate: 'エンゲージのあったセッション÷セッション', avgEngagementTime: 'セッションあたり', keyEventRate: 'キーイベント÷セッション' },
222
+ sessions: (n) => fmtInt(n, 'ja') + ' セッション',
223
+ low: '件数が少なく参考値',
224
+ basis: { matched: '合計(総計行と一致)', read: '読み取れた行の合計', noTotal: '明細の合計(CSVに総計行なし)' },
225
+ reason: { columns: '列の数が見出しと違う', number: '数として読めない値がある', engagedOverSessions: 'エンゲージのあったセッションがセッションより多い' },
226
+ excluded: (lines) => '除外した行: ' + lines.join('・') + ' 行目',
227
+ ratio: (x) => '×' + fmtRatio(x),
228
+ ratioLine: (m, x) => m + 'は検索の ' + fmtRatio(x) + ' 倍',
229
+ noRatio: '倍率は出していません',
230
+ period: (p) => p.start && p.end ? fmtDate(p.start, 'ja') + '〜' + fmtDate(p.end, 'ja') : '期間不明',
231
+ notes: {
232
+ periodUnknown: 'CSV の先頭に期間(開始日・終了日)が見つかりませんでした。2026年5月13日より前を含む場合、その日より前の AI からの訪問は AI Assistant に入っていない可能性があります。',
233
+ allBeforeAiChannel: 'この期間はすべて2026年5月13日より前です。AI Assistant チャネルはこの日に GA4 に加わったため、AI からの訪問は Referral などに入っています。',
234
+ beforeAiChannel: '期間に2026年5月13日より前が含まれます。AI Assistant チャネルはこの日に GA4 に加わったため、それより前の AI からの訪問は Referral などに入っている可能性があります。',
235
+ aiZero: 'AI Assistant の行がありません(この期間の AI からの訪問が0か、表の行数を減らして書き出したかもしれません)。',
236
+ lowSample: 'AI Assistant が30セッション未満のため、倍率は出さず、数は参考値です。',
237
+ searchZero: 'Organic Search の行がないため、倍率は出していません。',
238
+ duplicate: '同じチャネルが2行以上あります。比較やセカンダリ ディメンションを付けたまま書き出していないか確かめてください(各行はそのまま足しています)。',
239
+ noEngaged: '「エンゲージのあったセッション数」の列がないため、エンゲージメント率は出していません。',
240
+ noAvgTime: '「セッションあたりの平均エンゲージメント時間」の列がないため、平均エンゲージメント時間は出していません。',
241
+ noKeyEvents: '「キーイベント」の列がないため、キーイベント率は出していません。',
242
+ },
243
+ fine: ['このCSV内の数値', '参照元が渡らないAI訪問とAI Overviewsは区別できない'],
244
+ cardNote: { allBeforeAiChannel: 'AI Assistant は2026年5月13日から分類。この期間の AI からの訪問は Referral などに入っています', beforeAiChannel: 'AI Assistant は2026年5月13日から分類。それより前の AI からの訪問は Referral などに入っている可能性があります', periodUnknown: '期間不明。AI Assistant は2026年5月13日から分類されています' },
245
+ fineLong: 'このCSV内の数値です。参照元が渡らない AI からの訪問(Direct などに入る)と、Google 検索の AI による概要(AI Overviews)・AI モードからの訪問(Organic Search に入る)は区別できません。',
246
+ head: 'GA4 トラフィック獲得',
247
+ },
248
+ en: {
249
+ groups: { ai: 'AI Assistant', search: 'Organic Search', other: 'All other channels' },
250
+ groupSub: { ai: 'from AI', search: 'from search', other: 'Direct, Referral, etc.' },
251
+ metrics: { engagementRate: 'Engagement rate', avgEngagementTime: 'Avg engagement time', keyEventRate: 'Key event rate' },
252
+ metricSub: { engagementRate: 'engaged sessions ÷ sessions', avgEngagementTime: 'per session', keyEventRate: 'key events ÷ sessions' },
253
+ sessions: (n) => fmtInt(n, 'en') + (n === 1 ? ' session' : ' sessions'),
254
+ low: 'small sample, for reference only',
255
+ basis: { matched: 'Total (matches the grand total row)', read: 'Total of the rows that could be read', noTotal: 'Total of the rows (no grand total row in the CSV)' },
256
+ reason: { columns: 'column count differs from the header', number: 'a value is not a number', engagedOverSessions: 'more engaged sessions than sessions' },
257
+ excluded: (lines) => 'Rows left out: line ' + lines.join(', '),
258
+ ratio: (x) => '×' + fmtRatio(x),
259
+ ratioLine: (m, x) => m + ' is ' + fmtRatio(x) + '× search',
260
+ noRatio: 'No ratios shown',
261
+ period: (p) => p.start && p.end ? fmtDate(p.start, 'en') + ' – ' + fmtDate(p.end, 'en') : 'Period unknown',
262
+ notes: {
263
+ periodUnknown: 'No period (start and end date) was found at the top of the CSV. If it covers dates before May 13, 2026, AI visits before that day may not be in AI Assistant.',
264
+ allBeforeAiChannel: 'The whole period is before May 13, 2026. The AI Assistant channel was added to GA4 on that day, so AI visits here are in Referral and other channels.',
265
+ beforeAiChannel: 'The period includes dates before May 13, 2026. The AI Assistant channel was added to GA4 on that day, so earlier AI visits may be in Referral and other channels.',
266
+ aiZero: 'There is no AI Assistant row (no AI visits in this period, or the table was exported with fewer rows).',
267
+ lowSample: 'AI Assistant has fewer than 30 sessions, so no ratios are shown and the numbers are for reference only.',
268
+ searchZero: 'There is no Organic Search row, so no ratios are shown.',
269
+ duplicate: 'The same channel appears on more than one row. Check that no comparison or secondary dimension was on when you exported (each row was added as is).',
270
+ noEngaged: 'There is no Engaged sessions column, so engagement rate is not shown.',
271
+ noAvgTime: 'There is no Average engagement time per session column, so engagement time is not shown.',
272
+ noKeyEvents: 'There is no Key events column, so key event rate is not shown.',
273
+ },
274
+ fine: ['Numbers from this CSV only', 'AI visits without a referrer and AI Overviews cannot be told apart'],
275
+ cardNote: { allBeforeAiChannel: 'AI Assistant is classified from May 13, 2026. AI visits in this period are in Referral and other channels', beforeAiChannel: 'AI Assistant is classified from May 13, 2026. Earlier AI visits may be in Referral and other channels', periodUnknown: 'Period unknown. AI Assistant is classified from May 13, 2026' },
276
+ fineLong: 'Numbers from this CSV only. AI visits that pass no referrer (they land in Direct and others) and visits from Google’s AI Overviews and AI Mode (they land in Organic Search) cannot be told apart.',
277
+ head: 'GA4 Traffic acquisition',
278
+ },
279
+ };
280
+
281
+ export function fmtInt(n, lang) { return Number(n).toLocaleString(lang === 'en' ? 'en-US' : 'ja-JP', { maximumFractionDigits: 0 }); }
282
+ export function fmtRatio(x) { return x >= 9.95 ? x.toFixed(0) : x.toFixed(1); }
283
+ export function fmtPct(x) { return x == null ? '—' : (x * 100).toFixed(1) + '%'; }
284
+ export function fmtTime(sec, lang) {
285
+ if (sec == null) return '—';
286
+ const s = Math.round(sec), m = Math.floor(s / 60), r = s % 60;
287
+ if (lang === 'en') return m ? m + 'm ' + String(r).padStart(2, '0') + 's' : r + 's';
288
+ return m ? m + '分' + String(r).padStart(2, '0') + '秒' : r + '秒';
289
+ }
290
+ export function fmtDate(d, lang) {
291
+ const [y, m, dd] = d.split('-').map(Number);
292
+ if (lang === 'en') return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][m - 1] + ' ' + dd + ', ' + y;
293
+ return y + '/' + String(m).padStart(2, '0') + '/' + String(dd).padStart(2, '0');
294
+ }
295
+ export function fmtMetric(k, v, lang) { return k === 'avgEngagementTime' ? fmtTime(v, lang) : fmtPct(v); }
296
+
297
+ export const METRIC_KEYS = ['engagementRate', 'avgEngagementTime', 'keyEventRate'];
298
+
299
+ /** 上司や制作会社へ貼る要約(プレーンテキスト) */
300
+ export function summaryText(r, lang = 'ja', url = 'https://tools.first-ch.com/ai-vs-search/') {
301
+ const L = T[lang === 'en' ? 'en' : 'ja'];
302
+ const lines = [L.head + ' ' + L.period(r.period)];
303
+ for (const g of ['ai', 'search', 'other']) {
304
+ const m = r.groups[g];
305
+ const head = L.groups[g] + ': ' + L.sessions(m.sessions) + (g === 'ai' && r.lowSample ? '(' + L.low + ')' : '');
306
+ lines.push(head + ' / ' + METRIC_KEYS.map((k) => L.metrics[k] + ' ' + fmtMetric(k, m[k], lang)).join(' / '));
307
+ }
308
+ const rs = METRIC_KEYS.filter((k) => r.ratios[k] != null).map((k) => L.ratioLine(L.metrics[k], r.ratios[k]));
309
+ lines.push(rs.length ? (lang === 'en' ? 'AI vs search: ' : 'AI と検索の比: ') + rs.join(lang === 'en' ? ', ' : '・') : L.noRatio + '(' + (r.aiZero ? L.notes.aiZero : r.lowSample ? L.notes.lowSample : L.notes.searchZero) + ')');
310
+ if (r.totals.basis !== 'matched') lines.push(L.basis[r.totals.basis] + ': ' + L.sessions(r.totals.read.sessions));
311
+ if (r.excluded.length) lines.push(L.excluded(r.excluded.map((e) => e.line)));
312
+ for (const n of r.notes) if (['periodUnknown', 'allBeforeAiChannel', 'beforeAiChannel', 'duplicate'].includes(n)) lines.push('※' + L.notes[n]);
313
+ lines.push('※' + L.fineLong);
314
+ if (url) lines.push(url);
315
+ return lines.join('\n');
316
+ }
317
+
318
+ /** 見本の CSV(架空の数値・GA4 の書き出しと同じ並び)。lang で日本語版・英語版の見出しにする */
319
+ export function makeSampleCsv(lang = 'ja') {
320
+ const ja = lang !== 'en';
321
+ const head = ja
322
+ ? ['# ----------------------------------------', '# トラフィック獲得: セッションのデフォルト チャネル グループ', '# アカウント: 見本', '# プロパティ: 見本の店(架空)', '# ----------------------------------------', '#', '# 開始日: 20261001', '# 終了日: 20261031',
323
+ 'セッションのデフォルト チャネル グループ,ユーザー,セッション,エンゲージのあったセッション数,セッションあたりの平均エンゲージメント時間,イベント数,キーイベント,合計収益']
324
+ : ['# ----------------------------------------', '# Traffic acquisition: Session default channel group', '# Account: Sample', '# Property: Sample shop (fictional)', '# ----------------------------------------', '#', '# Start date: 20261001', '# End date: 20261031',
325
+ 'Session default channel group,Users,Sessions,Engaged sessions,Average engagement time per session,Event count,Key events,Total revenue'];
326
+ const data = [
327
+ [ja ? '総計' : 'Grand total', 4310, 6127, 3528, 58.4, 41262, 198, 0],
328
+ ['Organic Search', 2105, 2948, 1797, 58.6, 20137, 91, 0],
329
+ ['Direct', 1240, 1702, 811, 47.9, 9604, 52, 0],
330
+ ['Referral', 402, 563, 343, 70.2, 4117, 20, 0],
331
+ ['Organic Social', 337, 437, 189, 33.5, 2210, 6, 0],
332
+ ['AI Assistant', 151, 214, 163, 112.8, 2385, 18, 0],
333
+ ['Email', 61, 205, 178, 104.3, 2392, 10, 0],
334
+ ['Unassigned', 14, 58, 47, 62.7, 417, 1, 0],
335
+ ];
336
+ return head.concat(data.map((r) => r.map((c, i) => i === 0 ? c : i === 1 || i === 2 || i === 5 ? '"' + Number(c).toLocaleString('en-US') + '"' : c).join(','))).join('\n') + '\n';
337
+ }
338
+ // ===== ここまでコア =====
339
+
340
+ // ---- MCP の入口 ----
341
+ export async function aiVsSearchTool(opts = {}) {
342
+ const lang = opts.lang === 'en' ? 'en' : 'ja';
343
+ let text;
344
+ if (typeof opts.csv === 'string' && opts.csv.trim()) text = opts.csv;
345
+ else if (opts.path) {
346
+ if (!path.isAbsolute(opts.path)) throw new AiVsSearchError('PATH_NOT_ABSOLUTE', 'path must be an absolute path');
347
+ const st = await stat(opts.path).catch(() => null);
348
+ if (!st || !st.isFile()) throw new AiVsSearchError('NOT_FOUND', 'file not found: ' + opts.path);
349
+ if (st.size > MAX_CSV_CHARS * 4) throw new AiVsSearchError('TOO_LARGE', 'CSV file is too large');
350
+ const buf = await readFile(opts.path);
351
+ // GA4 の CSV は UTF-8。Excel で保存し直したものは UTF-16・Shift_JIS のことがあるので読み替える(サイト側の app.js と同じ順)
352
+ if (buf[0] === 0xff && buf[1] === 0xfe) text = new TextDecoder('utf-16le').decode(buf);
353
+ else { try { text = new TextDecoder('utf-8', { fatal: true }).decode(buf); } catch { text = new TextDecoder('shift_jis').decode(buf); } }
354
+ } else throw new AiVsSearchError('NO_INPUT', 'pass csv (text) or path (absolute)');
355
+ const r = aiVsSearch(text);
356
+ const L = T[lang];
357
+ return {
358
+ ...r,
359
+ labels: { groups: L.groups, metrics: L.metrics, basis: L.basis[r.totals.basis] },
360
+ noteTexts: r.notes.map((n) => L.notes[n]),
361
+ excludedTexts: r.excluded.map((e) => ({ line: e.line, reason: L.reason[e.reason] })),
362
+ caveat: L.fineLong,
363
+ summary: summaryText(r, lang, lang === 'en' ? 'https://tools.first-ch.com/en/ai-vs-search/' : 'https://tools.first-ch.com/ai-vs-search/'),
364
+ };
365
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@first-ch/tools-mcp",
3
- "version": "0.50.0",
3
+ "version": "0.51.0",
4
4
  "description": "First CH Tools の計算ロジック(WCAGコントラスト比・文字数/Xウェイト・WebP変換・JSON-LD生成・llms.txt生成・文字コード/改行コード変換・Marp Markdown→スライド レンダリング・テストデータ生成・テキスト/コード差分・Cron式の解説・Base64/Data URI変換・URLパラメータの分解/再構築・HTML特殊文字のエスケープ/エンティティのデコード・JSON⇄YAMLの相互変換・px⇄rem/emの単位換算とCSSの一括変換・カラーコードの相互変換とアルファ透過の合成・MD5/SHA-1/SHA-256/SHA-384/SHA-512のハッシュ生成と照合・JWTのデコードと有効期限/署名の検証・User-Agent文字列の解析とデバイス判定・UUID v4/ULIDの一括生成・アスペクト比の計算とレスポンシブサイズの算出・TSV/CSVからMarkdownテーブルへの整形と相互変換・SQLクエリの整形と予約語の大文字化・URL/テキストからのQRコード生成・UNIXタイムスタンプと日時表記の相互変換・robots.txtの生成(AIクローラーの許可プリセット付き)・文字列のケース変換(camelCase/snake_case/kebab-case など11形式)・CSV/TSVとJSON配列の相互変換(区切りの自動判定・a.b 列と入れ子の相互展開)・全角⇄半角の変換とテキストの掃除(文字種ごとの向き指定・半角カナの合成/分解・空白と空行の整理)・IPアドレス/CIDRの計算(ネットワーク・ブロードキャスト・ホスト範囲とホスト数・IPv4/IPv6・サブネット分割・包含判定・IP範囲→最小CIDR集合の逆算)・日数/営業日の計算(2日付間の日数と営業日数・起点日+N日/N営業日の期日・締め日と支払サイトからの支払日・土日と日本の祝日を内蔵)・HTML→Markdownの変換(見出し/リスト/表/リンク/画像/コード・script/styleや装飾タグの除去・本文だけの抽出・相対URLの絶対化)・和暦⇄西暦の変換(令和〜明治・自動判定・曜日と干支・存在しない和暦の指摘・満年齢と入学/卒業の年・元号一覧と早見表)・日本語タイトルからのURLスラッグ生成(かな→ヘボン式ローマ字・記号除去・ハイフン/アンダースコア連結・小文字化・長音の省略/表記)・Basic認証用 htpasswd の生成と照合(bcrypt / apr1-md5・パスワードの自動生成・Apache / nginx の設定スニペット)・OpenAPI/Swagger仕様書から日本語のMarkdownドキュメントとTypeScript型定義の生成(OpenAPI 3.x / Swagger 2.0・YAML/JSON・$ref/allOf/oneOf 対応・エンドポイントごとの引数/レスポンス型・外部 $ref は読みに行かない)・FAQ構造化データ(FAQPage の JSON-LD・Markdown・details/summary の HTML を同時生成・回答のリンク/箇条書きを HTML 化・「Q: / A:」形式の一括貼り付けの解析)・テキストの行操作(重複行の削除・数値を認識する並べ替え・シード付きシャッフル・行番号・空行除去・前後トリム・接頭辞/接尾辞)・印刷サイズとDPIの計算(用紙×解像度×塗り足しから必要なピクセル数・手持ちの画像の実効dpiと判定・早見表・mm/inch/px/pt/級の換算)・SERPのメタタグ文字数チェック(title / description が検索結果に収まるかをピクセル幅で判定・切り詰め位置と表示行・パンくず表示・https や階層の指摘)・Flexbox / CSS GridのCSS生成(既定値を省いた宣言・repeat()への畳み込み・grid-template-areasの検証・効かない組み合わせの指摘・定番プリセット)・社内文書の点検(Notion・Confluence などから書き出した Markdown/HTML の重複ページ・孤立ページ・表記ゆれや旧称・リンク切れの検出と修正案)・記入欄に収める字の大きさと改行位置(中袋〔ご祝儀袋・香典袋〕の住所欄などの幅・高さmmから1字の大きさ・行数・改行位置・縦書きの漢数字・金額の大字)・AIが書いた返信案と届いたメールの照合(原文に無い日付・曜日・時刻・金額・数量・電話・宛名を赤、消し忘れの仮の文字を黄)・ComfyUI画像(PNG)の埋め込みデータに残ったAPIキーの形の点検(ノードIDと入力欄で場所を示し値は伏せる・持ち主へのお知らせ文・文字のチャンクを抜いたコピー))をMCPツールとして提供するサーバー。あわせて apps.first-ch.com のWebアプリ39本(GEO・メタタグ・セキュリティヘッダー・SSL・DNS・リダイレクト・リンク切れ・構造化データ・AIクローラー許可・和文可読性・ビジネス文面チェック等)の JSON API を呼ぶ app_* ツールも提供する(こちらは入力を apps.first-ch.com へ送るため既定では無効・FIRSTCH_ENABLE_APPS=1 で有効)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -282,6 +282,7 @@
282
282
  "fit-to-box.mjs",
283
283
  "invoice-nebiki.mjs",
284
284
  "comfy-png-leak.mjs",
285
+ "ai-vs-search.mjs",
285
286
  "reply-check.mjs",
286
287
  "webp.mjs",
287
288
  "marp.mjs",
package/server.mjs CHANGED
@@ -49,6 +49,7 @@ import { wikiDocLintTool } from './wiki-doc-lint.mjs';
49
49
  import { fitToBoxTool } from './fit-to-box.mjs';
50
50
  import { invoiceNebikiTool } from './invoice-nebiki.mjs';
51
51
  import { comfyPngLeakTool } from './comfy-png-leak.mjs';
52
+ import { aiVsSearchTool } from './ai-vs-search.mjs';
52
53
  import { replyCheckTool } from './reply-check.mjs';
53
54
 
54
55
  const { version } = createRequire(import.meta.url)('./package.json');
@@ -2092,4 +2093,26 @@ registerTool(
2092
2093
  },
2093
2094
  );
2094
2095
 
2096
+ registerTool(
2097
+ 'ai_vs_search',
2098
+ {
2099
+ title: 'AIから来た人と検索から来た人の比較(GA4)',
2100
+ description:
2101
+ 'GA4「トラフィック獲得」(セッションのデフォルト チャネル グループ・比較とフィルタなし)の CSV から、Google が分類した AI Assistant と Organic Search、それ以外の合計を比べる(tools.first-ch.com/ai-vs-search/ と同一ロジック)。' +
2102
+ '指標はエンゲージメント率(エンゲージのあったセッション÷セッション)・セッションあたりの平均エンゲージメント時間(合わせるときはセッションで重み付け)・キーイベント率(キーイベント÷セッション。GA4 の「セッションのキーイベント率」とは別)。列名は日本語・英語(旧名・コンバージョンも)を読む。' +
2103
+ 'ratios は AI ÷ 検索で、AI Assistant が30セッション未満なら null(lowSample)。総計行は足さず、明細の合計との突き合わせ(totals.basis: matched / read / noTotal)にだけ使い、除外した行は excluded に行番号で返す。' +
2104
+ '期間(CSV 先頭の開始日・終了日)が2026-05-13(AI Assistant チャネルの追加日)より前を含めば notes に beforeAiChannel / allBeforeAiChannel。summary は上司や制作会社へ貼る要約。' +
2105
+ '外部の調査値・独自の AI サービスの一覧・GA4 API は使わない。参照元を渡さない AI 訪問(Direct 等)と AI Overviews・AI モード(Organic Search に入る)は区別できない。完全ローカル処理・ネットワーク送信なし。',
2106
+ inputSchema: {
2107
+ csv: z.string().optional().describe('CSV の中身(csv か path のどちらか)'),
2108
+ path: z.string().optional().describe('CSV ファイルの絶対パス'),
2109
+ lang: z.enum(['ja', 'en']).optional().describe("文言の言語(既定 'ja')"),
2110
+ },
2111
+ },
2112
+ async (opts) => {
2113
+ await logUsage('ai_vs_search');
2114
+ return asText(await aiVsSearchTool(opts));
2115
+ },
2116
+ );
2117
+
2095
2118
  serveStdio(buildServer);