Korean Law MCP

repository·main·Indexed 25 days ago

https://github.com/chrisryugj/korean-law-mcp

An MCP server providing AI assistants with high-fidelity access to South Korean legal databases, including laws, precedents, and ordinances. Version 4.9.1 consolidates 42 Ministry of Government Legislation APIs into 9 tools, featuring legal research, citation verification to prevent hallucinations, time-travel version comparison, and impact mapping. It supports integration with Claude Desktop, ChatGPT, Cursor, Windsurf, and Zed, and includes specialized tools like ordinance_radar for local government compliance and action_plan for structured legal guidance.

Tokens
26.3K
Snippets
43
Records
151
Agent score
82%

What's inside korean-law-mcp

  1. Overview of Korean Law MCP Tools

    main

    Korean Law MCP provides 29 specialized tools for interacting with Korean legal data, including statutes, precedents, administrative rules, and local ordinances. The tools are categorized into several functional areas:

    • Statute Management: Searching laws (search_law), retrieving text (get_law_text), comparing old/new versions (compare_old_new), and 3-tier comparisons (get_three_tier).
    • Article Analysis: Comparing specific articles (compare_articles), tracking article history (get_article_history), and parsing internal article links (parse_article_links).
    • Precedent & Interpretation: Searching precedents (search_precedents), summarizing them (summarize_precedent), extracting keywords (extract_precedent_keywords), and finding similar cases (find_similar_precedents).
    • Advanced Search & Discovery: Integrated search (search_all), advanced filtering (advanced_search), and law name autocompletion (suggest_law_names).
    • Administrative & Local Laws: Searching/retrieving administrative rules (search_admin_rule, get_admin_rule) and local ordinances (search_ordinance, get_ordinance).
    • Data Utilities: Batch article retrieval (get_batch_articles), law statistics (get_law_statistics), and generating external links to official portals (get_external_links).
  2. Overview of Korean Law MCP

    main

    Korean Law MCP is an MCP server and CLI that provides access to Korea's official legal database (법제처 Open API). It allows developers and AI agents to search, retrieve, and analyze Korean statutes, precedents, ordinances, and treaties.

    Key capabilities include:

    • Legal Research & Analysis: Search for laws and perform deep analysis.
    • Hallucination Guard: Verifies legal citations (existence and content) to prevent LLM errors.
    • Precedent Citator (cite_check): Checks if a specific precedent is still valid law (Korean Shepard's style).
    • Point-in-Time Law (applicable_law): Resolves which version of a law was in force on a specific date.
    • Ordinance Revision Radar (ordinance_radar): Detects if local ordinances are stale due to changes in parent statutes.

    It is compatible with MCP clients like Claude Desktop, Cursor, Windsurf, and Zed.

  3. Understand the Korean Law MCP tool structure

    main

    The Korean Law MCP provides 10 primary tools to interact with Korean legal data. Since version 4.4.0, many specialized functions have been consolidated into two high-level tools: legal_research and legal_analysis. Other specialized tools can be accessed via discover_tools and execute_tool or by calling their original names for backward compatibility.

    Tool Categories

    CategoryToolDescription
    Researchlegal_researchMulti-step legal research using one of 8 task types.
    Analysislegal_analysisVerification and analysis using one of 4 mode types.
    Statutessearch_lawSearch for laws to obtain lawId and MST.
    get_law_textRetrieve full text of specific articles.
    get_annexesRetrieve annexes, forms, or tables (e.g., fee schedules).
    Ordinancesordinance_radarAutomatically compares local ordinances against updated superior laws (v4.7.0).
    Integratedsearch_decisionsUnified search across 18 domains (Precedents, Constitutional Court, Tax Tribunal, etc.).
    get_decision_textRetrieve full text of decisions from the 18 domains.
    Metadiscover_toolsSearch for specialized tools (terminology, annexes, history, comparison).
    execute_toolProxy execution for specialized tools.
  4. Core Features of Korean Law MCP

    main

    Korean Law MCP provides high-level intelligence for legal research through several key capabilities:

    • Consolidated Tools: 42 underlying APIs are exposed through 10 optimized tools covering statutes, precedents, administrative rules, ordinances, constitutional decisions, tax rulings, customs interpretations, treaties, institutional rules, and legal terminology.
    • Decision Domains: The search_decisions tool covers 17 domains, including precedents, constitutional court, tax tribunal, FTC, NLRC, and customs.
    • Intelligence & Automation: Auto-resolves abbreviations, converts article numbers (e.g., 제38조003800), and visualizes 3-tier delegation.
    • Annex Processing: Uses the kordoc engine to download and convert various file formats (HWPX, HWP, PDF, XLSX, DOCX) into Markdown.
    • Chain Tools: Provides composite workflows like chain_full_research which automates a sequence of AI search → statutes → precedents → interpretations.
    • Caching: Implements a 1-hour search cache and a 24-hour article cache to improve performance.
  5. Understand Korean Law data flow patterns

    main

    The MCP server supports several optimized data flow patterns for interacting with legal data:

    • 2-step Search & Lookup: First use a search tool to get a unique identifier (mst), then use a lookup tool with that mst and a specific article number (jo).
    • Batch Lookup: Use get_batch_articles to retrieve multiple articles in a single API call by providing an mst and an array of article strings (e.g., ["제38조","제39조"]).
    • Chained Tools: Use tools like chain_full_research which automatically execute a sequence of tools (search $\rightarrow$ text $\rightarrow$ precedents $\rightarrow$ interpretations) in parallel to provide a comprehensive response.
    • Annex Extraction: Use get_annexes to download and parse supplementary files. The system automatically detects file types (HWPX, HWP, PDF) and converts HWP/HWPX tables into Markdown.
  6. Coding standards and rules

    main

    To maintain code quality, follow these rules:

    • File Size: Keep files under 200 lines. If a file exceeds this, move logic to src/lib/.
    • Naming Conventions:
      • Files: kebab-case
      • Functions: camelCase
      • Types: PascalCase
    • Validation: Every tool input MUST use a Zod schema.
    • LexDiff Integrity: Do not modify code in search-normalizer.ts or law-parser.ts as they are derived from LexDiff.
  7. Use JO Code (Article Numbers) for legal queries

    main

    The JO Code (조문번호) is a 6-digit AAAABB format used to identify specific articles:

    • AAAA: Article number (0001~9999)
    • BB: Sub-article/Paragraph number (00~99)

    Examples:

    • Article 5 (제5조) $\rightarrow$ 000500
    • Article 38 (제38조) $\rightarrow$ 003800
    • Article 10-2 (제10조의2) $\rightarrow$ 001002

    Note: For Local Ordinances (get_ordinance), you can input Korean text like "제20조" in the jo parameter, and it will be automatically converted to the code format.

  8. Understand the Precedent Search Architecture

    main

    Precedent searching in korean-law-mcp is implemented through a centralized core to ensure consistency across multiple calling paths. Developers should be aware that searching is not a single path; it is accessed via direct tool calls, unified decision searches, chain tools, and auxiliary analysis tools.

    Key Architectural Principles:

    • Decoupled Tools: Search tools (e.g., search_precedents) and detail retrieval tools (e.g., get_precedent_text) are separate. MCP tools/call only executes the requested handler and does not automatically trigger natural language routers or search-detail chains.
    • Structured Data over Parsing: New calling paths should prioritize using structured hit lists rather than parsing IDs from rendered text.
    • Compatibility: The output format [id] Title for search_precedents must be maintained to ensure the existing search-detail chain can still extract IDs.
    • Fallback Policies: Use fallbackPolicy: "none" for paths requiring high precision (like reverse searching for specific legal articles) to prevent the system from broadening the search query automatically.
  9. Verify legal citations with `legal_analysis`

    main

    To prevent LLM hallucinations, use the legal_analysis tool with the verify_citations mode. This ensures that the laws and articles cited by the AI actually exist and that the content matches the cited title.

    Verification Levels:

    • Existence Check: Confirms if the law name and article number exist in the database.
    • Content Match ([CONTENT_MISMATCH]): Checks if the text provided for a specific article (e.g., Civil Act Article 750 (Cancellation of Contract)) actually matches the official title and content of that article. This prevents the AI from citing a real article but attaching incorrect legal text to it.
  10. How the Korean Law MCP architecture works

    main

    The Korean Law MCP is a Model Context Protocol (MCP) server that provides access to the Korea Ministry of Government Legislation API (law.go.kr). It operates in two primary modes:

    1. STDIO Mode: Used for local desktop integration (e.g., with Claude Desktop).
    2. HTTP Mode: Used for remote integration (e.g., via Fly.io) using the StreamableHTTP stateless protocol.

    The system consists of a Tool Registry containing 98 Zod-validated tools categorized into Search, Lookup, Analysis, Full Text, Constitutional/Administrative, Knowledge Base, and Chains. These tools rely on shared libraries for API communication, XML/Annex parsing, and caching.

  11. How smart scenarios work in Korean Law MCP

    main

    Starting from v3.2.0, the MCP server supports 'Smart Scenarios'. Instead of manually chaining tools, you can ask questions in natural language. The AI detects the intent and automatically executes the necessary research and analysis tasks.

    Examples of natural language queries and their automated workflows:

    • "Food Sanitation Act penalty reduction possible?" $\rightarrow$ Penalty schedule + violation clauses + appeal cases.
    • "Import customs FTA check" $\rightarrow$ Customs Act + interpretations + FTA treaties + tariff tables + tax tribunal rulings.
    • "Building Act permit procedure" $\rightarrow$ Legal basis (Act $\rightarrow$ Decree $\rightarrow$ Rule) + fees/forms + admin rules + local ordinance exceptions.
    • "Labor Standards Act amendment timeline" $\rightarrow$ Old/new comparison + article history + precedents/interpretations mapped chronologically.
  12. Automatic expansion of legal abbreviations

    main

    The system automatically expands common legal abbreviations into their full names within queries. This allows for more flexible searching. For example:

    • 화관법 시행령 $\rightarrow$ 화학물질관리법 시행령
    • 산안법 시행규칙 $\rightarrow$ 산업안전보건법 시행규칙
    • 중처법 제4조 $\rightarrow$ 중대재해 처벌 등에 관한 법률 제4조