@first-ch/tools-mcp 0.48.0 → 0.50.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  MCP server exposing [First CH Tools](https://tools.first-ch.com)' free web-tool logic — WCAG contrast, JP character/X-weight counting, WebP conversion, JSON-LD generation, llms.txt generation, encoding/line-ending conversion, Marp Markdown→slide rendering, Japanese/English test-data generation, text/code diffing, cron-expression explanation, Base64/data-URI encoding, URL query-parameter editing, HTML entity escaping/unescaping, JSON⇄YAML conversion, px ⇄ rem/em unit conversion, colour-code conversion with alpha compositing, MD5/SHA-1/SHA-256/SHA-384/SHA-512 hashing, JWT decoding with expiry and signature checks, User-Agent parsing with device/bot detection, bulk UUID v4 / ULID generation, aspect-ratio calculation with responsive sizing, case conversion between camelCase, snake_case and kebab-case, CSV/TSV ⇄ JSON conversion, IP/CIDR calculation with subnet splitting and IP-range reduction, business-day date calculation with Japanese public holidays, HTML-to-Markdown conversion, Japanese era ⇄ Western date conversion with age calculation, and URL-slug generation from Japanese titles — to AI agents such as Claude Code. All of those run on your machine.
4
4
 
5
- It also ships **`app_*` tools** for the 38 web apps at [apps.first-ch.com](https://apps.first-ch.com) (site checks such as GEO/AI-search readiness, meta tags, security headers, SSL certificates, DNS and email DNS, redirects, broken links, structured data, AI-crawler access, Japanese readability, and AI-assisted business-tone and LP-copy checks). Unlike the local tools, **an `app_*` tool sends its input (a URL, domain name or text) to apps.first-ch.com** and returns the JSON the app's API responds with — see [Network access, files and privacy](#network-access-files-and-privacy).
5
+ It also ships **`app_*` tools** for the 39 web apps at [apps.first-ch.com](https://apps.first-ch.com) (site checks such as GEO/AI-search readiness, meta tags, security headers, SSL certificates, DNS and email DNS, redirects, broken links, structured data, AI-crawler access, Japanese readability, and AI-assisted business-tone and LP-copy checks). Unlike the local tools, **an `app_*` tool sends its input (a URL, domain name or text) to apps.first-ch.com** and returns the JSON the app's API responds with — see [Network access, files and privacy](#network-access-files-and-privacy).
6
6
 
7
7
  日本語版は [後半セクション](#日本語) を参照してください。
8
8
 
@@ -92,6 +92,7 @@ This server is also registered in the [MCP Registry](https://registry.modelconte
92
92
  | `fit_to_box` | Character size and line breaks for writing a string by hand into a printed box — e.g. the address, amount and name boxes on the inner envelope (nakabukuro) of a Japanese wedding or condolence money envelope (same logic as tools.first-ch.com/en/nakabukuro-ran/). From the box width and height (mm) and direction, returns the character size that fits (mm, rounded down to 0.1 mm), the line count and each line. Size uses a 1.5 mm margin inside each side and a 0.3× line gap, limited by both line length and line count (half-width letters/digits count as 0.6 in horizontal boxes; caps of 9 mm for addresses, 14 mm for amount/name). `kind: "address"` breaks between the street number and the building/room first, and only when that cannot reach 4 mm also after the prefecture/city or before the street number (runs like 12番地の18 or 1203号室 are never split; a line break in `text` marks the building; up to 4 lines); `postalCode` adds a 〒 line; vertical boxes get kanji street numbers (`numerals`: `digits` = 一〇, `tens` = 十). Below 4 mm, `alternatives` gives the size and lines with the prefecture dropped and with the building on two lines (it does not decide what may be dropped); `asIs` is how many characters spill out when written unbroken at 5 mm. `kind: "amount"` writes 30000 / 3万 / 30,000円 in formal numerals (daiji) as 金参萬円 (1–99,999,999; 圓, 也 and pre-printed 金/円 supported); `name` breaks only at spaces; `plain` takes any text | `text`, `width`, `height` (mm), `orientation?` (`vertical` default / `horizontal`), `kind?` (`address` default / `name` / `amount` / `plain`), `postalCode?`, `numerals?`, `thousandChar?` (阡 default / 千 / 仟), `yenChar?` (円 / 圓), `nari?`, `kinEnPrinted?`, `lang?` |
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
+ | `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?` |
95
96
 
96
97
  ### App tools (`app_*`, sent to apps.first-ch.com)
97
98
 
@@ -139,6 +140,7 @@ Each `app_*` tool calls one app's public JSON API (`POST https://apps.first-ch.c
139
140
  | `app_ja_readability_check` | [Japanese Readability Checker](https://apps.first-ch.com/en/ja-readability-check/) — Enter a URL to check the Japanese typography of its body text: one-character orphan lines, punctuation at line start, characters per line against the 35–40 guideline and missing Japanese font fallbacks, estimated for desktop and mobile. | `url`, `cpl?` |
140
141
  | `app_faq_site_diff` | [FAQ vs Site Consistency Checker](https://apps.first-ch.com/en/faq-site-diff/) — Enter an FAQ or help page and up to three site pages to pull out prices, hours, phone numbers, dates and periods such as "within 7 days", and list every topic where the values disagree. Find outdated FAQ answers. | `faq`, `sites`[] |
141
142
  | `app_nap_check` | [Business Name, Address & Phone Consistency Checker](https://apps.first-ch.com/en/nap-check/) — Enter up to three pages of one site to pull the business name, address, phone and opening hours from the text, footer, tel: links and JSON-LD, and list formatting variants and possible mismatches between pages and structured data. Groundwork for local SEO. 10 calls per 10 minutes per IP. | `urls`[] |
143
+ | `app_henji_kuru` | [Count LINE Attendance Replies by Pasting the Chat](https://apps.first-ch.com/en/henji-kuru/) — AI check for the replies to a LINE group attendance call (○ going / × not going / △ not sure) that do not fit the format, such as “me too” or “absent for the previous one”. Send 1–10 rows (the reply and, optionally, the message before it) and get a category (yes / no / maybe / unclear), head count and short reason per row. The server masks phone numbers, e-mail addresses, @mentions and names before さん, but mask names yourself before sending. Tallying the whole chat runs in the browser on the page, not in this API. Shares the AI rate limits. | `lines`[], `count?` |
142
144
 
143
145
  See [`server.mjs`](./server.mjs) for the exact Zod input schemas of the local tools and [`apps.mjs`](./apps.mjs) for the `app_*` tools.
144
146
 
@@ -194,7 +196,7 @@ Release rule: a push to `main` automatically publishes a new package version thr
194
196
 
195
197
  `@first-ch/tools-mcp` は、[First CH Tools](https://tools.first-ch.com)(無料Webツール集)の計算ロジック — 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の一括生成・アスペクト比の計算とレスポンシブサイズの算出・camelCase / snake_case / kebab-case などの文字列ケース変換・CSV/TSV ⇄ JSON の相互変換・日数/営業日の計算(日本の祝日を内蔵)・HTML→Markdownの変換・和暦⇄西暦の変換と満年齢の計算・日本語タイトルからのURLスラッグ生成 — をAIエージェント(Claude Code等)向けMCPツールとして提供するサーバーです。これらは全て端末内で処理します。
196
198
 
197
- あわせて、[apps.first-ch.com](https://apps.first-ch.com) のWebアプリ38本(GEO・メタタグ・セキュリティヘッダー・SSL証明書・DNS/メールDNS・リダイレクト・リンク切れ・構造化データ・AIクローラー許可・和文可読性・AIによるビジネス文面/LP文言のチェックなど)を呼ぶ **`app_*` ツール**も提供します。**`app_*` ツールは入力(URL・ドメイン名・文面)を apps.first-ch.com のサーバーへ送り**、アプリの API が返した JSON を返します(端末内で完結する他のツールとはここが違います)。詳しくは [通信・ファイル・プライバシー](#通信ファイルプライバシー) を参照してください。
199
+ あわせて、[apps.first-ch.com](https://apps.first-ch.com) のWebアプリ39本(GEO・メタタグ・セキュリティヘッダー・SSL証明書・DNS/メールDNS・リダイレクト・リンク切れ・構造化データ・AIクローラー許可・和文可読性・AIによるビジネス文面/LP文言のチェックなど)を呼ぶ **`app_*` ツール**も提供します。**`app_*` ツールは入力(URL・ドメイン名・文面)を apps.first-ch.com のサーバーへ送り**、アプリの API が返した JSON を返します(端末内で完結する他のツールとはここが違います)。詳しくは [通信・ファイル・プライバシー](#通信ファイルプライバシー) を参照してください。
198
200
 
199
201
  ### インストール
200
202
 
@@ -282,6 +284,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
282
284
  | `fit_to_box` | 印刷済みの記入欄(市販の中袋〔ご祝儀袋・香典袋〕の「住所」「金額」「氏名」の欄など)に手で書くとき、欄の幅・高さ(mm)と向きから、収まる1字の大きさ(mm・0.1mm単位で切り捨て)・行数・改行した後の各行を返す(tools.first-ch.com/nakabukuro-ran/ と同一ロジック)。欄の線から内側へ1.5mmずつ余白を取り、行間を字の0.3倍として、行の長さと行数の両方から決める(横書きの半角英数は0.6字分・上限は住所9mm・金額と氏名14mm)。`kind: "address"` は「〜番地」と「建物名・部屋番号」の境目で改行し、そこで4mmに届かないときだけ都道府県・市区町村の後や番地の前でも区切る(「12番地の18」「1203号室」など数字の並びの途中では切らない・`text` の改行は建物名の前として扱う・最大4行)。`postalCode` で「〒」の行を先頭に足し、縦書きの欄では番地を漢数字にする(`numerals`: `digits`=一〇型 / `tens`=十型)。1字が4mm未満なら `alternatives` に「都道府県を省いた場合」「建物名を2行にした場合」の大きさと行を返す(省いてよいかは判断しない)。`asIs` は改行せずに1字5mmで書いたときにはみ出す字数。`kind: "amount"` は 30000・3万・30,000円 を大字の「金参萬円」にして欄に合わせる(1〜99,999,999円・圓/也/「金」「円」が印刷済みに対応)。`name` は空白でだけ改行し、`plain` は任意の文字列 | `text`、`width`・`height`(mm)、`orientation?`(既定 `vertical` / `horizontal`)、`kind?`(既定 `address` / `name` / `amount` / `plain`)、`postalCode?`、`numerals?`、`thousandChar?`(既定 阡 / 千 / 仟)、`yenChar?`(円 / 圓)、`nari?`、`kinEnPrinted?`、`lang?` |
283
285
  | `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` で金額を出さない。 |
284
286
  | `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
+ | `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?` |
285
288
 
286
289
  #### apps のツール(`app_*`・apps.first-ch.com へ送信)
287
290
 
@@ -309,7 +312,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
309
312
  | `app_mixed_content` | [混在コンテンツチェッカー](https://apps.first-ch.com/mixed-content/) — https のページに残った http:// の参照(img・script・link・iframe・video・source・CSS の url())を抽出し、行番号・タグ・直し方と、ブラウザがブロックするか自動で https 化されるかを返す。見つかった http:// のURLへはアクセスしない。 | `url` |
310
313
  | `app_image_audit` | [ページ内画像診断](https://apps.first-ch.com/image-audit/) — URLのページ内の img / picture を抽出し、フォーマット(WebP・AVIF 対応)・loading=lazy・width/height の指定・alt を診断する。先頭30枚は HEAD リクエストで実際のファイルサイズと形式まで測る。 | `url` |
311
314
  | `app_gazou_ichijouhou` | [写真の位置情報チェック](https://apps.first-ch.com/gazou-ichijouhou/) — URLのページの JPEG と、WordPress の元画像の候補(-幅x高さ・-scaled を外した同じサーバーのURL)を組にして、Exif に撮影場所(GPS の緯度・経度)が残っていないかを調べる。1回で offset から5組を判定し、組の一覧(先頭20組)・画像ごとの状態と理由・次の offset を返す(next が null になるまで呼ぶ)。座標・撮影日時の値と画像のバイト列は返さない。「none」は安全の保証ではない。 | `url`, `offset?` |
312
- | `app_shashin_sozai_moto` | [HP乗り換え前の写真名義チェック](https://apps.first-ch.com/shashin-sozai-moto/) — URLのページの img・srcset・picture の写真を最大30枚拾い、素材サイト形式のファイル名(現在は AdobeStock_数字 のみ)と、JPEG の先頭128KBの XMP・IPTC にある撮影者・クレジット・著作権表記(各60字まで)を返す。1回で offset から10枚を判定し、写真の一覧・写真ごとの状態と理由・次の offset を返す(next が null になるまで呼ぶ)。CSS の背景画像と JavaScript で足される画像は対象外。画像のバイト列とページの原文は返さず、権利関係や違法性は判定しない。 | `url`, `offset?` |
315
+ | `app_shashin_sozai_moto` | [制作会社の乗り換え前に写真の利用権を確認](https://apps.first-ch.com/shashin-sozai-moto/) — URLのページの img・srcset・picture の写真を最大30枚拾い、素材サイト形式のファイル名(現在は AdobeStock_数字 のみ)と、JPEG の先頭128KBの XMP・IPTC にある撮影者・クレジット・著作権表記(各60字まで)を返す。1回で offset から10枚を判定し、写真の一覧・写真ごとの状態と理由・次の offset を返す(next が null になるまで呼ぶ)。CSS の背景画像と JavaScript で足される画像は対象外。画像のバイト列とページの原文は返さず、権利関係や違法性は判定しない。 | `url`, `offset?` |
313
316
  | `app_hp_sumaho_check` | [うちのHP、スマホで見て3つ教えて|確認依頼カード](https://apps.first-ch.com/hp-sumaho-check/) — ページの HTML と同じサイトの CSS(最大3本・解析は合計96KB/2,000規則まで)から、①本文の電話番号ごとの tel: リンク ②横ずれ(viewport の width=device-width・body や #wrapper 等の900px以上の固定幅) ③文字と拡大(user-scalable=no・maximum-scale=1・body/p の12px未満)を check/none/unknown(理由つき)で返し、記述の位置・直し方の要点と、実機で見てもらう人に聞く「はい/いいえ」の質問(最大3問)・ref 付きの共有URLを返す。合否・点数は出さず、実機の表示の判定ではない。原文は返さない。 | `url` |
314
317
  | `app_tech_detect` | [技術スタック検出](https://apps.first-ch.com/tech-detect/) — URLのページの HTML と応答ヘッダーのシグネチャから、CMS(WordPress・Shopify・Wix・STUDIO 等)・フレームワーク・CDN・解析タグ(GA4/GTM)・Webフォントを推定し、そう判断した根拠(どこで何に合致したか)と一緒に返す。 | `url` |
315
318
  | `app_gaibu_soushinsaki` | [外部タグ棚卸し(解析・広告・SNS埋め込み)](https://apps.first-ch.com/gaibu-soushinsaki/) — URLのページを1回だけ取得し、HTMLに書かれた script の src・img・iframe の外部ホストとインラインの設置スニペットを、主要18サービス(Google・Meta・Microsoft・LinkedIn・LINEヤフー・X)の対応表と照合する。会社数・サービスごとの明細(一般的な用途・止める場所・公式資料の出典)・終了済みサービス(UA など)・表にない外部ホストと、確認用の棚卸し表(CSV)を返す。HTMLに書かれたタグだけを見るもので、実際の送信や法令への適合は判定しない(タグマネージャー経由のタグは見えない)。 | `url` |
@@ -329,6 +332,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
329
332
  | `app_ja_readability_check` | [和文可読性チェッカー](https://apps.first-ch.com/ja-readability-check/) — URLのページの本文の日本語タイポグラフィを、PC とスマホの画面幅で推定して診断する。1文字だけの孤立行・句読点や閉じ括弧の行頭禁則・1行の文字数(35〜40字の目安)・和文フォントのフォールバック欠けを該当箇所つきで返す。ページとその CSS(8本まで)を取得する。 | `url`, `cpl?` |
330
333
  | `app_faq_site_diff` | [FAQ×サイト 記載差分チェッカー](https://apps.first-ch.com/faq-site-diff/) — FAQ・ヘルプページと本体サイトのページ(3件まで)の料金・営業時間・電話番号・日付・「〇日以内」などの記載を突き合わせ、食い違う箇所を返す。FAQ の更新漏れ探しに使う。 | `faq`, `sites`[] |
331
334
  | `app_nap_check` | [会社名・住所・電話の表記ゆれチェッカー](https://apps.first-ch.com/nap-check/) — 同じサイトのページ(3件まで・同じオリジン)の表示テキスト・フッター・tel: リンク・JSON-LD から会社名・住所・電話番号・営業時間を拾い、ページ間や構造化データとの表記ゆれ・不一致候補を返す。ローカルSEOの下調べに使う。同じIPから10分に10回まで(超えると HTTP 429)。 | `urls`[] |
335
+ | `app_henji_kuru` | [LINEの出欠の返事を貼るだけで数える|出欠集計](https://apps.first-ch.com/henji-kuru/) — LINEグループの出欠確認(○=参加・×=不参加・△=未定)への返事のうち、「私も」「前の件は欠席」など型に合わない行を1〜10行受け取り、行ごとに区分(yes / no / maybe / unclear)・人数・短い理由を返す(AI)。各行は返事と任意の直前の発言。サーバーでも電話・メール・@・「〜さん」の前の名前を伏せるが、名前は送る前に伏せておく。トーク履歴全体の集計はページの端末内の処理で、この API は行わない。AI の回数制限は共通。 | `lines`[], `count?` |
332
336
 
333
337
  正確な入力スキーマ(Zod定義)は、端末内のツールが [`server.mjs`](./server.mjs)、`app_*` ツールが [`apps.mjs`](./apps.mjs) を参照してください。
334
338
 
package/apps.mjs CHANGED
@@ -29,7 +29,7 @@ const SENDS = (what) =>
29
29
  const FETCHES = 'apps.first-ch.com のサーバーが対象のサイトへアクセスするので、相手のサーバーにはこちらの端末ではなく apps.first-ch.com からのアクセスとして記録される。';
30
30
  const RESULT = '応答は API の JSON をそのまま返す(入力の不備・相手サイトに届かない等は error と message つきのエラーになる)。';
31
31
  const AI_LIMIT =
32
- '**回数制限あり**: 同じIPから10分に5回まで、さらに app_tone_check と app_lp_persona_check の合計で1日50回まで(日本時間9時にリセット)。' +
32
+ '**回数制限あり**: 同じIPから10分に5回まで、さらに app_tone_check・app_lp_persona_check・app_henji_kuru の合計で1日50回まで(日本時間9時にリセット)。' +
33
33
  '超えると HTTP 429(rate_limited / daily_limit)が返るので、間を置くか翌日に回す。AI による参考意見で、結果は毎回少し変わりうる。';
34
34
 
35
35
  const LANG = z
@@ -482,6 +482,33 @@ const DEFS = [
482
482
  lang: LANG,
483
483
  },
484
484
  },
485
+ {
486
+ slug: 'henji-kuru',
487
+ apiPath: '/henji-kuru/api/read',
488
+ title: 'LINEの出欠の返事の判定(AI・出欠集計の要確認行)',
489
+ summary:
490
+ 'LINEグループの出欠確認(○=参加・×=不参加・△=未定)への返事のうち、型に合わない行(「私も」「前の件は欠席」など)を1〜10行受け取り、行ごとに区分(yes / no / maybe / unclear)・人数・短い理由を返す。' +
491
+ '各行は返事の本文と、任意で直前の発言(context)。サーバー側でも電話・メール・@の宛先・「〜さん」の前の名前を伏せてから判定するが、送る前に名前・連絡先は伏せておくこと。' +
492
+ 'トーク履歴全体の集計(募集文より前・期限後の除外、○×△と人数の数え上げ)は apps.first-ch.com/henji-kuru/ の端末内の処理で、この API は行わない。' +
493
+ 'この API には合計50回とは別に1日15回の枠があり(合計の内数)、枠か合計を使い切ると daily_limit になる。',
494
+ sends: '入力した返事の行と直前の発言',
495
+ ai: true,
496
+ slow: true,
497
+ inputSchema: {
498
+ lines: z
499
+ .array(
500
+ z.object({
501
+ text: z.string().min(1).max(300).describe('返事の本文(300文字まで)'),
502
+ context: z.string().max(300).optional().describe('直前の発言(任意・300文字まで)。「私も」の判断に使う'),
503
+ }),
504
+ )
505
+ .min(1)
506
+ .max(10)
507
+ .describe('判定する返事の行(1〜10件)'),
508
+ count: z.boolean().optional().describe('募集で人数も聞いたなら true(既定 true)。false なら count は常に null'),
509
+ lang: LANG,
510
+ },
511
+ },
485
512
  ];
486
513
 
487
514
  const toolName = (slug) => `app_${slug.replace(/-/g, '_')}`;
@@ -0,0 +1,575 @@
1
+ /* 受け取ったComfyUI画像のキー点検(comfy_png_leak_scan)
2
+ * 解析のコアは FirstCHTools の site/comfy-key-leak/lib.mjs と同一
3
+ * (2箇所ルール: site側が正本・片方を直したらもう片方も同じ内容で反映する)。
4
+ * 両ファイルの「ここからコア」〜「ここまでコア」はバイト一致する(どちらも ES module):
5
+ * diff <(sed -n '/^\/\/ ===== ここから/,/^\/\/ ===== ここまで/p' site/comfy-key-leak/lib.mjs) <(sed -n '/^\/\/ ===== ここから/,/^\/\/ ===== ここまで/p' comfy-png-leak.mjs)
6
+ *
7
+ * ComfyUI の PNG のチャンクを順に読み、CRC を確かめ、tEXt と非圧縮の iTXt の文字列から APIキーの形(AIza・sk-・sk-ant-・hf_・r8_)を探す。
8
+ * prompt ならノードID・class_type・inputs の名前、workflow だけならノードIDと widgets_values の何番目かを返す。値は先頭4字だけを残して伏せ、元の値は返さない。
9
+ * キーが有効かどうかは確かめない。完全ローカル処理・ネットワーク送信なし。 */
10
+
11
+ import { readFile, stat } from 'node:fs/promises';
12
+ import path from 'node:path';
13
+ import { writeOutput } from './fs-safe.mjs';
14
+
15
+ // ===== ここからコア =====
16
+ export const MAX_BYTES = 30 * 1024 * 1024; // これを超える PNG は読まずに「未検査」
17
+ const SIG = [137, 80, 78, 71, 13, 10, 26, 10];
18
+ const TEXT_TYPES = ['tEXt', 'iTXt', 'zTXt'];
19
+ // 中身に文字列を持たない(キーが入りようのない)既知のチャンク。これ以外の補助チャンクは形だけ探して「未検査」に数える
20
+ const BINARY_TYPES = ['IHDR', 'PLTE', 'IDAT', 'IEND', 'tRNS', 'cHRM', 'gAMA', 'iCCP', 'sBIT', 'sRGB', 'cICP', 'mDCV', 'cLLI', 'bKGD', 'hIST', 'pHYs', 'sPLT', 'tIME', 'acTL', 'fcTL', 'fdAT', 'oFFs', 'pCAL', 'sCAL', 'sTER', 'dSIG', 'gIFg', 'gIFx', 'vpAg', 'iDOT', 'orNT'];
21
+
22
+ // キーの形。sk-ant- は sk- より先に見る。前に英数字・_・- が続く場合(task- など)は拾わない
23
+ export const KINDS = {
24
+ anthropic: { prefix: 'sk-ant-', re: 'sk-ant-[A-Za-z0-9_-]{20,}' },
25
+ openai: { prefix: 'sk-', re: 'sk-[A-Za-z0-9_-]{20,}' },
26
+ google: { prefix: 'AIza', re: 'AIza[A-Za-z0-9_-]{35}' },
27
+ huggingface: { prefix: 'hf_', re: 'hf_[A-Za-z0-9]{30,}' },
28
+ replicate: { prefix: 'r8_', re: 'r8_[A-Za-z0-9]{30,}' },
29
+ };
30
+ const KIND_ORDER = ['anthropic', 'openai', 'google', 'huggingface', 'replicate'];
31
+ function keyRe() {
32
+ return new RegExp('(?<![A-Za-z0-9_-])(?:' + KIND_ORDER.map((k) => '(' + KINDS[k].re + ')').join('|') + ')', 'g');
33
+ }
34
+
35
+ // 各サービスの公式の無効化(削除・作り直し)画面
36
+ export const REVOKE = {
37
+ google: [
38
+ { ja: 'Google Cloud コンソールの「認証情報」', en: 'Google Cloud console – Credentials', url: 'https://console.cloud.google.com/apis/credentials' },
39
+ { ja: 'Google AI Studio の API キー', en: 'Google AI Studio – API keys', url: 'https://aistudio.google.com/app/apikey' },
40
+ ],
41
+ openai: [{ ja: 'OpenAI の API keys', en: 'OpenAI – API keys', url: 'https://platform.openai.com/api-keys' }],
42
+ anthropic: [{ ja: 'Anthropic Console の API Keys', en: 'Anthropic Console – API keys', url: 'https://console.anthropic.com/settings/keys' }],
43
+ huggingface: [{ ja: 'Hugging Face の Access Tokens', en: 'Hugging Face – Access tokens', url: 'https://huggingface.co/settings/tokens' }],
44
+ replicate: [{ ja: 'Replicate の API tokens', en: 'Replicate – API tokens', url: 'https://replicate.com/account/api-tokens' }],
45
+ };
46
+
47
+ export const KIND_LABEL = {
48
+ ja: { google: 'Google の API キーの形', openai: 'OpenAI などの API キーの形', anthropic: 'Anthropic の API キーの形', huggingface: 'Hugging Face のトークンの形', replicate: 'Replicate のトークンの形' },
49
+ en: { google: 'Google API key format', openai: 'OpenAI-style API key format', anthropic: 'Anthropic API key format', huggingface: 'Hugging Face token format', replicate: 'Replicate token format' },
50
+ };
51
+
52
+ // ---- CRC-32(PNG の各チャンクの検査値) ----
53
+ let CRC_TABLE = null;
54
+ export function crc32(bytes, start = 0, end = bytes.length) {
55
+ if (!CRC_TABLE) {
56
+ CRC_TABLE = new Uint32Array(256);
57
+ for (let n = 0; n < 256; n++) {
58
+ let c = n;
59
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
60
+ CRC_TABLE[n] = c >>> 0;
61
+ }
62
+ }
63
+ let c = 0xffffffff;
64
+ for (let i = start; i < end; i++) c = CRC_TABLE[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);
65
+ return (c ^ 0xffffffff) >>> 0;
66
+ }
67
+
68
+ function u32(b, i) { return ((b[i] << 24) | (b[i + 1] << 16) | (b[i + 2] << 8) | b[i + 3]) >>> 0; }
69
+ function typeOf(b, i) { return String.fromCharCode(b[i], b[i + 1], b[i + 2], b[i + 3]); }
70
+ function latin1(b, s, e) { let o = ''; for (let i = s; i < e; i++) o += String.fromCharCode(b[i]); return o; }
71
+ function utf8(b, s, e, fallback) {
72
+ try { return new TextDecoder('utf-8', { fatal: true }).decode(b.subarray(s, e)); } catch (_) { return fallback ? latin1(b, s, e) : null; }
73
+ }
74
+
75
+ // 先頭の数バイトで形式を見分ける(PNG でないときの案内に使う)
76
+ export function sniff(b) {
77
+ if (b.length >= 8 && SIG.every((v, i) => b[i] === v)) return 'png';
78
+ if (b.length >= 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff) return 'jpeg';
79
+ if (b.length >= 12 && latin1(b, 0, 4) === 'RIFF' && latin1(b, 8, 12) === 'WEBP') return 'webp';
80
+ if (b.length >= 6 && /^GIF8[79]a$/.test(latin1(b, 0, 6))) return 'gif';
81
+ if (b.length >= 12 && latin1(b, 4, 8) === 'ftyp') return 'heif';
82
+ return 'other';
83
+ }
84
+
85
+ // チャンクを順に読む。壊れていれば { error } を返す(どこまで読めたかは chunks に残す)
86
+ export function readChunks(b) {
87
+ const chunks = [];
88
+ if (sniff(b) !== 'png') return { chunks, error: 'NOT_PNG' };
89
+ let i = 8, sawEnd = false;
90
+ while (i < b.length) {
91
+ if (i + 12 > b.length) return { chunks, error: 'TRUNCATED', at: i };
92
+ const len = u32(b, i), type = typeOf(b, i + 4);
93
+ if (!/^[A-Za-z]{4}$/.test(type)) return { chunks, error: 'BAD_TYPE', at: i };
94
+ if (len > 0x7fffffff || i + 12 + len > b.length) return { chunks, error: 'TRUNCATED', at: i };
95
+ const crc = u32(b, i + 8 + len);
96
+ if (crc32(b, i + 4, i + 8 + len) !== crc) return { chunks, error: 'CRC', at: i, type };
97
+ chunks.push({ type, offset: i, length: len, dataStart: i + 8, dataEnd: i + 8 + len, end: i + 12 + len });
98
+ i += 12 + len;
99
+ if (type === 'IEND') { sawEnd = true; break; }
100
+ }
101
+ if (!chunks.length || chunks[0].type !== 'IHDR') return { chunks, error: 'NO_IHDR' };
102
+ if (!sawEnd) return { chunks, error: 'NO_IEND' };
103
+ return { chunks, error: null, trailing: b.length - i, trailingStart: i };
104
+ }
105
+
106
+ // ---- JSON を、同じ名前の項目も捨てずに読む(値ごとに元の文字列の中の位置を持つ) ----
107
+ function parseJsonAst(s) {
108
+ let i = 0, depth = 0;
109
+ const ws = () => { while (i < s.length && (s[i] === ' ' || s[i] === '\t' || s[i] === '\n' || s[i] === '\r')) i++; };
110
+ const fail = () => { throw new Error('json'); };
111
+ function str() {
112
+ const start = i; i++;
113
+ let out = '';
114
+ for (;;) {
115
+ if (i >= s.length) fail();
116
+ const c = s[i];
117
+ if (c === '"') { i++; break; }
118
+ if (c === '\\') {
119
+ const e = s[i + 1];
120
+ if (e === 'u') { const h = s.slice(i + 2, i + 6); if (!/^[0-9a-fA-F]{4}$/.test(h)) fail(); out += String.fromCharCode(parseInt(h, 16)); i += 6; continue; }
121
+ const m = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }[e];
122
+ if (m === undefined) fail();
123
+ out += m; i += 2; continue;
124
+ }
125
+ out += c; i++;
126
+ }
127
+ return { t: 'str', v: out, start, end: i };
128
+ }
129
+ function val() {
130
+ ws();
131
+ const c = s[i];
132
+ if (c === '{') {
133
+ if (++depth > 400) fail();
134
+ const node = { t: 'obj', entries: [], start: i }; i++; ws();
135
+ if (s[i] === '}') { i++; depth--; node.end = i; return node; }
136
+ for (;;) {
137
+ ws(); if (s[i] !== '"') fail();
138
+ const k = str(); ws(); if (s[i] !== ':') fail(); i++;
139
+ node.entries.push([k, val()]); ws();
140
+ if (s[i] === ',') { i++; continue; }
141
+ if (s[i] === '}') { i++; break; }
142
+ fail();
143
+ }
144
+ depth--; node.end = i; return node;
145
+ }
146
+ if (c === '[') {
147
+ if (++depth > 400) fail();
148
+ const node = { t: 'arr', items: [], start: i }; i++; ws();
149
+ if (s[i] === ']') { i++; depth--; node.end = i; return node; }
150
+ for (;;) {
151
+ node.items.push(val()); ws();
152
+ if (s[i] === ',') { i++; continue; }
153
+ if (s[i] === ']') { i++; break; }
154
+ fail();
155
+ }
156
+ depth--; node.end = i; return node;
157
+ }
158
+ if (c === '"') return str();
159
+ const m = /^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(s.slice(i, i + 400));
160
+ if (!m) fail();
161
+ const start = i; i += m[0].length;
162
+ return { t: 'lit', v: m[0], start, end: i };
163
+ }
164
+ const root = val(); ws();
165
+ if (i !== s.length) fail();
166
+ return root;
167
+ }
168
+
169
+ function scalarOf(node) {
170
+ if (!node) return null;
171
+ if (node.t === 'str') return node.v;
172
+ if (node.t === 'lit') return node.v;
173
+ return null;
174
+ }
175
+ function entriesNamed(obj, name) { return obj && obj.t === 'obj' ? obj.entries.filter(([k]) => k.v === name).map(([, v]) => v) : []; }
176
+
177
+ // JSON の形から ComfyUI のどちらの形式かを見分ける(チャンクの名前は書き換えられるので形で見る)
178
+ function shapeOf(root) {
179
+ if (!root || root.t !== 'obj') return 'json';
180
+ if (entriesNamed(root, 'nodes').some((v) => v.t === 'arr')) return 'workflow';
181
+ const objs = root.entries.filter(([, v]) => v.t === 'obj');
182
+ if (objs.length && objs.some(([, v]) => entriesNamed(v, 'class_type').length)) return 'prompt';
183
+ return 'json';
184
+ }
185
+
186
+ function maskText(s) { return String(s).replace(keyRe(), (v) => maskValue(v)); }
187
+ function seg(s) { s = maskText(s); return s.length > 40 ? s.slice(0, 39) + '…' : s; }
188
+
189
+ export function maskValue(v) {
190
+ v = String(v);
191
+ return v.slice(0, 4) + '•'.repeat(Math.max(0, Math.min(v.length - 4, 12)));
192
+ }
193
+
194
+ // 文字列の値(と項目名)を辿り、キーの形が見つかったら場所をつけて返す
195
+ function walk(root, shape, push) {
196
+ const stack = []; // { node, key }(key は親の中での名前か番号)
197
+ function visit(node, key, isKey) {
198
+ if (node.t === 'str') { push(node.v, locate(shape, stack, key, isKey), node); return; }
199
+ stack.push({ node, key });
200
+ if (node.t === 'obj') for (const [k, v] of node.entries) { visit(k, k.v, true); visit(v, k.v, false); }
201
+ else if (node.t === 'arr') node.items.forEach((v, n) => visit(v, n, false));
202
+ stack.pop();
203
+ }
204
+ visit(root, null, false);
205
+ }
206
+
207
+ function locate(shape, stack, key, isKey) {
208
+ // stack[0] が根。path は根から見た名前・番号の並び(最後が値の位置)
209
+ const path = stack.slice(1).map((f) => f.key).concat([key]);
210
+ const dupKey = stack.some((f, n) => {
211
+ if (f.node.t !== 'obj') return false;
212
+ const name = n + 1 < stack.length ? stack[n + 1].key : key;
213
+ return typeof name === 'string' && f.node.entries.filter(([k]) => k.v === name).length > 1;
214
+ });
215
+ const loc = { shape, path: path.map((p) => typeof p === 'number' ? p : seg(p)), isKey: !!isKey, dupKey };
216
+ if (shape === 'prompt' && stack.length >= 2 && stack[1].node.t === 'obj') {
217
+ const node = stack[1].node;
218
+ loc.nodeId = seg(path[0]);
219
+ loc.classType = [...new Set(entriesNamed(node, 'class_type').map(scalarOf).filter((v) => v != null).map(seg))];
220
+ if (path[1] === 'inputs' && path.length >= 3 && !(path.length === 3 && isKey)) {
221
+ loc.input = seg(path[2]);
222
+ if (path.length > 3) loc.inputPath = path.slice(3).map((p) => typeof p === 'number' ? p : seg(p));
223
+ } else loc.extra = true;
224
+ return loc;
225
+ }
226
+ if (shape === 'workflow') {
227
+ // いちばん内側の「nodes 配列の要素」をノードとみなす(サブグラフの定義の中のノードも同じ)
228
+ for (let n = stack.length - 1; n >= 2; n--) {
229
+ const arr = stack[n - 1], el = stack[n];
230
+ if (arr.node.t === 'arr' && el.node.t === 'obj' && typeof arr.key === 'string' && arr.key === 'nodes' && n - 1 >= 1 && stack[n - 2].node.t === 'obj') {
231
+ const node = el.node;
232
+ const id = entriesNamed(node, 'id').map(scalarOf).find((v) => v != null);
233
+ loc.nodeId = id == null ? null : seg(id);
234
+ const mode = entriesNamed(node, 'mode').map(scalarOf).find((v) => v != null);
235
+ if (mode === '4') loc.bypassed = true;
236
+ if (mode === '2') loc.muted = true;
237
+ const rest = stack.slice(n + 1).map((f) => f.key).concat([key]);
238
+ if (n >= 3) loc.inSubgraph = stack.slice(1, n - 1).some((f) => f.key === 'subgraphs' || f.key === 'definitions');
239
+ if (rest[0] === 'widgets_values' && rest.length >= 2 && !(rest.length === 2 && isKey)) {
240
+ if (typeof rest[1] === 'number') loc.widgetIndex = rest[1];
241
+ else loc.widgetKey = seg(rest[1]);
242
+ loc.fieldUnknown = true;
243
+ } else { loc.extra = true; loc.rest = rest.map((p) => typeof p === 'number' ? p : seg(p)); }
244
+ return loc;
245
+ }
246
+ }
247
+ loc.extra = true;
248
+ return loc;
249
+ }
250
+ return loc;
251
+ }
252
+
253
+ function scanText(text, chunkInfo, findings) {
254
+ let root = null;
255
+ const t = text.trim();
256
+ if (t[0] === '{' || t[0] === '[') { try { root = parseJsonAst(text); } catch (_) { root = null; } }
257
+ const covered = [];
258
+ const add = (value, kind, loc) => {
259
+ findings.push({ kind, prefix: KINDS[kind].prefix, masked: maskValue(value), length: value.length, chunk: chunkInfo, ...loc });
260
+ };
261
+ const matchAll = (s, cb) => {
262
+ const re = keyRe(); let m;
263
+ while ((m = re.exec(s))) {
264
+ const n = m.slice(1).findIndex((x) => x !== undefined);
265
+ cb(m[0], KIND_ORDER[n], m.index);
266
+ }
267
+ };
268
+ if (root) {
269
+ const shape = shapeOf(root);
270
+ walk(root, shape, (s, loc, node) => {
271
+ covered.push([node.start, node.end]);
272
+ matchAll(s, (v, kind) => add(v, kind, loc));
273
+ });
274
+ }
275
+ // JSON として読めない文字列・文字列の外(書き損じた JSON など)は、文字列全体で探す
276
+ matchAll(text, (v, kind, at) => {
277
+ if (covered.some(([a, b]) => at >= a && at < b)) return;
278
+ add(v, kind, { shape: root ? 'json-outside' : 'text', path: [] });
279
+ });
280
+ return root ? shapeOf(root) : 'text';
281
+ }
282
+
283
+ /** PNG のバイト列を点検する。返り値に元の値は入らない(先頭4字と長さだけ) */
284
+ export function scanPng(bytes) {
285
+ const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
286
+ const res = { status: 'none', reason: null, format: sniff(b), size: b.length, chunks: [], findings: [], unchecked: [], hasCaBX: false, hasExif: false, canStrip: false, kinds: [], textChunks: 0, trailing: 0 };
287
+ if (b.length > MAX_BYTES) { res.status = 'unchecked'; res.reason = 'TOO_LARGE'; res.unchecked.push({ type: '*', why: 'TOO_LARGE' }); return res; }
288
+ const rc = readChunks(b);
289
+ if (rc.error) {
290
+ res.status = 'failed'; res.reason = rc.error;
291
+ if (rc.type) res.badChunk = rc.type;
292
+ return res;
293
+ }
294
+ for (const c of rc.chunks) {
295
+ const info = { type: c.type, length: c.length, offset: c.offset, checked: true };
296
+ if (c.type === 'tEXt' || c.type === 'iTXt' || c.type === 'zTXt') {
297
+ res.textChunks++;
298
+ const d = b.subarray(c.dataStart, c.dataEnd);
299
+ const z = d.indexOf(0);
300
+ info.keyword = seg(latin1(d, 0, z < 0 ? Math.min(d.length, 79) : z));
301
+ if (z < 0) { info.checked = false; info.why = 'MALFORMED'; }
302
+ else if (c.type === 'zTXt') { info.checked = false; info.why = 'COMPRESSED'; }
303
+ else if (c.type === 'tEXt') {
304
+ const text = utf8(d, z + 1, d.length, true);
305
+ info.shape = scanText(text, { type: c.type, keyword: info.keyword }, res.findings);
306
+ } else {
307
+ // iTXt: keyword \0 圧縮フラグ 圧縮方式 言語タグ \0 翻訳キーワード \0 本文(UTF-8)
308
+ const flag = d[z + 1];
309
+ const l1 = d.indexOf(0, z + 3), l2 = l1 < 0 ? -1 : d.indexOf(0, l1 + 1);
310
+ if (flag === 1) { info.checked = false; info.why = 'COMPRESSED'; }
311
+ else if (flag !== 0 || l2 < 0) { info.checked = false; info.why = 'MALFORMED'; }
312
+ else {
313
+ const text = utf8(d, l2 + 1, d.length, true);
314
+ info.shape = scanText(text, { type: c.type, keyword: info.keyword }, res.findings);
315
+ }
316
+ }
317
+ } else if (!BINARY_TYPES.includes(c.type)) {
318
+ // eXIf・caBX(C2PA)・名前の分からないチャンクは構造を読まない。形だけは探すが、検査したとは言わない
319
+ if (c.type === 'eXIf') res.hasExif = true;
320
+ if (c.type === 'caBX') res.hasCaBX = true;
321
+ info.checked = false; info.why = c.type === 'eXIf' ? 'EXIF' : c.type === 'caBX' ? 'C2PA' : 'UNKNOWN_CHUNK';
322
+ scanText(latin1(b, c.dataStart, c.dataEnd), { type: c.type, keyword: null }, res.findings);
323
+ }
324
+ if (!info.checked) res.unchecked.push({ type: c.type, keyword: info.keyword || null, why: info.why });
325
+ res.chunks.push(info);
326
+ }
327
+ if (rc.trailing > 0) {
328
+ res.trailing = rc.trailing;
329
+ res.unchecked.push({ type: 'IEND+', why: 'TRAILING' });
330
+ scanText(latin1(b, rc.trailingStart, b.length), { type: 'IEND+', keyword: null }, res.findings);
331
+ }
332
+ res.kinds = KIND_ORDER.filter((k) => res.findings.some((f) => f.kind === k));
333
+ res.status = res.findings.length ? 'found' : res.unchecked.length ? 'unchecked' : 'none';
334
+ res.canStrip = !res.hasCaBX && res.textChunks > 0;
335
+ return res;
336
+ }
337
+
338
+ /** 場所を1行の文にする(お知らせ文と画面で同じ言い方を使う) */
339
+ export function placeText(f, lang = 'ja') {
340
+ const ja = lang !== 'en';
341
+ const ct = f.classType && f.classType.length ? f.classType.join(' / ') : null;
342
+ const node = f.nodeId != null ? (ja ? 'ノードID ' + f.nodeId : 'node ID ' + f.nodeId) : null;
343
+ const p = (arr) => arr.map((x) => typeof x === 'number' ? '[' + x + ']' : x).join(' › ');
344
+ if (f.shape === 'prompt' && node) {
345
+ const head = node + (ct ? (ja ? '(' + ct + ')' : ' (' + ct + ')') : '');
346
+ if (f.input) return head + (ja ? 'の入力欄「' + f.input + '」' : ', input "' + f.input + '"') + (f.inputPath ? ' ' + p(f.inputPath) : '');
347
+ return head + (ja ? 'の inputs の外の項目「' : ', item outside inputs "') + p(f.path.slice(1)) + (ja ? '」' : '"');
348
+ }
349
+ if (f.shape === 'workflow' && node) {
350
+ if (f.widgetIndex != null) return node + (ja ? ' の widgets_values の ' + (f.widgetIndex + 1) + ' 番目' : ', widgets_values item ' + (f.widgetIndex + 1));
351
+ if (f.widgetKey != null) return node + (ja ? ' の widgets_values の「' + f.widgetKey + '」' : ', widgets_values "' + f.widgetKey + '"');
352
+ return node + (ja ? ' の項目「' : ', item "') + p(f.rest || []) + (ja ? '」' : '"');
353
+ }
354
+ const where = f.chunk.keyword ? (ja ? '埋め込みテキスト「' + f.chunk.keyword + '」' : 'embedded text "' + f.chunk.keyword + '"') : (f.chunk.type === 'IEND+' ? (ja ? '画像の終わりの後ろに付いたデータ' : 'data after the end of the image') : (ja ? f.chunk.type + ' チャンク' : f.chunk.type + ' chunk'));
355
+ if (f.path && f.path.length) return where + (ja ? 'の項目「' : ', item "') + p(f.path) + (ja ? '」' : '"');
356
+ return where + (ja ? 'の中' : '');
357
+ }
358
+
359
+ /** キーの持ち主へのお知らせ文。値・ファイル名は入れない。欠陥や責任を言い切らない */
360
+ export function buildNotice(res, lang = 'ja', opts = {}) {
361
+ const ja = lang !== 'en';
362
+ if (!res || res.status !== 'found') return '';
363
+ const lines = [], seen = new Set();
364
+ for (const f of res.findings) {
365
+ const src = f.shape === 'prompt' ? 'prompt' : f.shape === 'workflow' ? 'workflow' + (f.bypassed ? (ja ? '・迂回中のノード' : ', bypassed node') : f.muted ? (ja ? '・無効のノード' : ', muted node') : '') : null;
366
+ const l = '・' + placeText(f, lang) + (src ? (ja ? '(' + src + ')' : ' (' + src + ')') : '') + (ja ? ': ' : ': ') + KIND_LABEL[ja ? 'ja' : 'en'][f.kind] + (ja ? '(' + f.prefix + ' で始まる)' : ' (starts with ' + f.prefix + ')');
367
+ const line = ja ? l : l.replace(/^・/, '- ');
368
+ if (!seen.has(line)) { seen.add(line); lines.push(line); }
369
+ }
370
+ const url = opts.url === false ? null : (opts.url || (ja ? 'https://tools.first-ch.com/comfy-key-leak/' : 'https://tools.first-ch.com/en/comfy-key-leak/'));
371
+ if (ja) {
372
+ return ['お知らせです。受け取った画像(PNG)の埋め込みデータに、APIキー形式の文字列がありました。', ...lines,
373
+ '値そのものはこの連絡には書いていません。有効かどうかと、書き込まれた原因は確認していません。',
374
+ '心当たりのあるキーでしたら、発行元の管理画面で状態をご確認ください。']
375
+ .concat(url ? ['(確認には ' + url + ' を使いました。画像はブラウザの外へ送っていません)'] : []).join('\n');
376
+ }
377
+ return ['A quick heads-up: the embedded data of an image (PNG) I received contains strings in an API key format.', ...lines,
378
+ 'I have not included the values here. I have not checked whether they are valid, or how they got written into the image.',
379
+ 'If you recognise the key, you may want to check its status in the provider’s dashboard.']
380
+ .concat(url ? ['(Checked with ' + url + ' — the image was not sent anywhere.)'] : []).join('\n');
381
+ }
382
+
383
+ /** tEXt・iTXt・zTXt を抜いたコピー。caBX 付き・壊れた PNG は書き換えない */
384
+ export function stripTextChunks(bytes) {
385
+ const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
386
+ if (b.length > MAX_BYTES) throw Object.assign(new Error('too large'), { code: 'TOO_LARGE' });
387
+ const rc = readChunks(b);
388
+ if (rc.error) throw Object.assign(new Error('broken png'), { code: 'BROKEN' });
389
+ if (rc.chunks.some((c) => c.type === 'caBX')) throw Object.assign(new Error('has caBX (C2PA)'), { code: 'HAS_CABX' });
390
+ const keep = rc.chunks.filter((c) => !TEXT_TYPES.includes(c.type));
391
+ const removed = rc.chunks.filter((c) => TEXT_TYPES.includes(c.type)).map((c) => c.type);
392
+ let n = 8; for (const c of keep) n += c.end - c.offset;
393
+ const out = new Uint8Array(n);
394
+ out.set(b.subarray(0, 8), 0);
395
+ let o = 8; for (const c of keep) { out.set(b.subarray(c.offset, c.end), o); o += c.end - c.offset; }
396
+ return { bytes: out, removed, kept: keep.length, droppedTrailing: rc.trailing || 0 };
397
+ }
398
+
399
+ /** 書き出したコピーを読み直し、文字のチャンクが無いことと、残したチャンクが元とバイト単位で同じことを確かめる */
400
+ export function verifyStripped(orig, out) {
401
+ const a = readChunks(orig instanceof Uint8Array ? orig : new Uint8Array(orig));
402
+ const b = readChunks(out instanceof Uint8Array ? out : new Uint8Array(out));
403
+ const r = { ok: false, readable: !b.error, textLeft: 0, kept: 0, sameBytes: false };
404
+ if (a.error || b.error) return r;
405
+ r.textLeft = b.chunks.filter((c) => TEXT_TYPES.includes(c.type)).length;
406
+ const ka = a.chunks.filter((c) => !TEXT_TYPES.includes(c.type));
407
+ const A = orig instanceof Uint8Array ? orig : new Uint8Array(orig), B = out instanceof Uint8Array ? out : new Uint8Array(out);
408
+ r.kept = b.chunks.length;
409
+ r.sameBytes = ka.length === b.chunks.length && ka.every((c, n) => {
410
+ const d = b.chunks[n], len = c.end - c.offset;
411
+ if (d.end - d.offset !== len) return false;
412
+ for (let k = 0; k < len; k++) if (A[c.offset + k] !== B[d.offset + k]) return false;
413
+ return true;
414
+ });
415
+ r.ok = r.textLeft === 0 && r.sameBytes;
416
+ return r;
417
+ }
418
+ // ===== ここまでコア =====
419
+
420
+ // ---- MCP の入口 ----
421
+ export class ComfyPngLeakError extends Error {
422
+ constructor(code, message) { super(message); this.code = code; }
423
+ }
424
+
425
+ // お知らせ文。コアの「確認には〜を使いました・送っていません」はページで確かめたときの文なので使わず、MCP ではページを同じ点検ができる場所として添える
426
+ function mcpNotice(res, lang, withUrl) {
427
+ const base = buildNotice(res, lang, { url: false });
428
+ if (!base || !withUrl) return base;
429
+ return base + '\n' + (lang === 'en'
430
+ ? '(You can run the same check at https://tools.first-ch.com/en/comfy-key-leak/ — the page does not send the image anywhere.)'
431
+ : '(同じ点検は https://tools.first-ch.com/comfy-key-leak/ でもできます。ページは画像をブラウザの外へ送りません)');
432
+ }
433
+
434
+ export async function comfyPngLeakTool(opts = {}) {
435
+ const lang = opts.lang === 'en' ? 'en' : 'ja';
436
+ let bytes = null, size = 0, source;
437
+ if (opts.path) {
438
+ if (!path.isAbsolute(opts.path)) throw new ComfyPngLeakError('PATH_NOT_ABSOLUTE', 'path must be an absolute path');
439
+ const st = await stat(opts.path).catch(() => null);
440
+ if (!st || !st.isFile()) throw new ComfyPngLeakError('NOT_FOUND', 'file not found: ' + opts.path);
441
+ size = st.size; source = 'path';
442
+ if (size <= MAX_BYTES) bytes = new Uint8Array(await readFile(opts.path));
443
+ } else if (opts.base64) {
444
+ const b64 = String(opts.base64).replace(/^data:[^,]*,/, '').replace(/\s+/g, '');
445
+ if (!/^[A-Za-z0-9+/_-]*={0,2}$/.test(b64)) throw new ComfyPngLeakError('INVALID_BASE64', 'base64 is not valid');
446
+ bytes = new Uint8Array(Buffer.from(b64, 'base64'));
447
+ size = bytes.length; source = 'base64';
448
+ } else throw new ComfyPngLeakError('NO_INPUT', 'pass path (absolute) or base64');
449
+
450
+ // 大きいファイルは読まずに「未検査」(ページと同じ)
451
+ const res = bytes ? scanPng(bytes) : { status: 'unchecked', reason: 'TOO_LARGE', format: null, size, chunks: [], findings: [], unchecked: [{ type: '*', why: 'TOO_LARGE' }], hasCaBX: false, hasExif: false, canStrip: false, kinds: [], textChunks: 0, trailing: 0 };
452
+ const out = {
453
+ ok: true, source, status: res.status, reason: res.reason, format: res.format, size,
454
+ findings: res.findings.map((f) => ({ ...f, place: placeText(f, lang), kindLabel: KIND_LABEL[lang][f.kind] })),
455
+ kinds: res.kinds,
456
+ revoke: res.kinds.map((k) => ({ kind: k, links: REVOKE[k].map((r) => ({ label: r[lang], url: r.url })) })),
457
+ unchecked: res.unchecked, chunks: res.chunks, hasCaBX: res.hasCaBX, hasExif: res.hasExif, canStrip: res.canStrip,
458
+ notice: mcpNotice(res, lang, opts.includeUrl !== false),
459
+ caution: res.status === 'found'
460
+ ? (lang === 'en' ? 'If the image has already been posted or delivered and the key is in use, deleting the image is not enough; disable the key in the provider dashboard. Validity was not checked.'
461
+ : '投稿・納品済みで、実際に使っているキーなら、画像を消すだけでは対処できません。発行元の画面でキーを無効にしてください。キーが有効かどうかは確かめていません。')
462
+ : null,
463
+ };
464
+ if (source === 'base64') {
465
+ out.inputNote = lang === 'en'
466
+ ? 'This image was passed as base64, so its bytes (including any embedded key) are already in this AI conversation and were sent to the model provider. This tool itself sends nothing, but treat a found key as exposed. Pass path next time.'
467
+ : 'base64 で渡した画像は、埋め込まれたキーを含めて既にこの AI との会話に載り、モデルの提供元へ送られています。このツール自体は何も送りませんが、見つかったキーは外へ出たものとして扱ってください。次からは path で渡してください。';
468
+ }
469
+ if (opts.outPath) {
470
+ if (!path.isAbsolute(opts.outPath)) throw new ComfyPngLeakError('PATH_NOT_ABSOLUTE', 'outPath must be an absolute path');
471
+ if (opts.path && path.resolve(opts.outPath) === path.resolve(opts.path)) throw new ComfyPngLeakError('SAME_FILE', 'outPath must differ from path (the original is never overwritten)');
472
+ if (!bytes) throw new ComfyPngLeakError('TOO_LARGE', 'files over 30 MB are not rewritten');
473
+ if (res.status === 'failed') throw new ComfyPngLeakError('BROKEN', 'damaged or non-PNG files are not rewritten');
474
+ if (res.hasCaBX) throw new ComfyPngLeakError('HAS_CABX', 'PNGs with caBX (C2PA) are not rewritten');
475
+ const s = stripTextChunks(bytes);
476
+ const v = verifyStripped(bytes, s.bytes);
477
+ if (!v.ok) throw new ComfyPngLeakError('VERIFY_FAILED', 'the stripped copy did not pass the re-check; nothing was written');
478
+ await writeOutput(opts.outPath, s.bytes, { overwrite: opts.overwrite === true });
479
+ const again = scanPng(s.bytes);
480
+ out.stripped = { outPath: opts.outPath, removed: s.removed, kept: s.kept, droppedTrailingBytes: s.droppedTrailing, verify: v, remainingFindings: again.findings.length, exifKept: again.hasExif };
481
+ }
482
+ return out;
483
+ }
484
+
485
+ // ---- 見本(架空のキー)とテスト用の PNG を作る。キーの形の文字列はソースに直接書かない(実在のキーと見分けにくい並びを残さない) ----
486
+ export function fakeKey(kind, tag = 'EXAMPLE') {
487
+ const pre = { google: ['AI', 'za'], openai: ['s', 'k-', 'proj-'], anthropic: ['s', 'k-ant-', 'api03-'], huggingface: ['h', 'f_'], replicate: ['r', '8_'] }[kind].join('');
488
+ const body = ('FAKE0' + tag + '0NOT0A0REAL0KEY').replace(/[^A-Za-z0-9]/g, '0');
489
+ const n = { google: 35, openai: 40, anthropic: 40, huggingface: 34, replicate: 37 }[kind];
490
+ return pre + (body + '0'.repeat(n)).slice(0, n);
491
+ }
492
+
493
+ function chunk(type, data) {
494
+ const out = new Uint8Array(12 + data.length);
495
+ const len = data.length;
496
+ out[0] = len >>> 24; out[1] = (len >>> 16) & 255; out[2] = (len >>> 8) & 255; out[3] = len & 255;
497
+ for (let i = 0; i < 4; i++) out[4 + i] = type.charCodeAt(i);
498
+ out.set(data, 8);
499
+ const c = crc32(out, 4, 8 + len);
500
+ out[8 + len] = c >>> 24; out[9 + len] = (c >>> 16) & 255; out[10 + len] = (c >>> 8) & 255; out[11 + len] = c & 255;
501
+ return out;
502
+ }
503
+ export function textChunk(keyword, text, type = 'tEXt') {
504
+ const enc = new TextEncoder();
505
+ const k = enc.encode(keyword), t = type === 'tEXt' ? Uint8Array.from(String(text), (ch) => ch.charCodeAt(0) & 255) : enc.encode(text);
506
+ if (type === 'tEXt') return chunk('tEXt', concat([k, [0], t]));
507
+ return chunk('iTXt', concat([k, [0, 0, 0, 0, 0], t])); // 非圧縮・言語タグと翻訳キーワードは空
508
+ }
509
+ export function rawChunk(type, data) { return chunk(type, data instanceof Uint8Array ? data : Uint8Array.from(data)); }
510
+ function concat(parts) {
511
+ let n = 0; for (const p of parts) n += p.length;
512
+ const out = new Uint8Array(n); let o = 0;
513
+ for (const p of parts) { out.set(p, o); o += p.length; }
514
+ return out;
515
+ }
516
+
517
+ // 無圧縮の deflate(stored ブロック)で RGB の画像を PNG にする。extra は IDAT の前に入れるチャンク
518
+ export function makePng(w, h, pixel, extra = []) {
519
+ const raw = new Uint8Array((w * 3 + 1) * h);
520
+ for (let y = 0; y < h; y++) {
521
+ raw[y * (w * 3 + 1)] = 0;
522
+ for (let x = 0; x < w; x++) { const [r, g, bl] = pixel(x, y); const o = y * (w * 3 + 1) + 1 + x * 3; raw[o] = r; raw[o + 1] = g; raw[o + 2] = bl; }
523
+ }
524
+ const blocks = [];
525
+ for (let i = 0; i < raw.length; i += 65535) {
526
+ const part = raw.subarray(i, Math.min(raw.length, i + 65535)), last = i + 65535 >= raw.length ? 1 : 0;
527
+ blocks.push(Uint8Array.of(last, part.length & 255, part.length >>> 8, ~part.length & 255, (~part.length >>> 8) & 255), part);
528
+ }
529
+ let a = 1, b2 = 0;
530
+ for (let i = 0; i < raw.length; i++) { a = (a + raw[i]) % 65521; b2 = (b2 + a) % 65521; }
531
+ const adler = ((b2 << 16) | a) >>> 0;
532
+ const z = concat([[0x78, 0x01], ...blocks, [adler >>> 24, (adler >>> 16) & 255, (adler >>> 8) & 255, adler & 255]]);
533
+ const ihdr = Uint8Array.of(w >>> 24, (w >>> 16) & 255, (w >>> 8) & 255, w & 255, h >>> 24, (h >>> 16) & 255, (h >>> 8) & 255, h & 255, 8, 2, 0, 0, 0);
534
+ return concat([Uint8Array.from(SIG), chunk('IHDR', ihdr), ...extra, chunk('IDAT', z), chunk('IEND', new Uint8Array(0))]);
535
+ }
536
+
537
+ // 見本の画像: 夕方の空と山(ComfyUI の出力を想定した架空の1枚)。prompt と workflow に架空のキーを入れる
538
+ export function samplePrompt() {
539
+ return {
540
+ '3': { inputs: { seed: 42, steps: 20, cfg: 7, sampler_name: 'euler', scheduler: 'normal', denoise: 1, model: ['4', 0], positive: ['6', 0], negative: ['7', 0], latent_image: ['5', 0] }, class_type: 'KSampler', _meta: { title: 'KSampler' } },
541
+ '4': { inputs: { ckpt_name: 'example_model.safetensors' }, class_type: 'CheckpointLoaderSimple', _meta: { title: 'Load Checkpoint' } },
542
+ '6': { inputs: { text: 'sunset over mountains, soft light', clip: ['4', 1] }, class_type: 'CLIPTextEncode', _meta: { title: 'Prompt' } },
543
+ '12': { inputs: { prompt: 'refine the sky', model: 'example-pro', api_key: fakeKey('google', 'SAMPLE') }, class_type: 'ExampleGeminiPrompt', _meta: { title: '空の仕上げ' } },
544
+ '9': { inputs: { filename_prefix: 'ComfyUI', images: ['8', 0] }, class_type: 'SaveImage', _meta: { title: 'Save Image' } },
545
+ };
546
+ }
547
+ export function sampleWorkflow() {
548
+ return {
549
+ last_node_id: 15, last_link_id: 9,
550
+ nodes: [
551
+ { id: 3, type: 'KSampler', mode: 0, widgets_values: [42, 'fixed', 20, 7, 'euler', 'normal', 1] },
552
+ { id: 4, type: 'CheckpointLoaderSimple', mode: 0, widgets_values: ['example_model.safetensors'] },
553
+ { id: 12, type: 'ExampleGeminiPrompt', title: '空の仕上げ', mode: 0, widgets_values: ['refine the sky', 'example-pro', fakeKey('google', 'SAMPLE')] },
554
+ { id: 15, type: 'ExampleUpscaleAPI', title: 'アップスケール(今回は使わない)', mode: 4, widgets_values: [2, fakeKey('replicate', 'SAMPLE')] },
555
+ { id: 9, type: 'SaveImage', mode: 0, widgets_values: ['ComfyUI'] },
556
+ ],
557
+ links: [], groups: [], config: {}, extra: {}, version: 0.4,
558
+ };
559
+ }
560
+ // ComfyUI(Python の json.dumps)と同じく ASCII の外の文字は \uXXXX にする(tEXt は Latin-1)
561
+ export function asciiJson(v) { return JSON.stringify(v).replace(/[\u007f-\uffff]/g, (c) => '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0')); }
562
+ export function makeSamplePng(w = 360, h = 240) {
563
+ const px = (x, y) => {
564
+ const t = y / h;
565
+ let r = 250 - 70 * t, g = 170 - 90 * t, b = 120 + 40 * t;
566
+ const sx = x - w * 0.68, sy = y - h * 0.5, d = Math.sqrt(sx * sx + sy * sy);
567
+ if (d < h * 0.14) { r = 255; g = 226; b = 170; }
568
+ const m1 = h * 0.62 + Math.sin(x / w * 7) * h * 0.08 + Math.sin(x / w * 17) * h * 0.03;
569
+ const m2 = h * 0.78 + Math.sin(x / w * 5 + 1) * h * 0.06;
570
+ if (y > m1) { r = 92; g = 70; b = 96; }
571
+ if (y > m2) { r = 52; g = 44; b = 66; }
572
+ return [Math.round(r), Math.round(g), Math.round(b)];
573
+ };
574
+ return makePng(w, h, px, [textChunk('prompt', asciiJson(samplePrompt())), textChunk('workflow', asciiJson(sampleWorkflow()))]);
575
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@first-ch/tools-mcp",
3
- "version": "0.48.0",
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が書いた返信案と届いたメールの照合(原文に無い日付・曜日・時刻・金額・数量・電話・宛名を赤、消し忘れの仮の文字を黄))をMCPツールとして提供するサーバー。あわせて apps.first-ch.com のWebアプリ38本(GEO・メタタグ・セキュリティヘッダー・SSL・DNS・リダイレクト・リンク切れ・構造化データ・AIクローラー許可・和文可読性・ビジネス文面チェック等)の JSON API を呼ぶ app_* ツールも提供する(こちらは入力を apps.first-ch.com へ送るため既定では無効・FIRSTCH_ENABLE_APPS=1 で有効)",
3
+ "version": "0.50.0",
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": {
7
7
  "firstch-tools-mcp": "server.mjs"
@@ -281,6 +281,7 @@
281
281
  "fs-safe.mjs",
282
282
  "fit-to-box.mjs",
283
283
  "invoice-nebiki.mjs",
284
+ "comfy-png-leak.mjs",
284
285
  "reply-check.mjs",
285
286
  "webp.mjs",
286
287
  "marp.mjs",
package/server.mjs CHANGED
@@ -48,6 +48,7 @@ import { cssLayoutGenerateTool } from './css-layout.mjs';
48
48
  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
+ import { comfyPngLeakTool } from './comfy-png-leak.mjs';
51
52
  import { replyCheckTool } from './reply-check.mjs';
52
53
 
53
54
  const { version } = createRequire(import.meta.url)('./package.json');
@@ -2064,4 +2065,31 @@ registerTool(
2064
2065
  },
2065
2066
  );
2066
2067
 
2068
+ registerTool(
2069
+ 'comfy_png_leak_scan',
2070
+ {
2071
+ title: '受け取ったComfyUI画像のキー点検とお知らせ文',
2072
+ description:
2073
+ 'ComfyUI の PNG の埋め込みデータ(tEXt・非圧縮 iTXt の prompt・workflow など)から APIキーの形(AIza・sk-・sk-ant-・hf_・r8_)を探す(tools.first-ch.com/comfy-key-leak/ と同一ロジック)。' +
2074
+ 'status は found(キーの形あり)/ none(見つからず。安全という意味ではない)/ unchecked(zTXt・圧縮 iTXt・eXIf・caBX・不明なチャンク・IEND の後ろ・30MB超で読めない部分がある)/ failed(CRC 不一致・途中で切れた・PNG でない)。' +
2075
+ 'findings の場所は prompt なら nodeId・classType・input、workflow だけなら nodeId と widgetIndex(入力欄名は特定できない・fieldUnknown)。JSON は重複キーの前の値も捨てずに読み、inputs の外(extra)・迂回ノード(bypassed)・JSON の外の文字も拾う。ノードの表示名(title)は使わない。' +
2076
+ '値は返さない(masked=先頭4字+伏せ字と length だけ)。notice はキーの持ち主へのお知らせ文(値・ファイル名なし、有効性と原因は確認していないと書く)。revoke は見つかった種類の公式の無効化画面。' +
2077
+ 'outPath を渡すと tEXt・iTXt・zTXt を抜いたコピーを書き、書く前に読み直して文字のチャンク0個・残したチャンクのバイト一致を確かめる(元のファイルは変えない・caBX 付きと壊れた PNG は書き換えない・既存ファイルは overwrite:true が無いと上書きしない)。' +
2078
+ 'キーが有効かどうかの確認・URL からの取得・JPEG/WebP の書き換えはしない。このツールはネットワークへ何も送らない。' +
2079
+ '入力は path を優先する: base64 で渡すと画像のバイト列(埋め込まれた生のキーを含む)が会話に載り、モデルの提供元へ渡る(そのとき返り値に inputNote が付く)。',
2080
+ inputSchema: {
2081
+ path: z.string().optional().describe('PNG の絶対パス(path か base64 のどちらか。こちらを優先)'),
2082
+ base64: z.string().optional().describe('PNG の Base64(data URI 可)。画像と埋め込まれたキーが会話に載りモデルの提供元へ渡るので、path が使えないときだけ'),
2083
+ outPath: z.string().optional().describe('文字のチャンクを抜いたコピーの書き出し先(絶対パス・任意)'),
2084
+ overwrite: z.boolean().optional().describe('outPath に既存ファイルがあるとき上書きするか(既定 false)'),
2085
+ includeUrl: z.boolean().optional().describe('お知らせ文に、同じ点検ができるページ(tools.first-ch.com)の URL を添えるか(既定 true)'),
2086
+ lang: z.enum(['ja', 'en']).optional().describe("文言の言語(既定 'ja')"),
2087
+ },
2088
+ },
2089
+ async (opts) => {
2090
+ await logUsage('comfy_png_leak_scan');
2091
+ return asText(await comfyPngLeakTool(opts));
2092
+ },
2093
+ );
2094
+
2067
2095
  serveStdio(buildServer);