jp-ocr-date-fix
This server repairs Japanese dates broken by OCR and verifies that each repaired date actually exists within its era.
Fix dates in OCR text (
jp_ocr_fix_dates): takes Japanese OCR text and repairs look-alike character errors (e.g.今和6年3月15曰→令和6年3月15日,2O24年l月5日), returning the repaired text, a list of changes (start/end, before/after, ISO date), and flags for date-like spans it could not confirm.Check a single date (
jp_ocr_check_date): returnsstatusofok,fixed(with repaireddate/iso),invalid(date doesn't exist or falls outside its era, e.g.平成31年5月1日), ornot_a_date— it never guesses.Era-aware validation: supports 明治, 大正, 昭和, 平成, 令和; only applies a fix when the calendar confirms the date lies inside the era.
Read-only and deterministic: no network access, safe to call repeatedly, intended to run before extracting dates from scanned invoices, forms, or PDFs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@jp-ocr-date-fix Fix the broken Japanese dates in this OCR text: 今和6年3月15曰, 平戒31年4月30日"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
JP OCR Date Fix
Repair Japanese dates that OCR broke (今和6年3月15曰 → 令和6年3月15日), and only when the calendar confirms the result.
OCR often misreads the era name 令和 as 今和 or 合和, 日 as 曰, and 0/1 as O/l. One public test of a document parser on Japanese PDFs found the 令→今 error on roughly all OCR-processed pages (source). An AI that reads that text then extracts a date that does not exist, or guesses.
This tool fixes those spans with fixed rules and checks each result:
the span must have a full date shape: era + year + 年 + month + 月 (+ day + 日), or YYYY年M月(D日)
characters are mapped through a fixed look-alike table (
今合命冷→令,戒威→成,照→昭,曰目→日,O→0,l|→1, …)the repaired date must exist and fall inside its era (平成31年4月30日 is valid, 平成31年5月1日 is not)
if it cannot be confirmed, the text is left as it is and the span is returned in
flags
Python standard library only. No network. MIT.
Use
python -m jpocrdate scan.txt # repaired text to stdout, changes to stderr
python -m jpocrdate scan.txt --json # {"text", "changes", "flags"}from jpocrdate import fix_text, check_date
check_date("平戒31年4月30日")
# {'input': '平戒31年4月30日', 'status': 'fixed', 'date': '平成31年4月30日', 'iso': '2019-04-30'}
check_date("平成31年5月1日")
# {'input': '平成31年5月1日', 'status': 'invalid', 'reason': 'date is outside 平成'}As an MCP server (for AI agents)
{"mcpServers": {"jp-ocr-date-fix": {"command": "python", "args": ["-m", "jpocrdate.server"], "cwd": "/path/to/jp-ocr-date-fix"}}}Tools (read-only):
Tool | Input | Returns |
|
| repaired |
|
|
|
MCP protocol: the stdio server speaks both the classic initialize flow (2025-06-18 and earlier) and the stateless 2026-07-28 revision (server/discover, per-request _meta). Tested in tests/test_mcp_2026.py.
MCP の新しい版(2026-07-28・server/discover)と従来の initialize の両方で動きます。
Related MCP server: Torify — Japanese Locale APIs for AI Agents
Scope and limits
Eras: 明治, 大正, 昭和, 平成, 令和. Abbreviations such as
R6.3.15orH31/4/30are not handled yetOnly dates are repaired. Company names and amounts are out of scope (see JaPOC for company-name correction)
The look-alike table is hand-made from common OCR confusions. It is not learned from data, and it will miss some errors
Tests:
python -m unittest discover -s tests(18 tests)
日本語
OCRで崩れた日本の日付(今和6年3月15曰 など)を、決まったルールで直します。直した結果が暦に実在し、元号の期間内にあるときだけ直します。確かめられないものは直さずに flags で知らせます(推測しません)。
対応: 明治・大正・昭和・平成・令和、元年、全角数字、年月だけの日付
外部通信なし・Python標準ライブラリのみ・MIT
AIエージェントからは MCP サーバー(
python -m jpocrdate.server)として使えます
Available Tools
2 toolsjp_ocr_check_dateCheck one Japanese dateARead-onlyIdempotent
Check one date string. status: ok (already correct), fixed (OCR look-alikes repaired; see date/iso), invalid (the date does not exist, e.g. 平成31年5月1日; nothing is guessed), not_a_date.
Inputs: date (required).
jp_ocr_fix_datesRepair Japanese dates in OCR textARead-onlyIdempotent
Find Japanese dates in OCR output (e.g. '今和6年3月15曰', '2O24年l月5日') and repair OCR look-alike characters. A fix is applied only when the repaired date exists on the calendar and inside the era (令和/平成/昭和/大正/明治). Returns the repaired text, every change with its ISO date, and flags for spans that look like dates but cannot be confirmed. Use it before extracting dates from scanned Japanese invoices, forms or PDFs. OCRで崩れた和暦・日付を暦で確かめて直す。
Inputs: text (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools have related but distinguishable purposes: jp_ocr_fix_dates repairs dates in bulk text, while jp_ocr_check_date validates a single date string. There is some conceptual overlap because checking is a subset of fixing, but the descriptions make the batch-vs-single distinction fairly clear.
Both tools follow the same predictable pattern: a shared jp_ocr_ prefix followed by a verb_noun phrase (fix_dates, check_date). The convention is consistent and readable.
Two tools is a small surface, but the server has a narrow, well-defined purpose: repairing and checking Japanese OCR dates. The pair covers bulk and single-date use cases without obvious bloat, though it is on the thin side.
The surface covers the core workflow of finding/repairing dates and validating individual date strings, including edge cases like nonexistent calendar dates. Minor gaps exist, such as no dedicated pure-extraction or era-conversion tool, but these are not serious for the stated scope.
Maintenance
Related MCP Connectors
Japanese business days, holiday checks and invoice due dates for your AI agent.
Japan data tools for AI agents: calendar (rokuyo), address, name splitting, corporate number lookup
Deterministic calendars and cosmic date JSON for AI agents via MCP (Gregorian 1900-2100).
Normalize and verify Japanese postal addresses into structured fields for agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceJapan-specific utilities for AI agents — era ↔ Western year conversion, kanji-to-romaji, postal code lookup, national holidays, kana conversion, and Japanese name splitting. 9 tools, MIT licensed, install via uvx.929 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceTorify gives AI agents the Japanese locale primitives that standard libraries lack — imperial era date conversion (wareki), qualified invoice number validation with NTA registry lookup, corporate number lookup (法人番号), postal code resolution, name romanization (Hepburn), and kanji-to-kana conversion via Yahoo! JLP. 31 endpoints total. No authentication required for MCP. Pay-per-call $0.02/call viaMIT
- AlicenseAqualityDmaintenanceEnables AI assistants to perform Japanese business calendar calculations including holiday detection, business day arithmetic, payment date settlement, and deadline management using local data.6MIT
- AlicenseAqualityDmaintenanceMCP server for Japanese business days, public holidays, wareki dates, and tax arithmetic, helping AI agents avoid common Japanese date and tax errors.7MIT