@first-ch/tools-mcp 0.30.0 → 0.32.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 +10 -2
- package/html-md.mjs +1226 -0
- package/package.json +17 -3
- package/server.mjs +87 -0
- package/wareki.mjs +669 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @first-ch/tools-mcp
|
|
2
2
|
|
|
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,
|
|
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, and Japanese era ⇄ Western date conversion with age calculation — to AI agents such as Claude Code.
|
|
4
4
|
|
|
5
5
|
日本語版は [後半セクション](#日本語) を参照してください。
|
|
6
6
|
|
|
@@ -78,6 +78,10 @@ This server is also registered in the [MCP Registry](https://registry.modelconte
|
|
|
78
78
|
|
|
79
79
|
| `date_calc` | Counts the days and business days between two dates, works out the due date N days or N business days from a start date, and turns a closing day plus payment terms into a payment date — the same logic as the browser tool at tools.first-ch.com/date-calc/. For delivery dates, acceptance deadlines and payment schedules. **A business day is any day that is not a weekend, a Japanese public holiday or a closure you list**; the holiday table shipped with the package is the one published by Japan's Cabinet Office (1970–2027), so the "Happy Monday" holidays that move each year, substitute holidays after a Sunday holiday, citizens' holidays squeezed between two holidays (2026-09-22) and the shifting equinox days are all counted. `mode="between"` returns calendar days, business days, the breakdown of days off and every holiday in the range. `mode="add"` moves `n` (negative counts backwards) units from `base` and also lists the days it skipped; **"within 10 business days of receipt" differs by one depending on whether day zero counts**, so counting starts the day after by default (the Japanese civil-code rule) and `include_start=true` makes the start date day 1. `mode="payment"` resolves `invoice` + `closing` + `pay_months` + `pay_day`, moving a payment that lands on a day off by `pay_adjust` (default `prev`, the usual Japanese practice). The weekend, the New Year break, your own closures and your working weekends can all be set. Dates are held as days since 1970-01-01, so the server's time zone cannot shift the answer | `mode?` (`between` / `add` / `payment`), `start?`, `end?`, `base?`, `n?`, `unit?` (`business` default / `days` / `weeks` / `months` / `years`), `include_start?`, `adjust?`, `invoice?`, `closing?` (`eom` default / 1-31 / `none`), `pay_months?`, `pay_day?`, `pay_adjust?`, `weekend?`, `holidays?`, `year_end?`, `closed_dates?`, `work_dates?`, `lang?` |
|
|
80
80
|
|
|
81
|
+
| `html_to_markdown` | Converts an HTML fragment into Markdown — the same logic as the browser tool at tools.first-ch.com/html-md/. For turning a fetched page into something an LLM can read cheaply, and for moving existing web copy into Markdown. Headings (h1-h6), paragraphs, line breaks, emphasis, strikethrough, lists (nested, the `start` attribute, checkboxes), tables (thead / caption, with column alignment taken from `align` and `text-align`), links, images, code blocks (the language comes from `class="language-*"`), block quotes, horizontal rules, definition lists, figure / figcaption and details / summary are all handled, while `script`, `style`, anything marked `hidden` or `display:none` and presentational `div` / `span` wrappers are removed. **The HTML is not parsed with the browser DOM**: the tokeniser and tree builder are written by hand, so this server and the web page agree exactly, and unclosed elements are closed at the end while stray closing tags are dropped — the counts always come back in `notes`. **An attribute quote that is never closed stops the tag there**, because carrying on would swallow the rest of the document as one attribute value. **Whatever Markdown cannot express is reported rather than dropped in silence**: merged cells (a `colspan` is padded with empty cells, a `rowspan` keeps its value on the first row only), a cell holding a list or a code block (that table is left as HTML), definition lists (written in the Markdown Extra `: ` form) and `sup` / `sub` / `mark` / `iframe` / `svg` (`unknown` chooses between keeping them as HTML, reducing them to text and removing them). Tables, task lists and strikethrough are GFM extensions, so `gfm=false` switches them off. `base_url` rewrites relative links and images as absolute URLs — the thing that breaks most often in a migration — and `main_only` keeps only `main` / `article`, dropping `header`, `nav`, `footer`, `aside` and `form`. It never touches the network; fetching the page is the caller's job | `html?` or `path?`, `outputPath?`, `main_only?`, `base_url?`, `gfm?`, `escape?`, `pad_tables?`, `headings?` (`atx` default / `setext`), `bullet?` (`-` / `*` / `+`), `code_block?` (`fenced` / `indented`), `links?` (`inline` / `reference` / `strip`), `images?` (`keep` / `alt` / `drop`), `tables?` (`gfm` / `html`), `unknown?` (`keep` / `text` / `drop`), `br?` (`spaces` / `backslash` / `html` / `space`), `lang?` (`ja` default / `en`) |
|
|
82
|
+
|
|
83
|
+
| `wareki_convert` | Converts Japanese era dates (Reiwa, Heisei, Showa, Taisho, Meiji) and Western dates both ways and returns the weekday and zodiac — the same logic as the browser tool at tools.first-ch.com/wareki/. For converting and checking the dates in contracts, invoices and official forms. `mode="convert"` takes `date` or `dates` (up to 1000) and **detects which calendar each one is in**: `2026-10-01`, `2026/10/1`, `20261001`, `2026年10月1日`, `令和8年10月1日`, `R8.10.1`, `令和八年十月一日`, `㋿8.10.1`, `Reiwa 8` and so on. A year alone (`1989`, `昭和64年`) or a year and month (`2019-05`) also works, and both eras are returned when the period spans an era change. `formats` gives the era date (gannen, with weekday, in kanji numerals), the short forms (`R8.10.1` / `R08.10.01`), Western, ISO 8601 and English. Eras begin on 1912-07-30 (Taisho), 1926-12-25 (Showa), 1989-01-08 (Heisei) and 2019-05-01 (Reiwa). **Era dates that never existed (Heisei 32, Heisei 31 May 1, Reiwa 1 April 30) are still converted, and `notes` gives the correct era date**; a written weekday that does not match comes back as `WEEKDAY_MISMATCH`. **Before 1873 (Meiji 5 and earlier) only the year is converted**, because dates were lunisolar (`LUNAR_CALENDAR`). `mode="age"` takes `birth` (era dates accepted) and `reference` (today in Japan time if omitted) and returns the exact age (it goes up on the birthday; people born on February 29 turn older on March 1 in common years), years/months/days, the kazoe age, the next birthday and the entry and graduation years from elementary school to university. `mode="eras"` returns the era list, plus a year chart of era, zodiac and age when `from_year` / `to_year` are given (up to 500 years). Badly written dates come back as `ok: false` with `error.code` | `mode?` (`convert` / `age` / `eras`), `date?`, `dates?`, `birth?`, `reference?`, `from_year?`, `to_year?`, `lang?` (`ja` default / `en`) |
|
|
84
|
+
|
|
81
85
|
See [`server.mjs`](./server.mjs) for the exact Zod input schemas.
|
|
82
86
|
|
|
83
87
|
**PDF output (`marp_render`) needs a local Chrome/Chromium.** marp-core renders the HTML with no browser dependency (so the package stays light for `npx`); PDF is produced by driving a locally-installed Chrome/Chromium in headless mode. It is auto-detected on common paths, or set `MARP_CHROME_PATH` to the executable. If none is found, `marp_render` returns the HTML only and reports `pdf_skipped` — you can still open that HTML and print → PDF yourself (one slide per page).
|
|
@@ -121,7 +125,7 @@ Release rule: a push to `main` automatically publishes a new package version thr
|
|
|
121
125
|
|
|
122
126
|
## 日本語
|
|
123
127
|
|
|
124
|
-
`@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
|
|
128
|
+
`@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の変換・和暦⇄西暦の変換と満年齢の計算 — をAIエージェント(Claude Code等)向けMCPツールとして提供するサーバーです。
|
|
125
129
|
|
|
126
130
|
### インストール
|
|
127
131
|
|
|
@@ -197,6 +201,10 @@ claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
|
|
|
197
201
|
|
|
198
202
|
| `date_calc` | 2つの日付の間の日数・営業日数、起点日から N日後/N営業日後の期日、締め日と支払サイトからの支払日を計算する。tools.first-ch.com/date-calc/ と同一ロジック。納期・検収期限・支払サイトの確認のための道具。**営業日は「土日・日本の祝日・指定した休業日を除いた日」**で、祝日は内閣府「国民の祝日について」の一覧をパッケージに同梱している(1970年〜2027年)ため、ハッピーマンデーで動く祝日・日曜と重なったときの振替休日・前後を祝日に挟まれた国民の休日(2026-09-22)・年によって変わる春分の日/秋分の日がすべて計算に入る。`mode="between"` は暦日数・営業日数・休みの内訳・期間内の祝日一覧を返す。`mode="add"` は `base` から `n`(負なら過去へ)を `unit` の単位で進めた期日と、飛ばした休みの一覧を返す。**「受領後10営業日」は初日を数えるかで1日ずれる**ので、民法の原則どおり翌日起算を既定とし、`include_start=true` で起点日を1日目として数える。`mode="payment"` は `invoice`・`closing`・`pay_months`・`pay_day` から支払日を求め、休みに当たったら `pay_adjust`(既定 `prev`=前営業日へ繰り上げ・日本の商慣習)で寄せる。週の休み・年末年始・自社の休業日・休日出勤も指定できる。日付は「1970-01-01からの通算日」の整数で扱うのでサーバーのタイムゾーンで1日ずれない | `mode?`(`between` / `add` / `payment`)、`start?`、`end?`、`base?`、`n?`、`unit?`(既定 `business` / `days` / `weeks` / `months` / `years`)、`include_start?`、`adjust?`、`invoice?`、`closing?`(既定 `eom` / 1〜31 / `none`)、`pay_months?`、`pay_day?`、`pay_adjust?`、`weekend?`、`holidays?`、`year_end?`、`closed_dates?`、`work_dates?`、`lang?` |
|
|
199
203
|
|
|
204
|
+
| `html_to_markdown` | HTML断片をMarkdownへ変換する。tools.first-ch.com/html-md/ と同一ロジック。取得したページの本文をLLMへ渡す前の後処理、既存サイトの原稿をMarkdown管理へ移す移行作業のための道具。見出し(h1〜h6)・段落・改行・強調・取り消し線・リスト(入れ子・`start` 属性・チェックボックス)・表(thead / caption と `align`・`text-align` による列の配置)・リンク・画像・コードブロック(`class="language-*"` から言語を拾う)・引用・水平線・定義リスト・figure / figcaption・details / summary に対応し、`script`・`style`・`hidden` や `display:none` の要素・装飾のための `div` / `span` は自動で取り除く。**HTMLの解釈にブラウザのDOMを使っていない**——字句解析も木の組み立ても自前なのでWeb版と結果が一致し、閉じ忘れたタグは末尾で閉じ、行き場のない閉じタグは捨てて変換を続ける(補った件数は必ず `notes` で返す)。**属性の引用符が閉じていない場合だけは打ち切る**——続けると残りの文書全体を1つの属性値として飲み込むため。**Markdownに書けないものは黙って捨てず報告する**: セルの結合(`colspan` は空セルで埋め、`rowspan` は先頭行にだけ値が入る)・セル内のリスト/コードブロック(その表だけHTMLのまま残す)・定義リスト(Markdown Extra の `: ` 記法)・`sup` / `sub` / `mark` / `iframe` / `svg`(`unknown` で「HTMLのまま残す/文字だけ残す/取り除く」を選ぶ)。表・タスクリスト・取り消し線はGFMの拡張なので `gfm=false` で切れる。`base_url` を渡すと相対URLのリンクと画像を絶対URLへ直し(移行でいちばん壊れるところ)、`main_only=true` は `main` / `article` の中だけを取り出して `header`・`nav`・`footer`・`aside`・`form` を落とす。ネットワークへは出ない(ページの取得は呼び出し側の仕事) | `html?` または `path?`、`outputPath?`、`main_only?`、`base_url?`、`gfm?`、`escape?`、`pad_tables?`、`headings?`(既定 `atx` / `setext`)、`bullet?`(`-` / `*` / `+`)、`code_block?`(`fenced` / `indented`)、`links?`(`inline` / `reference` / `strip`)、`images?`(`keep` / `alt` / `drop`)、`tables?`(`gfm` / `html`)、`unknown?`(`keep` / `text` / `drop`)、`br?`(`spaces` / `backslash` / `html` / `space`)、`lang?`(既定 `ja` / `en`) |
|
|
205
|
+
|
|
206
|
+
| `wareki_convert` | 和暦(令和・平成・昭和・大正・明治)と西暦を相互に変換し、曜日と干支を返す。tools.first-ch.com/wareki/ と同一ロジック。契約書・請求書・行政書類の日付の変換と検算のための道具。`mode="convert"` は `date` か `dates`(1000件まで)を受け、**西暦か和暦かを自動で見分ける**(`2026-10-01`・`2026/10/1`・`20261001`・`2026年10月1日`・`令和8年10月1日`・`R8.10.1`・`令和八年十月一日`・`㋿8.10.1`・`Reiwa 8` など)。年だけ(`1989`・`昭和64年`)・年月だけ(`2019-05`)も変換でき、改元をまたぐときは両方の元号を返す。`formats` に和暦(元年表記・曜日つき・漢数字)・略記(`R8.10.1`/`R08.10.01`)・西暦・ISO 8601・英語を返す。**存在しない和暦(平成32年・平成31年5月1日・令和元年4月30日)も西暦へ直したうえで正しい和暦を `notes` で指摘**し、書き添えの曜日が実際と違えば `WEEKDAY_MISMATCH` を返す。**明治5年(1872年)以前は旧暦のため年単位でだけ換算する**(`LUNAR_CALENDAR`)。`mode="age"` は `birth`(和暦可)と `reference`(省略時は日本時間の今日)から満年齢(誕生日に1つ増え、2月29日生まれは平年だと3月1日)・年月日の内訳・数え年・次の誕生日と、小学校〜大学の入学・卒業の年を返す。`mode="eras"` は元号一覧を返し、`from_year` / `to_year` を渡すと和暦・干支・満年齢の早見表も返す(500年分まで)。日付の書き方の誤りは `ok: false` と `error.code` で返す | `mode?`(`convert` / `age` / `eras`)、`date?`、`dates?`、`birth?`、`reference?`、`from_year?`、`to_year?`、`lang?`(既定 `ja` / `en`) |
|
|
207
|
+
|
|
200
208
|
正確な入力スキーマ(Zod定義)は [`server.mjs`](./server.mjs) を参照してください。
|
|
201
209
|
|
|
202
210
|
**`marp_render` のPDF出力にはローカルの Chrome/Chromium が必要です。** marp-core によるHTML生成はブラウザ非依存(`npx` 導入を軽く保つため)で、PDFはローカルインストール済みの Chrome/Chromium を headless で駆動して生成します。定番パスから自動検出し、`MARP_CHROME_PATH` で実行ファイルを明示することもできます。見つからない場合は HTML のみを返し `pdf_skipped` を報告します(そのHTMLを開いて印刷→PDF保存でも1スライド=1ページで作成できます)。
|