MCPcopy Index your code
hub / github.com/chrisryugj/korean-law-mcp

github.com/chrisryugj/korean-law-mcp @v4.6.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.6.6 ↗ · + Follow
786 symbols 2,236 edges 128 files 85 documented · 11% updated 1d ago★ 2,1571 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Korean Law MCP

42 APIs compressed into 9 tools. Search, retrieve, and analyze Korean law — statutes, precedents, ordinances, treaties + LLM hallucination guard for legal citations (existence + content) + precedent citator (cite_check) + point-in-time law resolution (applicable_law).

npm version MCP 1.27 License: MIT TypeScript

조코헌트 주간 1등 Top 1 위너

MCP server + CLI for Korea's official legal database (법제처 Open API). Works with Claude Desktop, Cursor, Windsurf, Zed, and any MCP-compatible client.

한국어

Korean Law MCP demo


v4.6.0 — Citation verification goes deeper (content) + cloud anti-bot

  • verify_citations content check: Beyond confirming an article exists, it now catches content hallucinations like 민법 제750조(계약해제) — a real article (§750) tagged with the wrong title. It compares the cited article title against the actual one ([CONTENT_MISMATCH]) using LexDiff's citation-content-matcher (normalized common substring + character bigram Jaccard). Same for legal_analysis(mode=verify_citations).
  • law.go.kr JS anti-bot bypass: When 법제처 serves a location.assign JS redirect instead of API data to cloud IPs (GCP/AWS/Fly), the client parses the obfuscated URL and follows the tokenized redirect (up to 3 hops, retrying the original URL on a 404). No-op on local/registered IPs — a defense layer for cloud deployments where Referer injection (v4.0.9) isn't enough.

v4.5.0 — Upcoming-law detection (prevents "renamed law not found" errors)

search_law runs a supplementary target=eflaw (enforcement-date) search and annotates results.

  • Pending rename: e.g. 「데이터기반행정 활성화에 관한 법률」 → 「인공지능 및 데이터 기반 행정 활성화에 관한 법률」 (effective 2026-08-28). Maps old ↔ new titles so searching the new name doesn't return only "no exact match" and mislead the LLM into "the law doesn't exist."
  • Pending amendment: when a current law has an amendment awaiting enforcement, surfaces its enforcement date, promulgation number, and pending-version MST.
  • Not-yet-in-force new law: separately flags promulgated-but-not-yet-effective laws that return 0 hits in a current search (with a no-legal-effect warning).

v4.4.1–4.4.3 — Stability patches

  • v4.4.3: Pin zod to ^4 — fixes a crash where a fresh install resolving zod 3.x threw z.toJSONSchema is not a function on the first listTools call.
  • v4.4.2: Restore get_annexes for administrative-rule tables/forms — parse the admrulbyl key first, auto-detect "...시행세칙", and split table/form collisions that share a bylSeq (#50/#49/#51).
  • v4.4.1: Fix advertised-schema required bug — .default() fields (legal_research.task, search_law.display) were exposed as required inputs (fixed via io:"input"); pass through legal_analysis cost options; warn on incompatible scenarios.

v4.4.0 — Exposed tools consolidated 19 → 9 (52% context reduction)

Shrinks the ListTools payload every MCP client reads per session from ~15.1KB to ~7.2KB.

  • 8 chain_* tools → one legal_research (task param: full_research·law_system·action_basis·dispute_prep·amendment_track·ordinance_compare·procedure_detail·document_review)
  • 4 killer features (verify_citations·cite_check·applicable_law·impact_map) → one legal_analysis (mode param)
  • Backward compatible: direct tool-name calls and execute_tool routing both still work; only the advertised list changes.

What's New in v4.3 — Precedent Citator + Point-in-Time Law

cite_check — "Is this precedent still good law?" (Korean Shepard's)

Give it a case number (e.g. 2007다27670). It back-traces every later decision citing that case via full-text search, deep-scans en banc decisions for overruling language ("…변경하기로 한다"), and tracks alias references like "(이하 '2008년 전원합의체 판결'이라 한다)". Verdict: ✅ still cited / ⚠️ en banc successor exists / ❌ overruling detected — with the exact holding context.

applicable_law — "Which version of the law applies to my case date?"

Give it a statute + a date. It pins the version in force on that date (MST), fetches the article as it read then, diffs against the current text, and extracts transitional provisions (적용례·경과조치) from every later amendment's addenda — plus lex temporis guidance (Criminal Act §1, General Act on Public Administration §14).


v3.5 — Citation Hallucination Guard

Catches fake article citations in AI-generated legal answers in real time. Cross-verifies every citation against Korea's official law database.

"Under Civil Act Article 750, damages may be claimed for tort;
 Labor Standards Act Article 60 Paragraph 1 provides annual leave;
 Commercial Act Article 401-2 Paragraph 7 imposes director liability;
 Criminal Act Article 9999 imposes aggravated punishment."

→ Run verify_citations (actual verification result against 법제처 API):

  • ✓ Civil Act Article 750 (Tort liability) — exists
  • ✓ Labor Standards Act Article 60 (Annual paid leave) Paragraph 1 — exists
  • Commercial Act Article 401-2 — Paragraph 7 doesn't exist (max Paragraph 2)
  • Criminal Act Article 9999 — no such article (valid range: Art.1~Art.372)

Don't blindly trust ChatGPT/Claude legal answers. Essential reliability check for legal AI services, law firms, students, contract review.


What's New in v3.2.0+ — Smart Scenarios

Same 14 tools, 7 new analysis scenarios. Just ask in natural language — the AI detects what you need and runs extra analysis automatically.

Ask this Get this
"Food Sanitation Act penalty reduction possible?" Penalty schedule + violation clauses + appeal cases where penalties were reduced
"Import customs FTA check" Customs Act + customs interpretations + FTA treaties + tariff tables + tax tribunal rulings
"Building Act permit procedure" Legal basis (Act→Decree→Rule) + fees/forms + admin rules + local ordinance exceptions
"National Health Insurance Act delegation" Finds delegated provisions where implementing decrees haven't been created yet
"Building Act impact analysis" Subordinate laws + nationwide ordinances affected + related admin rules
"Labor Standards Act amendment timeline" Old/new comparison + article history + precedents/interpretations mapped chronologically
"Parking ordinance compliance check" Constitutional Court decisions + admin appeal cancellations + parent law basis

No changes to how you use it. Ask naturally, get deeper analysis automatically.

v3.3.0~v3.3.1 changes

v3.3.1 — Law alias dictionary expansion (11 → 52 entries, +41)

Triggered by a lexdiff hallucination case where "산안기준규칙" (산업안전보건기준에 관한 규칙) got keyword-matched to "국가표준기본법" by Korea Law Open API's aiSearch. Expanded LAW_ALIAS_ENTRIES in lib/search-normalizer.ts with high-frequency abbreviations across labor/safety (산안법, 중처법, 근기법), privacy/telecom (개보법, 정보통신망법), anti-corruption (청탁금지법, 이해충돌방지법), public contracting (국가계약법, 지방계약법), real estate (주임법, 상임법, 부거법), antitrust (공정거래법, 하도급법, 약관법, 표시광고법, 가맹사업법), finance (자본시장법, 특금법, 전금법), urban planning (국토계획법, 도정법), environment/health (감염병예방법, 대기환경법), transport (여객운수법, 화물운수법), procedure (민소법, 형소법, 민집법), social insurance (국건법, 산재보험법, 고보법), and telecom (전기통신사업법). Since api-client.ts and law-parser.ts already consume resolveLawAlias(), the existing search pipeline gets the benefit automatically. 45/45 tests passing (41 new + 4 regression).

v3.3.0 — HTTP stateless mode + kordoc 2.3.0

Root-cause fix for the remote server (korean-law-mcp.fly.dev) periodically losing sessions due to OOM-driven restarts. Switched to MCP's official stateless pattern (sessionIdGenerator: undefined): fresh Server + Transport per request, released on response close. Removed in-memory session Map, InMemoryEventStore, and idle cleanup — eliminating leak sources entirely. Survives restarts, scale-out, and rolling deploys with zero client disruption. GET /mcp and DELETE /mcp return 405 (matching the SDK example). API keys are isolated per-request via AsyncLocalStorage.

  • HTTP stateless transitionsrc/server/http-server.ts (ref: @modelcontextprotocol/sdk/examples/server/simpleStatelessStreamableHttp.js)
  • kordoc 2.2.5 → 2.3.0
  • Session management code removedsessions Map, MAX_SESSIONS, 10-min idle setInterval, InMemoryEventStore, POST/GET/DELETE branching (~50 LOC net reduction)

v3.2.2get_annexes direct exposure. Auto-fetch annexes on refund/fee keywords.

v3.2.1 — kordoc 2.2.5 update.

v3.1.0~v3.1.5 changes

v3.1.5 — kordoc 2.2.4 + README modernization.

v3.1.4 — kordoc 2.2.4 update. HTML <table> for merged cells, markdownToHwpx improvements.

v3.1.3 — Empty search result hints for 18 tools. Session cleanup interval reduced.

v3.1.2 — kordoc 2.2.1 update. GFM table escaping.

v3.1.1 — kordoc 2.1→2.2 update.

v3.1.0 — Production hardening: 20 file fixes.

v3.1.3 — Empty search result hints for 18 tools. Session cleanup interval reduced (30min→10min).

v3.1.2 — kordoc 2.2.1 update. GFM table special character escaping and pipe collision prevention.

v3.1.1 — kordoc 2.1→2.2 update.

v3.1.0 — Production hardening: 20 file fixes. truncateResponse 50KB limit applied to 17 tools, HTTP session limit (MAX_SESSIONS=100), CORS wildcard warning, parameter pollution defense, chain tool auth error propagation, SSE server dead code removal.

v3.0.x changes

v2 structured 41 legal APIs into 89 MCP tools. v3 re-compresses them into 14 tools.

Raw APIs v2 v3
Tool count 41 89 14
AI context cost - ~110 KB ~20 KB
Coverage - 100% 100%
Profile management - lite/full split Single (none needed)

What changed: 34 individual search/get tools for precedents, constitutional court, tax tribunal, FTC, etc. are now unified into 2 tools: search_decisions(domain) + get_decision_text(domain), covering 17 domains with a single domain parameter.

  • kordoc 1.6 → 2.2.5 — Document parsing engine upgrade (XLSX/DOCX support, security hardening, form filler)
  • Bug fixes — Admin appeal text retrieval, English law text retrieval

v2.2.0

  • 23 New Tools (64 → 87) — Treaties, law-ordinance linkage, institutional rules, special administrative appeals, document analysis, and more.
  • Document Analysis Engine — 8 document types, 17 risk rules, amount/period extraction, clause conflict detection.
  • Law-Ordinance Linkage (4 tools) — Trace delegation chains between national laws and local ordinances.
  • Treaty Support (2 tools) — Bilateral/multilateral treaty search and retrieval.
  • Security Hardening — CORS origin control, API key header-only, security headers, session ID masking.

v1.8.0 – v1.9.0 features

  • 8 Chain Tools — Composite research workflows in a single call: chain_full_research (AI search → statutes → precedents → interpretations), chain_law_system, chain_action_basis, chain_dispute_prep, chain_amendment_track, chain_ordinance_compare, chain_procedure_detail.
  • Batch Article Retrievalget_batch_articles accepts a laws array for multi-law queries in one call.
  • AI Search Type Filtersearch_ai_law now supports lawTypes filter.
  • Structured Error Format[ErrorCode] + tool name + suggestion across all 64 tools.
  • HWP Table Fix — Legacy HWP parser now extracts tables from paragraph.controls[].content path.

Why this exists

South Korea has 1,600+ active laws, 10,000+ administrative rules, and a precedent system spanning Supreme Court, Constitutional Court, tax tribunals, and customs rulings. All of this lives behind a clunky government API with zero developer experience.

This project wraps that entire legal system into 14 structured tools that any AI assistant or script can call. Built by a Korean civil servant who got tired of manually searching 법제처 for the hundredth time.


Quick Start

Option 1: MCP Server (Claude Desktop / Cursor / Windsurf)

Auto setup (recommended):

npx korean-law-mcp setup

Interactive wizard handles API key input, client selection, and config file registration. Supports Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, and Gemini CLI.

Manual setup:

npm install -g korean-law-mcp

Add to your MCP client config:

{
  "mcpServers": {
    "korean-law": {
      "command": "korean-law-mcp",
      "env": {
        "LAW_OC": "your-api-key"
      }
    }
  }
}

Get your free API key at 법제처 Open API.

Client Config File
Claude Desktop %APPDATA%\Claude\claude_desktop_config.json (Win) / ~/Library/Application Support/Claude/claude_desktop_config.json (Mac)
Cursor .cursor/mcp.json
Windsurf .windsurf/mcp.json
Continue ~/.continue/config.json
Zed ~/.config/zed/settings.json

Option 2: Remote (No Install)

Claude Desktop does not support remote HTTP MCP servers directly. Use the mcp-remote adapter (requires [Node.js](h

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 655
Interface 95
Method 30
Class 6

Languages

TypeScript100%

Modules by API surface

src/tools/compact-query-planner.ts34 symbols
test/test-chain-full-research-precedent-retry.cjs31 symbols
src/tools/chains.ts28 symbols
test/test-compact-query-planner.cjs23 symbols
src/tools/precedents.ts23 symbols
src/lib/api-client.ts21 symbols
src/tools/precedent-search-core.ts19 symbols
test/test-precedent-html-fallback.cjs18 symbols
src/tools/annex.ts18 symbols
src/lib/xml-parser.ts18 symbols
src/setup.ts16 symbols
src/tools/precedent-evidence.ts15 symbols

For agents

$ claude mcp add korean-law-mcp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page