@first-ch/tools-mcp 0.57.0 → 0.59.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 +6 -2
- package/apps.mjs +20 -0
- package/kuronuri-tail.mjs +155 -0
- package/package.json +4 -2
- package/server.mjs +22 -0
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
|
|
5
|
+
It also ships **`app_*` tools** for the 43 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
|
|
|
@@ -96,6 +96,7 @@ This server is also registered in the [MCP Registry](https://registry.modelconte
|
|
|
96
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. |
|
|
97
97
|
| `email_read_aloud` | For choosing a new email address you will repeat on the phone (same logic as tools.first-ch.com/en/mail-yomiage/). Pass up to five addresses or bare domains as `candidates`; for each it returns the read-aloud text (letters and digits one by one; `@` at, `.` dot, `-` hyphen, `_` underscore, `+` plus; only a final `.com`/`.net` read as a word) and its length in `units` (katakana morae with `lang: "ja"`, syllables with `"en"`), sorted shortest first (not a ranking). `facts` counts characters, symbols by kind (`@` excluded), repeated characters, digits and letter/digit switches. `chars` gives each character's reading, its phonetic-alphabet word from Japan's Radio Station Operation Rules Appended Table 5 (the same words as the ITU table) and a Japanese example word. Unreadable candidates come back with `ok: false` and an error code. `card` is a comparison line with the addresses masked. No ranking, look-alike checks, availability or existence checks. Fully local. |
|
|
98
98
|
| `renkyu_pair_plan` | For two people whose days off fall on different weekdays, planning 2027 together (same logic as tools.first-ch.com/en/renkyu-2027/). Give each person (`me`, `partner`) their weekdays off (`days`, 0=Sun…6=Sat; default Sat+Sun), whether they are off on Japanese public holidays (`holidays`) and over New Year 29 Dec–3 Jan (`yearEnd`), and the paid leave they can use (`leave`, 0–10), plus `maxTotal` (0–20) for both. Returns `together` (days both are off in 2027), `perMonth` (12 counts), each person's days off, and up to three `candidates`: runs where every day is off for both or covered by leave for whoever works, within each person's leave and `maxTotal`, bounded by a working day or the edge of the year (breaks across the new year are cut). Ordered by length, then total leave, then the gap between the two; overlapping runs keep only the top one. Each has `start`, `end`, `days`, `meLeave`, `partnerLeave` (YYYY-MM-DD) and a `label`. Also `text` (share sentence) and `url` (the page with the settings after `#`). Holidays follow the Cabinet Office table for 2027 (17 days). No shift work, three or more people, 2028+ or company calendars | `me?`, `partner?` (`days?`, `holidays?`, `yearEnd?`, `leave?`), `maxTotal?` (default: sum of both `leave`), `lang?` (`ja`/`en`) |
|
|
99
|
+
| `kuronuri_tail` | Checks whether data follows the end of a **PNG or JPEG** image (same logic as tools.first-ch.com/en/kuronuri/). For PNG the chunks are read in order with length, name and CRC checks up to `IEND`; for JPEG the markers are read in order, length segments are skipped by their length (so the `FFD9` of an EXIF thumbnail is not taken as the end) and entropy-coded data is scanned past `FF00` and RST markers to the main `EOI` after SOF and SOS (progressive files included). `status` is `found` (`trailingBytes` is the byte count), `none` or `unknown` (could not analyze: `reason` is `NOT_PNG_OR_JPEG`, `TRUNCATED`, `BAD_CRC`, `BAD_CHUNK`, `NO_HEADER`, `NO_IMAGE_DATA`, `BAD_MARKER` or `BAD_LENGTH`, with the offset in `at`). `imageEnd` is where the image ends. Trailing data can hold part of an image before it was edited, or another image or video added by a camera. It does not judge whether a black-out shows through, recover anything from the trailing data or rewrite the image. Fully local. | `base64` (data URI allowed, 50 MB max) or `path` (absolute), `lang?` |
|
|
99
100
|
|
|
100
101
|
### App tools (`app_*`, sent to apps.first-ch.com)
|
|
101
102
|
|
|
@@ -139,6 +140,7 @@ Each `app_*` tool calls one app's public JSON API (`POST https://apps.first-ch.c
|
|
|
139
140
|
| `app_myip` | [IP & Request Info](https://apps.first-ch.com/en/myip/) — Shows the public IP, estimated country/city, network (ASN), HTTP/TLS details, User-Agent and main request headers of the request your machine sends to apps.first-ch.com. Handy for VPN checks. | — |
|
|
140
141
|
| `app_brand_fetch` | [Brand Fetch](https://apps.first-ch.com/en/brand-fetch/) — Enter a domain to extract the site's logo, favicons, main colours and company description. Colours are ranked by CSS frequency with contrast ratios on white and black — handy for placeholder branding in proposals and mock-ups. | `url` |
|
|
141
142
|
| `app_tone_check` | [Japanese Business Tone Check](https://apps.first-ch.com/en/tone-check/) — Paste a Japanese business email or proposal to flag phrases that may read as rude, vague, double keigo or too pushy, with drop-in rewrites and cultural pitfalls for English translation (AI-generated advice). **Rate-limited**: 5 calls per 10 minutes per IP, and 50 calls per day shared with `app_lp_persona_check`. | `text` |
|
|
143
|
+
| `app_hondai_wariai` | [Will That Google Link Open Without Signing In?](https://apps.first-ch.com/en/hondai-wariai/) — Paste one Google Docs, Sheets, Slides or Drive file/folder share link; the server keeps only the file ID, asks Google once without signing in (no redirects followed, 5 s, 64 KB) and returns `login` (sign-in required), `public` (likely viewable, with the file name), `not_found` or `unknown`, plus fixes linked to Google's official help. Nothing is stored. **Rate-limited**: 5 calls per minute per IP. | `url` |
|
|
142
144
|
| `app_lp_persona_check` | [LP Copy Persona Check](https://apps.first-ch.com/en/lp-persona-check/) — Paste landing page copy and pick an industry (professional services, e-commerce or B2B SaaS) to get estimated scores and comments on clarity, trust, formality and purchase intent from three simulated Japanese buyer personas (AI-generated advice, not real customer feedback). **Rate-limited**: 5 calls per 10 minutes per IP, and 50 calls per day shared with `app_tone_check`. | `text`, `industry` |
|
|
143
145
|
| `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?` |
|
|
144
146
|
| `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`[] |
|
|
@@ -202,7 +204,7 @@ Release rule: a push to `main` automatically publishes a new package version thr
|
|
|
202
204
|
|
|
203
205
|
`@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ツールとして提供するサーバーです。これらは全て端末内で処理します。
|
|
204
206
|
|
|
205
|
-
あわせて、[apps.first-ch.com](https://apps.first-ch.com) のWebアプリ
|
|
207
|
+
あわせて、[apps.first-ch.com](https://apps.first-ch.com) のWebアプリ43本(GEO・メタタグ・セキュリティヘッダー・SSL証明書・DNS/メールDNS・リダイレクト・リンク切れ・構造化データ・AIクローラー許可・和文可読性・AIによるビジネス文面/LP文言のチェックなど)を呼ぶ **`app_*` ツール**も提供します。**`app_*` ツールは入力(URL・ドメイン名・文面)を apps.first-ch.com のサーバーへ送り**、アプリの API が返した JSON を返します(端末内で完結する他のツールとはここが違います)。詳しくは [通信・ファイル・プライバシー](#通信ファイルプライバシー) を参照してください。
|
|
206
208
|
|
|
207
209
|
### インストール
|
|
208
210
|
|
|
@@ -294,6 +296,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
|
|
|
294
296
|
| `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 は使わない。完全ローカル処理・送信なし。 |
|
|
295
297
|
| `email_read_aloud` | 電話や名刺で言い続けるメールアドレスを候補から決めるとき向け(tools.first-ch.com/mail-yomiage/ と同一ロジック)。`candidates` にアドレスかドメインを最大5件渡すと、候補ごとの読み上げ文(英字・数字は1字ずつ、`@` アットマーク・`.` ドット・`-` ハイフン・`_` アンダーバー・`+` プラス、末尾の `.com`・`.net` だけ語で読む)と長さ `units`(`lang: "ja"` はカタカナの拍・`"en"` は音節)を短い順に返す(順位ではない)。`facts` は文字数・記号の種類(`@` は数えない)・同じ文字の連続・数字の桁数・英字と数字の切り替わり回数。`chars` は1文字ずつの読み・欧文通話表の語(無線局運用規則 別表第五号・ITU と同じ語)・日本語の言い換え例。読めない候補は `ok: false` とエラーコード。`card` はアドレスを伏せ字にした比べの文。順位・見た目の似た文字・空き・実在の確認はしない。完全ローカル。 |
|
|
296
298
|
| `renkyu_pair_plan` | 休みの曜日が違う2人が2027年の予定を立てるとき向け(tools.first-ch.com/renkyu-2027/ と同一ロジック)。`me`・`partner` にそれぞれ休みの曜日(`days`・0=日〜6=土・既定は土日)、祝日に休むか(`holidays`)、年末年始 12/29〜1/3 に休むか(`yearEnd`)、使える有給(`leave`・0〜10日)を、`maxTotal`(0〜20)に2人の有給の合計の上限を渡すと、2027年に2人そろって休める日数(`together`)と月ごとの内訳(`perMonth`)、有給を足した連休の候補(`candidates`・最大3件)を返す。候補は期間の毎日が「2人とも休み」か「休みでない方の有給」で埋まり、各自の上限と合計の上限を守る期間(年をまたぐ連休は年の端で切る)。並びは長い順→有給の合計の少ない順→2人の差の小さい順で、重なる候補は上位1件。各候補は `start`・`end`・`days`・`meLeave`・`partnerLeave`・`label`。共有用の `text` と、条件を `#` 以降に入れたページの `url` も返す。祝日は内閣府の2027年の表(17日)。シフト制・3人以上・2028年以降・会社独自の休日は対象外 | `me?`・`partner?`(`days?`・`holidays?`・`yearEnd?`・`leave?`)、`maxTotal?`(既定は2人の `leave` の和)、`lang?` |
|
|
299
|
+
| `kuronuri_tail` | **PNG・JPEG** の画像の本体の終わりを決め、その後ろに付いたデータの有無とバイト数を返す(tools.first-ch.com/kuronuri/ と同一ロジック)。PNG はチャンクを順に読み、長さ・名前・CRC を確かめて `IEND` まで。JPEG はマーカーを順に読み、長さを持つセグメントは長さで飛ばし(EXIF の埋め込みサムネイルの `FFD9` を終端にしない)、符号化データは `FF00` と RST を飛ばして、SOF と SOS の後の本体の `EOI` まで(プログレッシブも読む)。`status` は `found`(`trailingBytes` にバイト数)・`none`・`unknown`(解析不能。`reason` は `NOT_PNG_OR_JPEG`・`TRUNCATED`・`BAD_CRC`・`BAD_CHUNK`・`NO_HEADER`・`NO_IMAGE_DATA`・`BAD_MARKER`・`BAD_LENGTH`、位置は `at`)。`imageEnd` は本体の終わりの位置。後ろのデータには、編集前の画像の一部やカメラが付けた別の画像・動画が入っていることがある。黒塗りが透けているかの判定・後ろのデータからの復元・画像の書き換えはしない。完全ローカル。 | `base64`(data URI 可・50MBまで)か `path`(絶対パス)、`lang?` |
|
|
297
300
|
|
|
298
301
|
#### apps のツール(`app_*`・apps.first-ch.com へ送信)
|
|
299
302
|
|
|
@@ -337,6 +340,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
|
|
|
337
340
|
| `app_myip` | [IP・リクエスト情報の確認](https://apps.first-ch.com/myip/) — この MCP サーバーが動いている端末から apps.first-ch.com へ届いたリクエストを見て、グローバルIP・推定国/都市・回線(ASN)・HTTP/TLS の方式・User-Agent・主要リクエストヘッダーを返す。VPN の切り替え確認などに使う。 | — |
|
|
338
341
|
| `app_brand_fetch` | [ブランド情報抽出](https://apps.first-ch.com/brand-fetch/) — サイトのロゴ・ファビコン・主要配色・会社説明を抽出して返す。配色は CSS の出現頻度順で、白地・黒地とのコントラスト比つき。画像は URL と寸法だけを返す。提案書やモックの仮ブランド作りに使う。 | `url` |
|
|
339
342
|
| `app_tone_check` | [ビジネス文面のニュアンスチェック](https://apps.first-ch.com/tone-check/) — 日本語のビジネスメール・提案文の失礼・曖昧・二重敬語・催促のきつさを「相手にどう受け取られるか」の観点で指摘し、言い換え候補を返す。英訳して送るときの文化的な誤解ポイントも添える。**回数制限あり**(同じIPから10分に5回・AIの2本合計で1日50回)。 | `text` |
|
|
343
|
+
| `app_hondai_wariai` | [そのGoogleリンク、ログインなしで開く?](https://apps.first-ch.com/hondai-wariai/) — Google のドキュメント・スプレッドシート・スライド・ドライブのファイルとフォルダの共有リンクを1つ渡すと、サーバーがファイルIDだけを取り出し、ログインなしで Google へ1回だけ問い合わせて(転送は追わない・5秒・64KB)、`login`(ログインが必要)・`public`(閲覧できる見込み・ファイル名つき)・`not_found`・`unknown` と、Google 公式ヘルプつきの直し方を返す。保存しない。**回数制限あり**(同じIPから1分に5回)。 | `url` |
|
|
340
344
|
| `app_lp_persona_check` | [LP文言・ペルソナ反応チェッカー](https://apps.first-ch.com/lp-persona-check/) — LP・サービス紹介の訴求文を、選んだ業種(士業・EC・BtoB SaaS)の疑似ペルソナ3人の視点で読み、分かりやすさ・信頼性・購買意欲への影響の推定スコア、敬語トーンの強弱(5段階)、ペルソナごとの反応、言い換え案を返す。疑似ペルソナによる推測で、実在の顧客の反応ではない。**回数制限あり**(同じIPから10分に5回・AIの2本合計で1日50回)。 | `text`, `industry` |
|
|
341
345
|
| `app_ja_readability_check` | [和文可読性チェッカー](https://apps.first-ch.com/ja-readability-check/) — URLのページの本文の日本語タイポグラフィを、PC とスマホの画面幅で推定して診断する。1文字だけの孤立行・句読点や閉じ括弧の行頭禁則・1行の文字数(35〜40字の目安)・和文フォントのフォールバック欠けを該当箇所つきで返す。ページとその CSS(8本まで)を取得する。 | `url`, `cpl?` |
|
|
342
346
|
| `app_faq_site_diff` | [FAQ×サイト 記載差分チェッカー](https://apps.first-ch.com/faq-site-diff/) — FAQ・ヘルプページと本体サイトのページ(3件まで)の料金・営業時間・電話番号・日付・「〇日以内」などの記載を突き合わせ、食い違う箇所を返す。FAQ の更新漏れ探しに使う。 | `faq`, `sites`[] |
|
package/apps.mjs
CHANGED
|
@@ -422,6 +422,25 @@ const DEFS = [
|
|
|
422
422
|
lang: LANG,
|
|
423
423
|
},
|
|
424
424
|
},
|
|
425
|
+
{
|
|
426
|
+
slug: 'hondai-wariai',
|
|
427
|
+
apiPath: '/hondai-wariai/api/check',
|
|
428
|
+
title: 'そのGoogleリンク、ログインなしで開く?(共有リンクの確認)',
|
|
429
|
+
summary:
|
|
430
|
+
'Google のドキュメント・スプレッドシート・スライド・ドライブのファイルとフォルダの共有リンクを1つ受け取り、ログインしていない状態で Google へ1回だけ問い合わせて、相手側から見た状態を返す。' +
|
|
431
|
+
'verdict は login(ログインが必要)・public(ログインなしで閲覧できる見込み。fileName にファイル名)・not_found(見つからない)・unknown(判定できない。reason に理由)のどれか。直し方(steps)と Google 公式ヘルプのリンク、チームに伝える一言(share)も返す。' +
|
|
432
|
+
'サーバーは URL からファイルIDだけを取り出し、docs.google.com・drive.google.com の決まった形の URL に組み直して問い合わせる(転送は追わない・5秒・64KB)。Google 以外のサービスや「ウェブに公開」の URL(/d/e/…)は受けない。同じIPから1分に5回まで。',
|
|
433
|
+
sends: '入力した Google の共有リンク',
|
|
434
|
+
fetches: true,
|
|
435
|
+
inputSchema: {
|
|
436
|
+
url: z
|
|
437
|
+
.string()
|
|
438
|
+
.min(1)
|
|
439
|
+
.max(2048)
|
|
440
|
+
.describe('Google の共有リンク(docs.google.com の document・spreadsheets・presentation、drive.google.com の file・folders・open?id=。2048文字まで)'),
|
|
441
|
+
lang: LANG,
|
|
442
|
+
},
|
|
443
|
+
},
|
|
425
444
|
{
|
|
426
445
|
slug: 'lp-persona-check',
|
|
427
446
|
apiPath: '/lp-persona-check/api/check',
|
|
@@ -545,6 +564,7 @@ const DEFS = [
|
|
|
545
564
|
picks: z
|
|
546
565
|
.array(z.enum(['c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8']))
|
|
547
566
|
.max(2)
|
|
567
|
+
.refine((a) => new Set(a).size === a.length, { message: '同じ手がかりIDを2回選べません' })
|
|
548
568
|
.optional()
|
|
549
569
|
.describe('言い換える投稿の手がかりID(c1〜c8・重複なしで2件まで。省略時は0件)'),
|
|
550
570
|
final: z.boolean().optional().describe('true なら答え合わせ(result)も返す。既定 false'),
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* 画像の終端より後ろのデータの点検(kuronuri_tail)
|
|
2
|
+
* 判定のコアは FirstCHTools の site/kuronuri/lib.mjs と同一
|
|
3
|
+
* (2箇所ルール: site側が正本・片方を直したらもう片方も同じ内容で反映する)。
|
|
4
|
+
* 両ファイルの「ここからコア」〜「ここまでコア」はバイト一致する(どちらも ES module):
|
|
5
|
+
* diff <(sed -n '/^\/\/ ===== ここから/,/^\/\/ ===== ここまで/p' site/kuronuri/lib.mjs) <(sed -n '/^\/\/ ===== ここから/,/^\/\/ ===== ここまで/p' kuronuri-tail.mjs)
|
|
6
|
+
*
|
|
7
|
+
* PNG はチャンクを順に読み CRC を確かめて IEND まで、JPEG はマーカーを順に読んで本体の EOI まで(EXIF の埋め込みサムネイルの FFD9 は終端にしない)を
|
|
8
|
+
* 画像とみなし、その後ろに付いたデータの有無とバイト数を返す。透けの判定・後ろのデータからの復元はしない。完全ローカル処理・ネットワーク送信なし。 */
|
|
9
|
+
|
|
10
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
|
|
13
|
+
// ===== ここからコア =====
|
|
14
|
+
// 画像の本体の終わり(PNG は IEND の後ろ、JPEG は本体の EOI の後ろ)を決め、その後ろに付いたデータのバイト数を返す。
|
|
15
|
+
// 透けの判定はしない。構造を読めない・壊れている(途中で切れた・CRC が合わない・並びが崩れた)ときは status: 'unknown'。
|
|
16
|
+
// status: 'none'(後ろに何もない)/ 'found'(trailing バイトある)/ 'unknown'(解析不能・reason に理由)
|
|
17
|
+
export const MAX_BYTES = 50 * 1024 * 1024;
|
|
18
|
+
|
|
19
|
+
let CRC_TABLE = null;
|
|
20
|
+
export function crc32(b, start, end) {
|
|
21
|
+
if (!CRC_TABLE) {
|
|
22
|
+
CRC_TABLE = new Uint32Array(256);
|
|
23
|
+
for (let n = 0; n < 256; n++) {
|
|
24
|
+
let c = n;
|
|
25
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
26
|
+
CRC_TABLE[n] = c >>> 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
let c = 0xffffffff;
|
|
30
|
+
for (let i = start; i < end; i++) c = CRC_TABLE[(c ^ b[i]) & 255] ^ (c >>> 8);
|
|
31
|
+
return (c ^ 0xffffffff) >>> 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const PNG_SIG = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
35
|
+
const isLetter = (x) => (x >= 65 && x <= 90) || (x >= 97 && x <= 122);
|
|
36
|
+
|
|
37
|
+
export function sniff(b) {
|
|
38
|
+
if (b.length >= 8 && PNG_SIG.every((x, i) => b[i] === x)) return 'png';
|
|
39
|
+
if (b.length >= 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff) return 'jpeg';
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// PNG: シグネチャの後ろのチャンクを順に読む(長さ・名前・CRC)。先頭は IHDR、IEND までに IDAT が1つ以上
|
|
44
|
+
function pngEnd(b) {
|
|
45
|
+
const n = b.length;
|
|
46
|
+
let i = 8, first = true, sawIdat = false;
|
|
47
|
+
for (;;) {
|
|
48
|
+
if (i + 8 > n) return { reason: 'TRUNCATED', at: i };
|
|
49
|
+
const len = ((b[i] << 24) | (b[i + 1] << 16) | (b[i + 2] << 8) | b[i + 3]) >>> 0;
|
|
50
|
+
if (len > 0x7fffffff) return { reason: 'BAD_CHUNK', at: i };
|
|
51
|
+
for (let k = 4; k < 8; k++) if (!isLetter(b[i + k])) return { reason: 'BAD_CHUNK', at: i };
|
|
52
|
+
const type = String.fromCharCode(b[i + 4], b[i + 5], b[i + 6], b[i + 7]);
|
|
53
|
+
if (first && type !== 'IHDR') return { reason: 'NO_HEADER', at: i };
|
|
54
|
+
first = false;
|
|
55
|
+
if (i + 12 + len > n) return { reason: 'TRUNCATED', at: i };
|
|
56
|
+
const want = ((b[i + 8 + len] << 24) | (b[i + 9 + len] << 16) | (b[i + 10 + len] << 8) | b[i + 11 + len]) >>> 0;
|
|
57
|
+
if (crc32(b, i + 4, i + 8 + len) !== want) return { reason: 'BAD_CRC', at: i };
|
|
58
|
+
if (type === 'IDAT') sawIdat = true;
|
|
59
|
+
i += 12 + len;
|
|
60
|
+
if (type === 'IEND') return sawIdat ? { end: i } : { reason: 'NO_IMAGE_DATA', at: i };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// JPEG: SOI の後ろのマーカーを順に読む。長さを持つセグメントは長さで飛ばすので、APP1(EXIF)の中の
|
|
65
|
+
// 埋め込みサムネイルの FFD9 は終端にしない。SOS の後ろの符号化データは FF00(詰め物)と RST0〜7 を飛ばし、
|
|
66
|
+
// 次のマーカーまで進む(プログレッシブの複数の SOS も同じ)。本体の EOI は SOF と SOS の後にあるものだけ
|
|
67
|
+
function jpegEnd(b) {
|
|
68
|
+
const n = b.length;
|
|
69
|
+
let i = 2, sawSof = false, sawSos = false;
|
|
70
|
+
for (;;) {
|
|
71
|
+
if (i >= n) return { reason: 'TRUNCATED', at: i };
|
|
72
|
+
if (b[i] !== 0xff) return { reason: 'BAD_MARKER', at: i };
|
|
73
|
+
while (i < n && b[i] === 0xff) i++; // 詰め物の FF
|
|
74
|
+
if (i >= n) return { reason: 'TRUNCATED', at: i };
|
|
75
|
+
const m = b[i++];
|
|
76
|
+
if (m === 0xd9) return sawSos ? { end: i } : { reason: 'NO_IMAGE_DATA', at: i - 2 };
|
|
77
|
+
if (m === 0x00 || m === 0xd8) return { reason: 'BAD_MARKER', at: i - 2 };
|
|
78
|
+
if ((m >= 0xd0 && m <= 0xd7) || m === 0x01) continue; // 長さを持たないマーカー
|
|
79
|
+
if (i + 2 > n) return { reason: 'TRUNCATED', at: i };
|
|
80
|
+
const len = (b[i] << 8) | b[i + 1];
|
|
81
|
+
if (len < 2) return { reason: 'BAD_LENGTH', at: i - 2 };
|
|
82
|
+
if (i + len > n) return { reason: 'TRUNCATED', at: i - 2 };
|
|
83
|
+
if (m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc) sawSof = true;
|
|
84
|
+
i += len;
|
|
85
|
+
if (m !== 0xda) continue;
|
|
86
|
+
if (!sawSof) return { reason: 'BAD_MARKER', at: i - len - 2 };
|
|
87
|
+
sawSos = true;
|
|
88
|
+
// 符号化データ: 次の「FF + 00・RST 以外」まで進む
|
|
89
|
+
for (;;) {
|
|
90
|
+
const j = b.indexOf(0xff, i);
|
|
91
|
+
if (j < 0) return { reason: 'TRUNCATED', at: n };
|
|
92
|
+
let k = j + 1;
|
|
93
|
+
while (k < n && b[k] === 0xff) k++;
|
|
94
|
+
if (k >= n) return { reason: 'TRUNCATED', at: n };
|
|
95
|
+
const x = b[k];
|
|
96
|
+
if (x === 0x00 || (x >= 0xd0 && x <= 0xd7)) { i = k + 1; continue; }
|
|
97
|
+
i = k - 1;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function inspectTail(input) {
|
|
104
|
+
const b = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
105
|
+
const size = b.length;
|
|
106
|
+
const format = sniff(b);
|
|
107
|
+
if (!format) return { format: null, status: 'unknown', reason: 'NOT_PNG_OR_JPEG', size, end: null, trailing: null };
|
|
108
|
+
const r = format === 'png' ? pngEnd(b) : jpegEnd(b);
|
|
109
|
+
if (r.end == null) return { format, status: 'unknown', reason: r.reason, at: r.at, size, end: null, trailing: null };
|
|
110
|
+
const trailing = size - r.end;
|
|
111
|
+
return { format, status: trailing > 0 ? 'found' : 'none', reason: null, size, end: r.end, trailing };
|
|
112
|
+
}
|
|
113
|
+
// ===== ここまでコア =====
|
|
114
|
+
|
|
115
|
+
// ---- MCP の入口 ----
|
|
116
|
+
export class KuronuriTailError extends Error {
|
|
117
|
+
constructor(code, message) { super(message); this.code = code; }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const REASON = {
|
|
121
|
+
ja: { NOT_PNG_OR_JPEG: 'PNG・JPEG ではありません', TRUNCATED: 'ファイルが途中で切れています', BAD_CRC: 'チャンクの検査値(CRC)が合いません', BAD_CHUNK: 'チャンクの並びが崩れています', NO_HEADER: '先頭の情報(IHDR)がありません', NO_IMAGE_DATA: '画像のデータより先に終わりの印があります', BAD_MARKER: 'マーカーの並びが崩れています', BAD_LENGTH: 'セグメントの長さが不正です' },
|
|
122
|
+
en: { NOT_PNG_OR_JPEG: 'not a PNG or JPEG', TRUNCATED: 'the file is cut off', BAD_CRC: 'a chunk CRC does not match', BAD_CHUNK: 'the chunk layout is broken', NO_HEADER: 'the header (IHDR) is missing', NO_IMAGE_DATA: 'the end marker comes before the image data', BAD_MARKER: 'the marker layout is broken', BAD_LENGTH: 'a segment length is invalid' },
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export async function kuronuriTailTool(opts = {}) {
|
|
126
|
+
const lang = opts.lang === 'en' ? 'en' : 'ja';
|
|
127
|
+
let bytes, source;
|
|
128
|
+
if (opts.base64) {
|
|
129
|
+
const b64 = String(opts.base64).replace(/^data:[^,]*,/, '').replace(/\s+/g, '');
|
|
130
|
+
if (!/^[A-Za-z0-9+/_-]*={0,2}$/.test(b64)) throw new KuronuriTailError('INVALID_BASE64', 'base64 is not valid');
|
|
131
|
+
bytes = new Uint8Array(Buffer.from(b64, 'base64'));
|
|
132
|
+
source = 'base64';
|
|
133
|
+
} else if (opts.path) {
|
|
134
|
+
if (!path.isAbsolute(opts.path)) throw new KuronuriTailError('PATH_NOT_ABSOLUTE', 'path must be an absolute path');
|
|
135
|
+
const st = await stat(opts.path).catch(() => null);
|
|
136
|
+
if (!st || !st.isFile()) throw new KuronuriTailError('NOT_FOUND', 'file not found: ' + opts.path);
|
|
137
|
+
if (st.size > MAX_BYTES) throw new KuronuriTailError('TOO_LARGE', 'files over 50 MB are not read');
|
|
138
|
+
bytes = new Uint8Array(await readFile(opts.path));
|
|
139
|
+
source = 'path';
|
|
140
|
+
} else throw new KuronuriTailError('NO_INPUT', 'pass base64 (or an absolute path)');
|
|
141
|
+
if (bytes.length > MAX_BYTES) throw new KuronuriTailError('TOO_LARGE', 'images over 50 MB are not read');
|
|
142
|
+
const r = inspectTail(bytes);
|
|
143
|
+
const endName = r.format === 'png' ? 'IEND' : r.format === 'jpeg' ? 'EOI' : null;
|
|
144
|
+
let summary;
|
|
145
|
+
if (r.status === 'none') summary = lang === 'en' ? 'None: nothing follows the end of the image (' + endName + ').' : 'なし: 画像の終わり(' + endName + ')の後ろには何もありません。';
|
|
146
|
+
else if (r.status === 'found') summary = lang === 'en' ? 'Yes: ' + r.trailing + ' bytes follow the end of the image (' + endName + ').' : 'あり: 画像の終わり(' + endName + ')の後ろに ' + r.trailing + ' バイトのデータが付いています。';
|
|
147
|
+
else summary = lang === 'en' ? 'Could not analyze: ' + REASON.en[r.reason] + '.' : '解析不能: ' + REASON.ja[r.reason] + '。';
|
|
148
|
+
return {
|
|
149
|
+
ok: true, source, format: r.format, status: r.status, hasTrailing: r.status === 'unknown' ? null : r.status === 'found',
|
|
150
|
+
trailingBytes: r.trailing, imageEnd: r.end, size: r.size, reason: r.reason, at: r.at ?? null, summary,
|
|
151
|
+
note: lang === 'en'
|
|
152
|
+
? 'This only checks for data after the end of the image. It does not judge whether a black-out or marker shows through (check that visually at https://tools.first-ch.com/en/kuronuri/) and does not recover anything from the trailing data.'
|
|
153
|
+
: '画像の終端より後ろのデータだけを調べます。黒塗り・マーカーが透けているかは判定しません(目で確かめるには https://tools.first-ch.com/kuronuri/ )。後ろのデータからの復元もしません。',
|
|
154
|
+
};
|
|
155
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@first-ch/tools-mcp",
|
|
3
|
-
"version": "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と入力欄で場所を示し値は伏せる・持ち主へのお知らせ文・文字のチャンクを抜いたコピー)・GA4「トラフィック獲得」のCSVから AI Assistant と Organic Search の訪問をエンゲージメント率・平均エンゲージメント時間・キーイベント率で比べる集計(倍率・総計行との突き合わせ・除外した行の行番号・要約)・メールアドレス候補の読み上げ文と拍数(記号・同じ文字の連続・数字の桁数などの数え上げと欧文通話表の1
|
|
3
|
+
"version": "0.59.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と入力欄で場所を示し値は伏せる・持ち主へのお知らせ文・文字のチャンクを抜いたコピー)・GA4「トラフィック獲得」のCSVから AI Assistant と Organic Search の訪問をエンゲージメント率・平均エンゲージメント時間・キーイベント率で比べる集計(倍率・総計行との突き合わせ・除外した行の行番号・要約)・メールアドレス候補の読み上げ文と拍数(記号・同じ文字の連続・数字の桁数などの数え上げと欧文通話表の1文字ずつの表)・PNG/JPEG の画像の終端(IEND・本体の EOI)より後ろに付いたデータの有無とバイト数)をMCPツールとして提供するサーバー。あわせて apps.first-ch.com のWebアプリ43本(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"
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"text-fit",
|
|
26
26
|
"email-address",
|
|
27
27
|
"paid-leave",
|
|
28
|
+
"redaction",
|
|
28
29
|
"phonetic-alphabet",
|
|
29
30
|
"japanese-address",
|
|
30
31
|
"kanji-numerals",
|
|
@@ -288,6 +289,7 @@
|
|
|
288
289
|
"ai-vs-search.mjs",
|
|
289
290
|
"email-read-aloud.mjs",
|
|
290
291
|
"renkyu-pair.mjs",
|
|
292
|
+
"kuronuri-tail.mjs",
|
|
291
293
|
"reply-check.mjs",
|
|
292
294
|
"webp.mjs",
|
|
293
295
|
"marp.mjs",
|
package/server.mjs
CHANGED
|
@@ -52,6 +52,7 @@ import { comfyPngLeakTool } from './comfy-png-leak.mjs';
|
|
|
52
52
|
import { aiVsSearchTool } from './ai-vs-search.mjs';
|
|
53
53
|
import { emailReadAloudTool } from './email-read-aloud.mjs';
|
|
54
54
|
import { renkyuPairTool } from './renkyu-pair.mjs';
|
|
55
|
+
import { kuronuriTailTool } from './kuronuri-tail.mjs';
|
|
55
56
|
import { replyCheckTool } from './reply-check.mjs';
|
|
56
57
|
|
|
57
58
|
const { version } = createRequire(import.meta.url)('./package.json');
|
|
@@ -2174,4 +2175,25 @@ registerTool(
|
|
|
2174
2175
|
},
|
|
2175
2176
|
);
|
|
2176
2177
|
|
|
2178
|
+
registerTool(
|
|
2179
|
+
'kuronuri_tail',
|
|
2180
|
+
{
|
|
2181
|
+
title: '画像の終端より後ろのデータの有無とバイト数(PNG・JPEG)',
|
|
2182
|
+
description:
|
|
2183
|
+
'PNG・JPEG の画像の本体の終わりを決め、その後ろに付いたデータの有無とバイト数を返す(tools.first-ch.com/kuronuri/ と同一ロジック)。' +
|
|
2184
|
+
'PNG はシグネチャの後ろのチャンクを順に読み、長さ・名前・CRC を確かめて IEND まで(先頭は IHDR・IDAT が1つ以上)。JPEG は SOI の後ろのマーカーを順に読み、長さを持つセグメントは長さで飛ばす(EXIF の埋め込みサムネイルの FFD9 は終端にしない)。SOS の後ろの符号化データは FF00 と RST を飛ばして次のマーカーまで進み、SOF と SOS の後の EOI を本体の終わりとする(プログレッシブの複数の SOS も読む)。' +
|
|
2185
|
+
'status は found(後ろにデータあり・trailingBytes にバイト数)/ none(なし)/ unknown(解析不能。reason は NOT_PNG_OR_JPEG・TRUNCATED・BAD_CRC・BAD_CHUNK・NO_HEADER・NO_IMAGE_DATA・BAD_MARKER・BAD_LENGTH、at はその位置)。imageEnd は本体の終わりのバイト位置。' +
|
|
2186
|
+
'後ろのデータには、編集前の画像の一部やカメラが付けた別の画像・動画が入っていることがある。黒塗り・マーカーが透けているかの判定、後ろのデータからの復元、画像の書き換えはしない。完全ローカル処理・ネットワーク送信なし。',
|
|
2187
|
+
inputSchema: {
|
|
2188
|
+
base64: z.string().optional().describe('画像(PNG・JPEG)の Base64(data URI 可・50MBまで)'),
|
|
2189
|
+
path: z.string().optional().describe('base64 の代わりに、画像ファイルの絶対パス(任意)'),
|
|
2190
|
+
lang: z.enum(['ja', 'en']).optional().describe("summary・note の言語(既定 'ja')"),
|
|
2191
|
+
},
|
|
2192
|
+
},
|
|
2193
|
+
async (opts) => {
|
|
2194
|
+
await logUsage('kuronuri_tail');
|
|
2195
|
+
return asText(await kuronuriTailTool(opts));
|
|
2196
|
+
},
|
|
2197
|
+
);
|
|
2198
|
+
|
|
2177
2199
|
serveStdio(buildServer);
|