@first-ch/tools-mcp 0.59.0 → 0.61.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 +19 -0
- package/package.json +5 -2
- package/romaji-name.mjs +310 -0
- package/server.mjs +30 -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 44 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
|
|
|
@@ -97,6 +97,7 @@ This server is also registered in the [MCP Registry](https://registry.modelconte
|
|
|
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
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?` |
|
|
100
|
+
| `romaji_name_check` | Before typing a name into a flight booking or ESTA, compares the surname and given name **as printed in a passport** with up to six document spellings, letter by letter (same logic as tools.first-ch.com/en/romaji/). `documents` are `{ label, text }` objects or strings, written “SURNAME GIVEN” or “SURNAME/GIVEN” (the part before the slash is the surname). Case and full-width characters are ignored; titles such as MR or MS at either end are set aside and reported as `title`. Each document gets `verdict` `match` / `diff` (`review` for every row when `review: true` — an alias or a changed surname — and `empty` for blank text) and `differences` with `kind` (`swap`, `sep` space or hyphen, `ou` O vs U, `nm` N vs M before B/M/P, `lookalike` 0/O 1/I…, `drop`, `add`, `sub`, `title`, `extra_word`, `nonlatin`), the position (`part` surname / given / between, `position`, `after`) and a readable `text`. `status: "unknown"` (spelling unknown or passport lost) and `"never"` stop the check with a note. No kana-to-romaji conversion, long-vowel judgement, non-Hepburn approval, airline correction rules, or boarding/application verdict. Fully local. | `surname?`, `given?`, `documents?` (max 6), `status?`, `review?`, `lang?` |
|
|
100
101
|
|
|
101
102
|
### App tools (`app_*`, sent to apps.first-ch.com)
|
|
102
103
|
|
|
@@ -145,6 +146,7 @@ Each `app_*` tool calls one app's public JSON API (`POST https://apps.first-ch.c
|
|
|
145
146
|
| `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?` |
|
|
146
147
|
| `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`[] |
|
|
147
148
|
| `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`[] |
|
|
149
|
+
| `app_shuusei_irai_memo` | [Changed Your Phone Number? Find the Old Number and Call Buttons That Still Dial It](https://apps.first-ch.com/en/shuusei-irai-memo/) — Enter your site's URL and the old and new numbers (Japanese numbers) to search up to 10 pages of the same site (robots.txt and sitemap.xml respected) for the old number in text, call-button links (tel:) and JSON-LD telephone, with the heading above and 20 characters on each side, plus a count of buttons that show the new number but dial the old one. 10 calls per 10 minutes per IP. | `url`, `old`, `new` |
|
|
148
150
|
| `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?` |
|
|
149
151
|
| `app_notice_check` | [Leftover Placeholder Text Checker](https://apps.first-ch.com/en/notice-check/) — Fetches the home page and up to 6 same-site pages from its navigation (512KB each, 12s in total) and returns leftover candidates in 6 kinds: Japanese dummy-copy phrases, placeholder values (〇〇, 【会社名】, 000-0000-0000), lorem ipsum, WordPress defaults (Hello world!, Sample Page, Just another WordPress site), demo/placehold images and links to localhost or staging. Each page gets a state (checked / unreadable for JavaScript-drawn pages / failed / limit) plus the matched text, a short excerpt and the nearest heading; unchecked pages are not counted as checked. Pages themselves are never returned. 10 calls per 10 minutes per IP. | `url` |
|
|
150
152
|
| `app_site_freshness` | [Expired Notice Finder](https://apps.first-ch.com/en/site-freshness/) — Reads only the fetched HTML of the one page you enter (first 512KB, up to 8s; other pages, PDFs and JavaScript-drawn text are not checked) and returns notices still on the page after their end date: places where a date with a year (2025年12月28日, 2025/12/28, 2025.12.28) and a notice word (休業, 休診, 臨時休業, 営業時間, 開催, 説明会, キャンペーン, セール, 受付, 締切) appear in the same sentence and the end date is before today in Japan time. Periods are compared by their end date; posting dates (time elements, a date alone at the start of a list row) are left out. Each candidate has the kind, end date, days since and a 30-character excerpt on each side; dates without a year or that do not exist are listed separately and not counted. For Japanese-language pages. The page itself is never returned. 20 calls per 10 minutes per IP. | `url` |
|
|
@@ -204,7 +206,7 @@ Release rule: a push to `main` automatically publishes a new package version thr
|
|
|
204
206
|
|
|
205
207
|
`@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ツールとして提供するサーバーです。これらは全て端末内で処理します。
|
|
206
208
|
|
|
207
|
-
あわせて、[apps.first-ch.com](https://apps.first-ch.com) のWebアプリ
|
|
209
|
+
あわせて、[apps.first-ch.com](https://apps.first-ch.com) のWebアプリ44本(GEO・メタタグ・セキュリティヘッダー・SSL証明書・DNS/メールDNS・リダイレクト・リンク切れ・構造化データ・AIクローラー許可・和文可読性・AIによるビジネス文面/LP文言のチェックなど)を呼ぶ **`app_*` ツール**も提供します。**`app_*` ツールは入力(URL・ドメイン名・文面)を apps.first-ch.com のサーバーへ送り**、アプリの API が返した JSON を返します(端末内で完結する他のツールとはここが違います)。詳しくは [通信・ファイル・プライバシー](#通信ファイルプライバシー) を参照してください。
|
|
208
210
|
|
|
209
211
|
### インストール
|
|
210
212
|
|
|
@@ -297,6 +299,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
|
|
|
297
299
|
| `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` はアドレスを伏せ字にした比べの文。順位・見た目の似た文字・空き・実在の確認はしない。完全ローカル。 |
|
|
298
300
|
| `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
301
|
| `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?` |
|
|
302
|
+
| `romaji_name_check` | 航空券や ESTA に名前を入れる前に、**パスポートに印字された**姓・名と、書類のつづり(最大6つ)を1文字ずつ見比べる(tools.first-ch.com/romaji/ と同一ロジック)。`documents` は `{ label, text }` かつづりの文字列で、「姓 名」か「姓/名」(区切りの前を姓とみなす)。大文字小文字・全角半角は同じとみなし、前後の MR・MS などの敬称は外して `title` として返す。書類ごとの `verdict` は `match`/`diff`(`review: true`=別名併記・改姓なら全行 `review`、空は `empty`)、`differences` に `kind`(`swap` 姓と名の入れ替え・`sep` 空白/ハイフン・`ou` OとU・`nm` B/M/P の前の N と M・`lookalike` 0とO など・`drop`・`add`・`sub`・`title`・`extra_word`・`nonlatin`)、位置(`part` 姓/名/間・`position`・`after`)、読める文 `text`。`status: "unknown"`(表記不明・紛失)と `"never"`(取ったことがない)は照合せず案内を返す。仮名からのローマ字生成・長音の判定・非ヘボン表記の可否・航空会社ごとの訂正・搭乗や申請の可否は返さない。完全ローカル。 | `surname?`・`given?`・`documents?`(最大6)・`status?`・`review?`・`lang?` |
|
|
300
303
|
|
|
301
304
|
#### apps のツール(`app_*`・apps.first-ch.com へ送信)
|
|
302
305
|
|
|
@@ -345,6 +348,7 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
|
|
|
345
348
|
| `app_ja_readability_check` | [和文可読性チェッカー](https://apps.first-ch.com/ja-readability-check/) — URLのページの本文の日本語タイポグラフィを、PC とスマホの画面幅で推定して診断する。1文字だけの孤立行・句読点や閉じ括弧の行頭禁則・1行の文字数(35〜40字の目安)・和文フォントのフォールバック欠けを該当箇所つきで返す。ページとその CSS(8本まで)を取得する。 | `url`, `cpl?` |
|
|
346
349
|
| `app_faq_site_diff` | [FAQ×サイト 記載差分チェッカー](https://apps.first-ch.com/faq-site-diff/) — FAQ・ヘルプページと本体サイトのページ(3件まで)の料金・営業時間・電話番号・日付・「〇日以内」などの記載を突き合わせ、食い違う箇所を返す。FAQ の更新漏れ探しに使う。 | `faq`, `sites`[] |
|
|
347
350
|
| `app_nap_check` | [会社名・住所・電話の表記ゆれチェッカー](https://apps.first-ch.com/nap-check/) — 同じサイトのページ(3件まで・同じオリジン)の表示テキスト・フッター・tel: リンク・JSON-LD から会社名・住所・電話番号・営業時間を拾い、ページ間や構造化データとの表記ゆれ・不一致候補を返す。ローカルSEOの下調べに使う。同じIPから10分に10回まで(超えると HTTP 429)。 | `urls`[] |
|
|
351
|
+
| `app_shuusei_irai_memo` | [電話番号を変えた後、HPに残る旧番号と「押すと旧番号」を探す](https://apps.first-ch.com/shuusei-irai-memo/) — HPのURLと旧番号・新番号を入れると、robots.txt を守って sitemap.xml から同じサイトの最大10ページを読み、旧番号が残る本文・電話ボタンのリンク先(tel:)・JSON-LD の telephone を、直前の見出しと前後20字つきで返す。表示は新番号なのに押すと旧番号にかかるボタンの数も返す。同じIPから10分に10回まで。 | `url`・`old`・`new` |
|
|
348
352
|
| `app_henji_kuru` | [LINEの出欠の返事を貼るだけで数える|出欠集計](https://apps.first-ch.com/henji-kuru/) — LINEグループの出欠確認(○=参加・×=不参加・△=未定)への返事のうち、「私も」「前の件は欠席」など型に合わない行を1〜10行受け取り、行ごとに区分(yes / no / maybe / unclear)・人数・短い理由を返す(AI)。各行は返事と任意の直前の発言。サーバーでも電話・メール・@・「〜さん」の前の名前を伏せるが、名前は送る前に伏せておく。トーク履歴全体の集計はページの端末内の処理で、この API は行わない。AI の回数制限は共通。 | `lines`[], `count?` |
|
|
349
353
|
| `app_notice_check` | [公開直後のダミーテキスト・消し忘れチェック](https://apps.first-ch.com/notice-check/) — 公開URLのトップと、ナビにある同じサイトのページを最大6本(各512KB・全体12秒まで)取得し、日本語ダミー文の定型句・仮の値(〇〇・【会社名】・000-0000-0000)・lorem ipsum・WordPress の初期状態(Hello world!・サンプルページ・Just another WordPress site)・デモ/placehold 系の画像・localhost や staging へのリンクの6種類で消し忘れ候補を返す。ページごとに状態(検査済み・JavaScript で描くページ等の未検査・取得不能・12秒の上限)と、一致した語句・前後の短い抜粋・直近の見出しを返し、未検査のページは検査済みに数えない。ページの原文は返さない。同じIPから10分に10回まで。 | `url` |
|
|
350
354
|
| `app_site_freshness` | [終わった告知の残り探し](https://apps.first-ch.com/site-freshness/) — 入力した1ページの取得HTMLだけ(先頭512KB・8秒まで。他ページ・PDF・JavaScript で出る本文は見ない)を読み、年付きの日付(2025年12月28日・2025/12/28・2025.12.28)と同じ文の中の告知語(休業・休診・臨時休業・営業時間・開催・説明会・キャンペーン・セール・受付・締切)がそろい、終了日が日本時間の今日より前の告知候補を返す。期間は終了日で比べ、time 要素や一覧の行頭にある掲載日は外す。候補ごとに種別・終了日・何日過ぎたか・前後30字の抜粋を返し、年なし・実在しない日付は「読めなかった日付」に分けて件数に入れない。ページの原文は返さない。同じIPから10分に20回まで。 | `url` |
|
package/apps.mjs
CHANGED
|
@@ -501,6 +501,25 @@ const DEFS = [
|
|
|
501
501
|
lang: LANG,
|
|
502
502
|
},
|
|
503
503
|
},
|
|
504
|
+
{
|
|
505
|
+
slug: 'shuusei-irai-memo',
|
|
506
|
+
apiPath: '/shuusei-irai-memo/api/check',
|
|
507
|
+
title: '電話番号を変えた後、HPに残る旧番号と「押すと旧番号」を探す',
|
|
508
|
+
summary:
|
|
509
|
+
'HPのURLと旧番号・新番号(日本の0始まり10〜11桁)を受け取り、robots.txt を守って sitemap.xml(無ければトップの同じホストへのリンク)から同じサイトの最大10ページ(各先頭512KB・全体20秒)を1件ずつ取得し、旧番号が残る場所を返す。' +
|
|
510
|
+
'比べるのは1つのテキストノードの中・tel: のリンク先・JSON-LD の telephone だけで、番号は数字だけにそろえる(全角・ハイフン・括弧を除き、+81 は 0)。別々の要素にまたがる数字はつなげない。' +
|
|
511
|
+
'場所ごとにページのパス・場所の種類(本文/電話ボタンのリンク先/検索エンジン向け店舗情報)・直前の見出し・見つかった表記・前後20字を返し、表示は新番号なのにリンク先が旧番号のボタンの数(mismatch)と、確認したページ n/10・取得できなかったページ・512KBで打ち切ったページの行(scopeLine)を返す。' +
|
|
512
|
+
'画像・PDF・スクリプトで出る文字は見ない。住所・料金・営業時間は探さない。ページの原文は返さない。同じIPから10分に10回まで(超えると HTTP 429)。',
|
|
513
|
+
sends: '入力したURLと旧番号・新番号',
|
|
514
|
+
fetches: true,
|
|
515
|
+
slow: true,
|
|
516
|
+
inputSchema: {
|
|
517
|
+
url: URL_PARAM('調べるHPのURL(トップページ)'),
|
|
518
|
+
old: z.string().min(1).max(40).describe('旧電話番号(例: 03-0123-4567。全角・括弧・+81 も可。40文字まで)'),
|
|
519
|
+
new: z.string().min(1).max(40).describe('新電話番号(旧番号と別の番号。40文字まで)'),
|
|
520
|
+
lang: LANG,
|
|
521
|
+
},
|
|
522
|
+
},
|
|
504
523
|
{
|
|
505
524
|
slug: 'henji-kuru',
|
|
506
525
|
apiPath: '/henji-kuru/api/read',
|
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文字ずつの表)・PNG/JPEG の画像の終端(IEND・本体の EOI
|
|
3
|
+
"version": "0.61.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)より後ろに付いたデータの有無とバイト数・パスポートの氏名と航空券・ESTA などのつづりの1文字ずつの照合〔違いの位置と種類〕)をMCPツールとして提供するサーバー。あわせて apps.first-ch.com のWebアプリ44本(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"
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"email-address",
|
|
27
27
|
"paid-leave",
|
|
28
28
|
"redaction",
|
|
29
|
+
"romaji",
|
|
30
|
+
"passport",
|
|
29
31
|
"phonetic-alphabet",
|
|
30
32
|
"japanese-address",
|
|
31
33
|
"kanji-numerals",
|
|
@@ -290,6 +292,7 @@
|
|
|
290
292
|
"email-read-aloud.mjs",
|
|
291
293
|
"renkyu-pair.mjs",
|
|
292
294
|
"kuronuri-tail.mjs",
|
|
295
|
+
"romaji-name.mjs",
|
|
293
296
|
"reply-check.mjs",
|
|
294
297
|
"webp.mjs",
|
|
295
298
|
"marp.mjs",
|
package/romaji-name.mjs
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/* 航空券・ESTAの名前とパスポートの見比べ(romaji_name_check)
|
|
2
|
+
* 照合のコアは FirstCHTools の site/romaji/lib.mjs と同一
|
|
3
|
+
* (2箇所ルール: site側が正本・片方を直したらもう片方も同じ内容で反映する)。
|
|
4
|
+
* 両ファイルの「ここからコア」〜「ここまでコア」はバイト一致する(どちらも ES module):
|
|
5
|
+
* diff <(sed -n '/^\/\/ =* ここから/,/^\/\/ =* ここまで/p' site/romaji/lib.mjs) <(sed -n '/^\/\/ =* ここから/,/^\/\/ =* ここまで/p' romaji-name.mjs)
|
|
6
|
+
*
|
|
7
|
+
* パスポートに印字された姓・名と、書類ごとのつづり(最大6つ)を1文字ずつ並べ、書類ごとに一致か違いありと、
|
|
8
|
+
* 違いの位置と種類を返す。仮名からローマ字は作らず、搭乗や申請の可否も返さない。完全ローカル処理・ネットワーク送信なし。 */
|
|
9
|
+
|
|
10
|
+
// ==================== ここからコア ====================
|
|
11
|
+
// パスポートに印字された姓・名(利用者が打った基準)と、書類ごとのつづりを1文字ずつ並べて違いを探す。
|
|
12
|
+
// 仮名からローマ字は作らない。大文字と小文字の違い・全角と半角の違いは同じとみなす。
|
|
13
|
+
// 搭乗や申請の可否は返さない(違いの位置と種類だけ)。
|
|
14
|
+
export const MAX_DOCS = 6;
|
|
15
|
+
export const MAX_LEN = 80;
|
|
16
|
+
export const STATUSES = ['have', 'unknown', 'never']; // 手元にある/取得したが表記不明・紛失/取得したことがない
|
|
17
|
+
export const TITLES = ['MR', 'MRS', 'MS', 'MISS', 'MSTR', 'MSTER', 'MX', 'DR', 'PROF', 'SIR', 'MADAM'];
|
|
18
|
+
export const KINDS = ['swap', 'sep', 'ou', 'nm', 'lookalike', 'drop', 'add', 'sub', 'title', 'extra_word', 'nonlatin'];
|
|
19
|
+
export const KIND_LABEL = {
|
|
20
|
+
ja: {
|
|
21
|
+
swap: '姓と名の入れ替え', sep: '空白・ハイフンの有無', ou: 'OとUの違い', nm: 'B・M・Pの前のNとM',
|
|
22
|
+
lookalike: '似た字', drop: '文字の欠落', add: '文字の追加', sub: '違う字', title: '敬称の混入',
|
|
23
|
+
extra_word: 'ミドルネーム欄などの余分な語', nonlatin: 'ローマ字以外の文字',
|
|
24
|
+
},
|
|
25
|
+
en: {
|
|
26
|
+
swap: 'Surname and given name swapped', sep: 'Space or hyphen', ou: 'O vs U', nm: 'N vs M before B, M or P',
|
|
27
|
+
lookalike: 'Look-alike character', drop: 'Missing letter', add: 'Extra letter', sub: 'Different letter', title: 'Title mixed in',
|
|
28
|
+
extra_word: 'Extra word (middle-name field etc.)', nonlatin: 'Non-Latin character',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const LOOKALIKE = ['0O', '0Q', '0D', '1I', '1L', 'IL', '5S', '8B', '2Z', '6G', 'VU'];
|
|
32
|
+
const isSep = (c) => c === ' ' || c === '-';
|
|
33
|
+
const isLatin = (c) => /^[A-Z0-9 '\-.]$/.test(c);
|
|
34
|
+
|
|
35
|
+
export class RomajiError extends Error {
|
|
36
|
+
constructor(code, message) { super(message); this.code = code; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// NFKC(全角→半角)→大文字→空白をそろえる。wide=全角の英字・空白が入っていた
|
|
40
|
+
export function norm(s) {
|
|
41
|
+
const raw = String(s == null ? '' : s);
|
|
42
|
+
const wide = /[!-~ ]/.test(raw);
|
|
43
|
+
const text = raw.normalize('NFKC').toUpperCase().replace(/[\s ]+/g, ' ').trim().slice(0, MAX_LEN);
|
|
44
|
+
return { text, wide };
|
|
45
|
+
}
|
|
46
|
+
const compact = (s) => s.replace(/[\s\-'.]/g, '');
|
|
47
|
+
|
|
48
|
+
// 書類のつづり: 「姓/名」「姓,名」なら区切りの前を姓とみなす。前後の敬称(MR・MS など)は外して記録する
|
|
49
|
+
export function splitDoc(text) {
|
|
50
|
+
let t = text;
|
|
51
|
+
let slash = -1;
|
|
52
|
+
const m = /[\/,]/.exec(t);
|
|
53
|
+
if (m) { slash = m.index; t = (t.slice(0, m.index) + ' ' + t.slice(m.index + 1)).replace(/ +/g, ' ').trim(); }
|
|
54
|
+
const words = t.split(' ').filter(Boolean);
|
|
55
|
+
const titles = [];
|
|
56
|
+
const isTitle = (w) => TITLES.includes(w.replace(/\.$/, ''));
|
|
57
|
+
while (words.length > 1 && isTitle(words[words.length - 1])) titles.unshift(words.pop());
|
|
58
|
+
while (words.length > 1 && isTitle(words[0])) titles.unshift(words.shift());
|
|
59
|
+
return { body: words.join(' '), titles, slash: slash >= 0 };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 文字単位の編集距離と、その並べ方(同じ字・置き換え・欠落・追加)
|
|
63
|
+
export function align(a, b) {
|
|
64
|
+
const n = a.length, m = b.length;
|
|
65
|
+
const D = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
|
|
66
|
+
for (let i = 0; i <= n; i++) D[i][0] = i;
|
|
67
|
+
for (let j = 0; j <= m; j++) D[0][j] = j;
|
|
68
|
+
for (let i = 1; i <= n; i++) {
|
|
69
|
+
for (let j = 1; j <= m; j++) {
|
|
70
|
+
D[i][j] = Math.min(D[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1), D[i - 1][j] + 1, D[i][j - 1] + 1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const ops = [];
|
|
74
|
+
let i = n, j = m;
|
|
75
|
+
while (i > 0 || j > 0) {
|
|
76
|
+
if (i > 0 && j > 0 && D[i][j] === D[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)) {
|
|
77
|
+
ops.push({ op: a[i - 1] === b[j - 1] ? 'eq' : 'sub', a: a[i - 1], b: b[j - 1], ai: i - 1, bi: j - 1 }); i--; j--;
|
|
78
|
+
} else if (i > 0 && D[i][j] === D[i - 1][j] + 1) {
|
|
79
|
+
ops.push({ op: 'del', a: a[i - 1], b: '', ai: i - 1, bi: j }); i--;
|
|
80
|
+
} else {
|
|
81
|
+
ops.push({ op: 'ins', a: '', b: b[j - 1], ai: i, bi: j - 1 }); j--;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { dist: D[n][m], ops: ops.reverse() };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 基準の文字列と、各文字が姓・名の何文字目か(空白・ハイフンは数えない)
|
|
88
|
+
function baseLine(first, second, firstPart, secondPart) {
|
|
89
|
+
const text = first + ' ' + second;
|
|
90
|
+
const where = [];
|
|
91
|
+
let k = 0;
|
|
92
|
+
for (const c of first) { where.push(isSep(c) ? null : { part: firstPart, pos: ++k }); }
|
|
93
|
+
where.push({ part: 'between', pos: 0 });
|
|
94
|
+
k = 0;
|
|
95
|
+
for (const c of second) { where.push(isSep(c) ? null : { part: secondPart, pos: ++k }); }
|
|
96
|
+
return { text, where };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function classify(ops, base, doc) {
|
|
100
|
+
const diffs = [];
|
|
101
|
+
const baseMark = new Array(base.text.length).fill(null);
|
|
102
|
+
const docMark = new Array(doc.length).fill(null);
|
|
103
|
+
// 位置の言い方: 置き換え・欠落は基準のその字、追加は直前の基準の字の後ろ
|
|
104
|
+
const posAfter = (ai) => {
|
|
105
|
+
for (let k = ai - 1; k >= 0; k--) {
|
|
106
|
+
const w = base.where[k];
|
|
107
|
+
if (w) return w.part === 'between' ? w : { ...w, after: true };
|
|
108
|
+
}
|
|
109
|
+
return { part: null, pos: 0, after: true };
|
|
110
|
+
};
|
|
111
|
+
const posAt = (ai) => base.where[ai] || posAfter(ai);
|
|
112
|
+
let k = 0;
|
|
113
|
+
while (k < ops.length) {
|
|
114
|
+
const o = ops[k];
|
|
115
|
+
if (o.op === 'eq') { k++; continue; }
|
|
116
|
+
if (o.op === 'sub') {
|
|
117
|
+
const pair = [o.a, o.b].sort().join('');
|
|
118
|
+
const nextA = base.text[o.ai + 1] || '', nextB = doc[o.bi + 1] || '';
|
|
119
|
+
let kind = 'sub';
|
|
120
|
+
if (isSep(o.a) && isSep(o.b)) kind = 'sep';
|
|
121
|
+
else if (pair === 'OU') kind = 'ou';
|
|
122
|
+
else if (pair === 'MN' && (/[BMP]/.test(nextA) || /[BMP]/.test(nextB))) kind = 'nm';
|
|
123
|
+
else if (LOOKALIKE.includes(pair)) kind = 'lookalike';
|
|
124
|
+
diffs.push({ kind, from: o.a, to: o.b, baseAt: o.ai, docAt: o.bi, len: 1, where: posAt(o.ai) });
|
|
125
|
+
baseMark[o.ai] = kind; docMark[o.bi] = kind;
|
|
126
|
+
k++; continue;
|
|
127
|
+
}
|
|
128
|
+
// 同じ向きの欠落・追加は1つにまとめる
|
|
129
|
+
let e = k;
|
|
130
|
+
while (e + 1 < ops.length && ops[e + 1].op === o.op) e++;
|
|
131
|
+
const run = ops.slice(k, e + 1);
|
|
132
|
+
const chars = run.map((r) => (o.op === 'del' ? r.a : r.b)).join('');
|
|
133
|
+
const prev = o.op === 'del' ? base.text[o.ai - 1] || '' : doc[o.bi - 1] || '';
|
|
134
|
+
const next = o.op === 'del' ? base.text[o.ai + run.length] || '' : doc[o.bi + run.length] || '';
|
|
135
|
+
let kind;
|
|
136
|
+
if ([...chars].every(isSep)) kind = 'sep';
|
|
137
|
+
else if (chars.length === 1 && ((/[OU]/.test(chars) && prev === 'O') || (chars === 'O' && next === 'O'))) kind = 'ou';
|
|
138
|
+
else if (o.op === 'ins' && compact(chars).length >= 2 && (isSep(chars[0]) || prev === '' || prev === ' ') && (isSep(chars[chars.length - 1]) || next === '' || next === ' ')) kind = 'extra_word';
|
|
139
|
+
else kind = o.op === 'del' ? 'drop' : 'add';
|
|
140
|
+
if (o.op === 'del') {
|
|
141
|
+
diffs.push({ kind, from: chars, to: '', baseAt: o.ai, docAt: o.bi, len: chars.length, where: posAt(o.ai) });
|
|
142
|
+
for (const r of run) baseMark[r.ai] = kind;
|
|
143
|
+
} else {
|
|
144
|
+
diffs.push({ kind, from: '', to: chars, baseAt: o.ai, docAt: o.bi, len: chars.length, where: posAfter(o.ai) });
|
|
145
|
+
for (const r of run) docMark[r.bi] = kind;
|
|
146
|
+
}
|
|
147
|
+
k = e + 1;
|
|
148
|
+
}
|
|
149
|
+
return { diffs, baseMark, docMark };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 1つの書類のつづりを基準と比べる
|
|
153
|
+
export function compareOne(surname, given, docText) {
|
|
154
|
+
const S = norm(surname).text, G = norm(given).text;
|
|
155
|
+
const d = norm(docText);
|
|
156
|
+
if (!d.text) return { verdict: 'empty', text: '', wide: false, order: null, titles: [], diffs: [], base: '', baseMark: [], docMark: [], ops: [] };
|
|
157
|
+
const sp = splitDoc(d.text);
|
|
158
|
+
const body = sp.body;
|
|
159
|
+
// ローマ字以外の文字(仮名・漢字など)があれば、並べて比べずにその字だけを示す
|
|
160
|
+
if ([...body].some((ch) => !isLatin(ch))) {
|
|
161
|
+
const docMark = [...body].map((ch) => (isLatin(ch) ? null : 'nonlatin'));
|
|
162
|
+
const bad = [...new Set([...body].filter((ch) => !isLatin(ch)))].join('');
|
|
163
|
+
return { verdict: 'diff', text: body, wide: d.wide, order: null, titles: sp.titles,
|
|
164
|
+
diffs: [{ kind: 'nonlatin', from: '', to: bad, baseAt: -1, docAt: body.search(/[^A-Z0-9 '\-.]/), len: bad.length, where: null }],
|
|
165
|
+
base: (S + ' ' + G).trim(), baseMark: [], docMark, ops: [] };
|
|
166
|
+
}
|
|
167
|
+
const sg = baseLine(S, G, 'surname', 'given');
|
|
168
|
+
const gs = baseLine(G, S, 'given', 'surname');
|
|
169
|
+
const straight = align(sg.text, body);
|
|
170
|
+
// 姓と名を逆に並べた方が近ければ入れ替えとみなし、入れ替えた基準で残りの違いを探す
|
|
171
|
+
const swapped = S !== G && compact(S) && compact(G) ? align(gs.text, body) : null;
|
|
172
|
+
const useSwap = swapped && swapped.dist < straight.dist && compact(body) !== compact(sg.text);
|
|
173
|
+
const base = useSwap ? gs : sg;
|
|
174
|
+
const ops = (useSwap ? swapped : straight).ops;
|
|
175
|
+
const c = classify(ops, base, body);
|
|
176
|
+
const diffs = [];
|
|
177
|
+
if (useSwap) diffs.push({ kind: 'swap', from: '', to: '', baseAt: -1, docAt: -1, len: 0, where: null });
|
|
178
|
+
for (const t of sp.titles) diffs.push({ kind: 'title', from: '', to: t, baseAt: -1, docAt: -1, len: t.length, where: null });
|
|
179
|
+
diffs.push(...c.diffs);
|
|
180
|
+
return {
|
|
181
|
+
verdict: diffs.length ? 'diff' : 'match', text: body, wide: d.wide, order: useSwap ? 'given-first' : 'surname-first',
|
|
182
|
+
titles: sp.titles, diffs, base: base.text, baseMark: c.baseMark, docMark: c.docMark,
|
|
183
|
+
ops: ops.map((o) => ({ op: o.op, a: o.a, b: o.b, ai: o.ai, bi: o.bi })),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// 全体: パスポートの状態・別名併記や改姓の有無と、書類(最大6つ)
|
|
188
|
+
export function checkNames(input) {
|
|
189
|
+
const o = input && typeof input === 'object' ? input : {};
|
|
190
|
+
const status = STATUSES.includes(o.status) ? o.status : 'have';
|
|
191
|
+
const review = !!o.review;
|
|
192
|
+
const S = norm(o.surname), G = norm(o.given);
|
|
193
|
+
const base = { surname: S.text, given: G.text, text: (S.text + ' ' + G.text).trim(), wide: S.wide || G.wide,
|
|
194
|
+
nonLatin: [...(S.text + G.text)].some((ch) => !isLatin(ch)) };
|
|
195
|
+
if (status !== 'have') return { status, review, base, rows: [] };
|
|
196
|
+
const docs = Array.isArray(o.docs) ? o.docs.slice(0, MAX_DOCS) : [];
|
|
197
|
+
const rows = docs.map((x, i) => {
|
|
198
|
+
const label = String((x && x.label) || '').trim().slice(0, 40) || String(i + 1);
|
|
199
|
+
const r = base.text ? compareOne(S.text, G.text, x && x.text) : { verdict: 'empty', text: '', diffs: [], base: '', baseMark: [], docMark: [], titles: [], order: null, wide: false, ops: [] };
|
|
200
|
+
return { label, ...r, verdict: review && r.verdict !== 'empty' ? 'review' : r.verdict };
|
|
201
|
+
});
|
|
202
|
+
return { status, review, base, rows };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// 違い1件の位置の言い方(姓の3文字目・名の2文字目の後ろ・先頭)
|
|
206
|
+
export function whereText(w, lang = 'ja') {
|
|
207
|
+
if (!w) return '';
|
|
208
|
+
const part = w.part === 'surname' ? (lang === 'en' ? 'surname' : '姓') : w.part === 'given' ? (lang === 'en' ? 'given name' : '名') : '';
|
|
209
|
+
if (w.part === 'between') return lang === 'en' ? 'between surname and given name' : '姓と名の間';
|
|
210
|
+
if (!part) return lang === 'en' ? 'at the start' : '先頭';
|
|
211
|
+
if (lang === 'en') return w.after ? `after letter ${w.pos} of the ${part}` : `letter ${w.pos} of the ${part}`;
|
|
212
|
+
return w.after ? `${part}の${w.pos}文字目の後ろ` : `${part}の${w.pos}文字目`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 違い1件の短い説明(種類・位置・字)
|
|
216
|
+
export function diffText(d, lang = 'ja') {
|
|
217
|
+
const L = KIND_LABEL[lang === 'en' ? 'en' : 'ja'];
|
|
218
|
+
const label = L[d.kind] || d.kind;
|
|
219
|
+
if (d.kind === 'swap') return label;
|
|
220
|
+
if (d.kind === 'title') return `${label} (${d.to})`;
|
|
221
|
+
if (d.kind === 'nonlatin') return `${label}: ${d.to}`;
|
|
222
|
+
const at = whereText(d.where, lang);
|
|
223
|
+
const SEP = lang === 'en' ? { ' ': 'space', '-': 'hyphen' } : { ' ': '空白', '-': 'ハイフン' };
|
|
224
|
+
const sp = (s) => ([...s].every(isSep) ? [...s].map((c) => SEP[c]).join('+') : s.trim());
|
|
225
|
+
let what;
|
|
226
|
+
if (d.from && d.to) what = `${sp(d.from)} → ${sp(d.to)}`;
|
|
227
|
+
else if (d.from) what = lang === 'en' ? `${sp(d.from)} missing` : `${sp(d.from)} が無い`;
|
|
228
|
+
else what = lang === 'en' ? `extra ${sp(d.to)}` : `${sp(d.to)} が余分`;
|
|
229
|
+
return lang === 'en' ? `${label}: ${what}, ${at}` : `${label}: ${at} ${what}`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// 名前を伏せた表示: 語の頭文字と違いのある位置だけ残し、ほかは「•」
|
|
233
|
+
export function maskLine(text, marks) {
|
|
234
|
+
let out = '';
|
|
235
|
+
for (let i = 0; i < text.length; i++) {
|
|
236
|
+
const c = text[i];
|
|
237
|
+
const head = i === 0 || isSep(text[i - 1]);
|
|
238
|
+
out += isSep(c) || head || (marks && marks[i]) ? c : '•';
|
|
239
|
+
}
|
|
240
|
+
return out;
|
|
241
|
+
}
|
|
242
|
+
// ==================== ここまでコア ====================
|
|
243
|
+
|
|
244
|
+
// ---- MCP の入口 ----
|
|
245
|
+
const NOTES = {
|
|
246
|
+
ja: {
|
|
247
|
+
unknown: '基準未確認: パスポートの表記は戸籍の変更が無い限り原則として変えられないため、前に取ったパスポートの表記が基準になる。申請した旅券窓口で確かめてから照合する。',
|
|
248
|
+
never: '対象外: このツールはパスポートに印字された表記を基準にする。これから取る場合の表記の決まりは旅券窓口の資料(ヘボン式)を見る。',
|
|
249
|
+
review: '別名併記・改姓ありのため、全行を要確認とした。どの表記を入れるかは旅券窓口や予約先で確かめる。',
|
|
250
|
+
airline: '名前の入力の決まり(ミドルネーム・敬称の欄など)は航空会社ごとに違う。予約する航空会社の案内で確かめる。',
|
|
251
|
+
mynumber: 'マイナンバーカードに書いたローマ字は、原則として削除できない(豊島区)。',
|
|
252
|
+
},
|
|
253
|
+
en: {
|
|
254
|
+
unknown: 'Reference not confirmed: a Japanese passport spelling generally cannot change unless the family register changes, so the earlier passport sets the spelling. Check it with the passport office before comparing.',
|
|
255
|
+
never: 'Not covered: this check uses the spelling printed in a passport. For the rules used when applying, see the passport office guides (Hepburn).',
|
|
256
|
+
review: 'The passport shows an alias or the surname changed, so every row is marked for checking. Ask the passport office or the booking site which spelling to use.',
|
|
257
|
+
airline: 'Name entry rules (middle names, title fields and so on) differ by airline. Check the guide of the airline you book with.',
|
|
258
|
+
mynumber: 'Romaji added to a My Number Card generally cannot be removed (Toshima City).',
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
export const SOURCES = [
|
|
262
|
+
'https://www.pref.fukuoka.lg.jp/uploaded/attachment/107685.pdf',
|
|
263
|
+
'https://www.pref.osaka.lg.jp/o070140/passport/top/romaji.html',
|
|
264
|
+
'https://www.city.toshima.lg.jp/096/tetsuzuki/mynumber/2606031703.html',
|
|
265
|
+
'https://www.kojinbango-card.go.jp/260515_2/',
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
export function romajiNameTool(opts = {}) {
|
|
269
|
+
const lang = opts.lang === 'en' ? 'en' : 'ja';
|
|
270
|
+
const status = opts.status == null ? 'have' : opts.status;
|
|
271
|
+
if (!STATUSES.includes(status)) throw new RomajiError('BAD_STATUS', `status must be one of ${STATUSES.join(', ')}`);
|
|
272
|
+
if (status === 'have' && !norm(opts.surname).text && !norm(opts.given).text) throw new RomajiError('NO_NAME', 'surname or given (as printed in the passport) is required');
|
|
273
|
+
const docs = opts.documents == null ? [] : opts.documents;
|
|
274
|
+
if (!Array.isArray(docs)) throw new RomajiError('BAD_DOCUMENTS', 'documents must be an array of { label, text }');
|
|
275
|
+
if (docs.length > MAX_DOCS) throw new RomajiError('TOO_MANY', `documents: up to ${MAX_DOCS}`);
|
|
276
|
+
const r = checkNames({ status, review: !!opts.review, surname: opts.surname, given: opts.given, docs: docs.map((d) => (typeof d === 'string' ? { text: d } : d)) });
|
|
277
|
+
const N = NOTES[lang];
|
|
278
|
+
const notes = [];
|
|
279
|
+
if (status !== 'have') notes.push(N[status]);
|
|
280
|
+
else {
|
|
281
|
+
if (r.review) notes.push(N.review);
|
|
282
|
+
notes.push(N.airline, N.mynumber);
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
status: r.status,
|
|
286
|
+
stopped: status !== 'have',
|
|
287
|
+
passport: r.base.text,
|
|
288
|
+
passportNonLatin: r.base.nonLatin,
|
|
289
|
+
documents: r.rows.map((row) => ({
|
|
290
|
+
label: row.label,
|
|
291
|
+
text: row.text,
|
|
292
|
+
verdict: row.verdict,
|
|
293
|
+
order: row.order,
|
|
294
|
+
compared: row.base,
|
|
295
|
+
differences: row.diffs.map((d) => ({
|
|
296
|
+
kind: d.kind,
|
|
297
|
+
label: KIND_LABEL[lang][d.kind],
|
|
298
|
+
from: d.from,
|
|
299
|
+
to: d.to,
|
|
300
|
+
part: d.where ? d.where.part : null,
|
|
301
|
+
position: d.where ? d.where.pos : null,
|
|
302
|
+
after: !!(d.where && d.where.after),
|
|
303
|
+
text: diffText(d, lang),
|
|
304
|
+
})),
|
|
305
|
+
fullWidth: row.wide,
|
|
306
|
+
})),
|
|
307
|
+
notes,
|
|
308
|
+
sources: SOURCES,
|
|
309
|
+
};
|
|
310
|
+
}
|
package/server.mjs
CHANGED
|
@@ -53,6 +53,7 @@ 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
55
|
import { kuronuriTailTool } from './kuronuri-tail.mjs';
|
|
56
|
+
import { romajiNameTool } from './romaji-name.mjs';
|
|
56
57
|
import { replyCheckTool } from './reply-check.mjs';
|
|
57
58
|
|
|
58
59
|
const { version } = createRequire(import.meta.url)('./package.json');
|
|
@@ -2196,4 +2197,33 @@ registerTool(
|
|
|
2196
2197
|
},
|
|
2197
2198
|
);
|
|
2198
2199
|
|
|
2200
|
+
registerTool(
|
|
2201
|
+
'romaji_name_check',
|
|
2202
|
+
{
|
|
2203
|
+
title: 'パスポートの氏名と書類のつづりを1文字ずつ見比べ(航空券・ESTA など)',
|
|
2204
|
+
description:
|
|
2205
|
+
'パスポートに印字された姓・名(surname・given)と、書類(航空券・ESTA・マイレージ・ホテル・マイナンバーカードなど)のつづりを最大6つ受け取り、1文字ずつ並べて書類ごとに一致(match)か違いあり(diff)かを返す(tools.first-ch.com/romaji/ と同一ロジック)。' +
|
|
2206
|
+
'書類のつづりは「姓 名」か「姓/名」(区切りの前を姓とみなす)。大文字小文字・全角半角は同じとみなし、前後の敬称(MR・MS など)は外して title として返す。' +
|
|
2207
|
+
'違いの kind は swap(姓と名の入れ替え)・sep(空白・ハイフン)・ou(OとU。O の後ろの U・O と O⇄U)・nm(B・M・P の前の N と M)・lookalike(0とO・1とI など)・drop(欠落)・add(追加)・sub(違う字)・title(敬称)・extra_word(ミドルネーム欄などの余分な語)・nonlatin(ローマ字以外の文字)。位置は part(surname / given / between)と position(何文字目)・after(その字の後ろ)。' +
|
|
2208
|
+
'status は have(手元にある・既定)/ unknown(取ったが表記不明・紛失=照合せず基準未確認)/ never(取ったことがない=対象外)。review=true(別名併記・改姓)なら全行を review(要確認)にする。' +
|
|
2209
|
+
'仮名からのローマ字生成・長音の判定・非ヘボン表記の可否・航空会社ごとの訂正の可否・搭乗や申請の可否は返さない。完全ローカル処理・ネットワーク送信なし。',
|
|
2210
|
+
inputSchema: {
|
|
2211
|
+
surname: z.string().optional().describe('パスポートに印字された姓(ローマ字)'),
|
|
2212
|
+
given: z.string().optional().describe('パスポートに印字された名(ローマ字)'),
|
|
2213
|
+
documents: z
|
|
2214
|
+
.array(z.union([z.string(), z.object({ label: z.string().optional(), text: z.string() })]))
|
|
2215
|
+
.max(6)
|
|
2216
|
+
.optional()
|
|
2217
|
+
.describe('比べる書類(最大6つ)。{ label: "航空券", text: "SATO/HANAKO MS" } か、つづりの文字列'),
|
|
2218
|
+
status: z.enum(['have', 'unknown', 'never']).optional().describe("パスポートの状態(既定 'have')"),
|
|
2219
|
+
review: z.boolean().optional().describe('別名併記がある・取った後に姓が変わったなら true(全行を要確認にする)'),
|
|
2220
|
+
lang: z.enum(['ja', 'en']).optional().describe("label・text・notes の言語(既定 'ja')"),
|
|
2221
|
+
},
|
|
2222
|
+
},
|
|
2223
|
+
async (opts) => {
|
|
2224
|
+
await logUsage('romaji_name_check');
|
|
2225
|
+
return asText(romajiNameTool(opts));
|
|
2226
|
+
},
|
|
2227
|
+
);
|
|
2228
|
+
|
|
2199
2229
|
serveStdio(buildServer);
|