### Initial Project Setup and Run Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/DEVELOPMENT.md Clone the repository, install dependencies, build the project, and run the main application with an API key. ```bash git clone https://github.com/chrisryugj/korean-law-mcp.git cd korean-law-mcp npm install npm run build LAW_OC=your-api-key node build/index.js ``` -------------------------------- ### Tool Aliases Example Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/CHANGELOG.md Example of how discover_tools can use natural language input with aliases. ```typescript discover_tools(intent="조세심판원") ``` -------------------------------- ### Terminal Usage Examples Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Examples of how to use the korean-law-mcp command-line interface for searching laws, listing tools, and getting help. ```bash # 설치 npm install -g korean-law-mcp # 인증키 설정 (honggildong을 본인 키로 바꾸세요) export LAW_OC=honggildong # Mac/Linux set LAW_OC=honggildong # Windows CMD $env:LAW_OC="honggildong" # Windows PowerShell # 사용 예시 korean-law "민법 제1조" # 자연어로 바로 조회 korean-law search_law --query "관세법" # 도구 직접 호출 korean-law list # 전체 도구 목록 korean-law list --category 판례 # 카테고리별 필터 korean-law help search_law # 도구별 도움말 ``` -------------------------------- ### Example Usage in Claude Code Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Examples of how to ask questions in Claude Code that will trigger the korean-law MCP tool. ```bash "근로기준법 제74조 알려줘" "민법 제750조 판례 검증해줘" ``` -------------------------------- ### Manual Installation Command Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Command to manually install the korean-law-mcp globally using npm. ```bash npm install -g korean-law-mcp ``` -------------------------------- ### Usage Examples Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README-EN.md Examples of how to interact with the Korean Law MCP using natural language queries and corresponding tool calls. ```text User: "관세법 제38조 알려줘" → search_law("관세법") → get_law_text(mst, jo="003800") User: "화관법 최근 개정 비교" → "화관법" → "화학물질관리법" auto-resolved → compare_old_new(mst) User: "근로기준법 제74조 해석례" → search_interpretations("근로기준법 제74조") → get_interpretation_text(id) User: "산업안전보건법 별표1 내용" → get_annexes("산업안전보건법 별표1") → HWPX download → Markdown table ``` -------------------------------- ### Action Plan Scenario - 5-Step Citizen-Friendly Action Guide Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/CHANGELOG.md Description of the 'action_plan' scenario, built upon 'chain_full_research', which provides a 5-step guide for citizens responding to specific legal situations, mapping keywords to legal domains and outlining necessary actions. ```typescript 5 Steps: Situation Diagnosis, Rights/Remedies, Application Agency/Deadline, Required Documents/Forms, Pitfalls/Precautions. ``` ```typescript Citizen Keywords to Legal Domain Mapping: e.g., '전세금 못 받았어' -> 주택임대차보호법 보증금. ``` -------------------------------- ### Install Korean Law MCP Plugin Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Install the Korean Law MCP plugin for Claude Code. ```bash /plugin marketplace add chrisryugj/korean-law-mcp /plugin install korean-law@korean-law-marketplace ``` -------------------------------- ### Usage Examples with API Call Flow Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Examples demonstrating how to query Korean laws and the corresponding API call flow, including searching, comparing, and retrieving interpretations or annexes. ```text "관세법 제38조 알려줘" → search_law("관세법") → MST 획득 → get_law_text(mst, jo="003800") "화관법 최근 개정 비교" → "화관법" → "화학물질관리법" 자동 변환 → compare_old_new(mst) "근로기준법 제74조 해석례" → search_interpretations("근로기준법 제74조") → get_interpretation_text(id) "산업안전보건법 별표1 내용 알려줘" → get_annexes(lawName="산업안전보건법 별표1") → HWPX 파일 다운로드 → 표/텍스트 Markdown 변환 ``` -------------------------------- ### Get Article with Precedents Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves a specific article along with associated legal precedents. ```json { "mst": "279811", "jo": "제38조", "includePrecedents": true } ``` -------------------------------- ### Example Query for Construction Permit Procedures Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md An example query for understanding construction permit procedures, illustrating the system's ability to provide legal basis (laws, decrees, rules), fees, forms, related directives, local ordinances, and interpretations. ```Korean "건축법 허가 절차" ``` -------------------------------- ### Manual Installation Configuration Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Configuration to be added to AI app settings for manual installation, specifying the command and environment variable for the API key. ```json { "mcpServers": { "korean-law": { "command": "korean-law-mcp", "env": { "LAW_OC": "honggildong" } } } } ``` -------------------------------- ### Get Batch Articles Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves multiple articles from a law in a single request. ```json { "mst": "279811", "articles": [ "제38조", "제39조", "제40조" ] } ``` -------------------------------- ### Example Query for Local Ordinance Compliance Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md An example query to check if a local ordinance complies with higher laws, showing how the system can search for related Constitutional Court rulings, administrative appeal decisions, and compare against the legal basis. ```Korean "주차 조례 상위법 적합성" ``` -------------------------------- ### Automatic Installation Command Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Command to automatically set up the korean-law-mcp, including API key input, AI client selection, and automatic configuration file registration. ```bash npx korean-law-mcp setup ``` -------------------------------- ### Search Law and Get Article Text Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/API.md Demonstrates how to search for a law by its name and then retrieve the text of a specific article using its MST and Jo identifiers. ```python 1. search_law(query="근로기준법") → mst: 276787 획득 2. get_law_text(mst="276787", jo="제74조") → 조문 내용 조회 ``` -------------------------------- ### Get Law Annexes Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieve a list of annexes for a specific law, identified by `lawName` and `knd` (type). This can include tables of rates or other supplementary information. ```json { "lawName": "관세법", "knd": "1" } ``` -------------------------------- ### Get Article with Precedents API Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves a specific article from a law along with its associated precedents. ```APIDOC ## GET /get_article_with_precedents ### Description Retrieves a specific article from a law and includes any relevant legal precedents associated with it. ### Method GET ### Endpoint /get_article_with_precedents ### Parameters #### Query Parameters - **mst** (string) - Required - The master ID of the law. - **jo** (string) - Required - The article number (e.g., "제38조"). - **includePrecedents** (boolean) - Required - Set to true to include precedents. ### Request Example ```json { "mst": "279811", "jo": "제38조", "includePrecedents": true } ``` ### Response #### Success Response (200) - **response preview** (string) - The content of the specified article, including law name, promulgation date, effective date, and the article text. Precedents are not explicitly shown in the preview but are implied to be included. #### Response Example ```json { "response preview": "법령명: 관세법\n공포일: 20251111\n시행일: 20251111\n\n제38조 신고납부\n제38조(신고납부)\n① 물품(제39조에 따라 세관장이 부과고지하는 물품은 제외한다)을 수입하려는 자는 수입신고를 할 때에 세관장에게 관세의 납부에 관한 신고(이하 \"납세신고\"라 한다)를 하여야 한다." } ``` ``` -------------------------------- ### Pattern 2: Batch Query (1 API call) Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/ARCHITECTURE.md Example of batch querying for articles, performing one full law lookup and then filtering by article. ```python get_batch_articles(mst="279811", articles=["제38조","제39조","제40조"]) → 전체 법령 1회 조회 후 조문 필터링 ``` -------------------------------- ### Get Precedent Text Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves the full text of a specific legal precedent using its unique ID. ```json { "id": "609561" } ``` -------------------------------- ### Environment File for HTTP API Protocol Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Example of a .env file to set both the API key and the API protocol to HTTP. ```env LAW_OC=honggildong LAW_API_PROTOCOL=http ``` -------------------------------- ### JO Code Format Example Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/API.md Illustrates the conversion of Korean article numbering (e.g., '제5조') to the 6-digit JO code format (AAAABB). This format is used for specifying articles within laws and ordinances. ```plaintext 제5조 → 000500 제38조 → 003800 제10조의2 → 001002 ``` -------------------------------- ### Citation Verification Example Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Demonstrates how the `verify_citations` function checks citations against the Ministry of Government Legislation's official database, identifying actual provisions and flagging non-existent or incorrectly cited ones. ```Korean "민법 제750조에 따라 불법행위 손해배상을 청구하고, 근로기준법 제60조 제1항은 연차유급휴가를 규정하며, 상법 제401조의2 제7항에 따라 이사 책임을 물을 수 있고, 형법 제9999조는 가중처벌을 정한다" ``` ```Korean → `verify_citations` 한 번으로 (실제 법제처 API 교차검증 결과): - ✓ 민법 제750조(불법행위의 내용) 실존 - ✓ 근로기준법 제60조(연차 유급휴가) 제1항 실존 - ✗ **상법 제401조의2 — 제7항 없음 (최대 제2항)** - ✗ **형법 제9999조 — 해당 조문 없음 (존재 범위: 제1조~제372조)** ``` -------------------------------- ### Build and Run Docker Image Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/DEVELOPMENT.md Build a Docker image for the application and run it, exposing port 3000 and setting the necessary API key environment variable. ```bash docker build -t korean-law-mcp . docker run -e LAW_OC=your-key -p 3000:3000 korean-law-mcp ``` -------------------------------- ### Build and Test New Tool Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/DEVELOPMENT.md After adding a new tool, build the project and test it using either the standard STDIO mode or the Inspector for debugging. ```bash npm run build LAW_OC=your-key node build/index.js # STDIO 모드 테스트 npx @modelcontextprotocol/inspector build/index.js # Inspector 테스트 ``` -------------------------------- ### Deploy to Fly.io Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/DEVELOPMENT.md Deploy the application to Fly.io using the `flyctl deploy` command. ```bash flyctl deploy ``` -------------------------------- ### Extract Annexes and Convert to Markdown Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/API.md Demonstrates how to retrieve a list of annexes for a given law, download a specific annex file (HWP) using its bylSeq, and convert it to Markdown. ```python 1. get_annexes(lawName="여권법 시행령") → 별표 목록 + bylSeq 획득 2. get_annexes(lawName="여권법 시행령", bylSeq="000000") → HWP 파일 다운로드 → 표 Markdown 변환 ``` -------------------------------- ### Version Management and Publishing Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/DEVELOPMENT.md Increment the project version using `npm version patch`, build the project, and then publish the package to the npm registry. ```bash npm version patch # 버전 bump npm run build npm publish ``` -------------------------------- ### Example Query for Unenacted Delegated Legislation Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md An example query to find provisions that mandate a decree but for which the decree has not yet been enacted. ```Korean "국민건강보험법 위임입법" ``` -------------------------------- ### Development Workflow: Watch Mode and CLI Testing Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/DEVELOPMENT.md Use `npm run watch` for continuous building during development. Test the CLI interface by running specific commands with arguments. ```bash # Watch 모드 npm run watch # 다른 터미널에서 서버 실행 LAW_OC=your-key node build/index.js # CLI 테스트 npm run cli -- search_law --query "민법" npm run cli -- list ``` -------------------------------- ### Chain Tool for Comprehensive Research Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/API.md Shows how to use the `chain_full_research` tool to automatically perform a multi-step research process, including AI search, law lookup, case law retrieval, and interpretation analysis. ```python 1. chain_full_research(query="음주운전 처벌") → AI검색 → 법령조문 → 판례 → 해석례 자동 수행 ``` -------------------------------- ### Example Query for Impact Analysis of Legal Amendments Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md An example query for analyzing the impact of a legal amendment, demonstrating the system's capability to identify affected subordinate legislation, local ordinances, and administrative rules. ```Korean "건축법 영향도 분석" ``` -------------------------------- ### Example Query for Administrative Fine Reduction Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md An example query asking about the possibility of reducing an administrative fine, demonstrating how the system can provide information on penalty standards, relevant provisions, reduced administrative appeal cases, and amendment history. ```Korean "식품위생법 영업정지 과태료 감경 가능?" ``` -------------------------------- ### Get Law Tree API Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves the hierarchical structure of a law. ```APIDOC ## GET /get_law_tree ### Description Retrieves the hierarchical structure of a law, providing a tree-like representation. ### Method GET ### Endpoint /get_law_tree ### Parameters #### Query Parameters - **mst** (string) - Required - The master ID of the law. ### Request Example ```json { "mst": "279811" } ``` ### Response #### Success Response (200) - **response preview** (string) - A preview of the law tree structure, indicating the law name and a note about using another tool for detailed delegation relationships. #### Response Example ```json { "response preview": "=== 법령 트리 구조 ===\n\n📜 법률\n\n\n💡 상세한 위임 관계는 get_three_tier Tool을 사용하세요." } ``` ``` -------------------------------- ### Example Query for Import Regulations Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md An example query for checking import regulations, showing how the system can consolidate information from various sources like the Customs Act, Korea Customs Service interpretations, FTA treaties, tariff tables, and Tax Tribunal rulings. ```Korean "수입 통관 FTA 적용 확인" ``` -------------------------------- ### Compare Articles Between Two Laws Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/API.md Shows how to search for two different laws and then compare specific articles from each. ```python 1. search_law(query="근로기준법") → mst1 2. search_law(query="파견법") → mst2 3. compare_articles(law1={mst: mst1, jo:"74조"}, law2={mst: mst2, jo:"18조"}) ``` -------------------------------- ### Get Batch Articles API Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves multiple articles from a law in a single request. ```APIDOC ## POST /get_batch_articles ### Description Retrieves multiple articles from a specified law in a single request. ### Method POST ### Endpoint /get_batch_articles ### Parameters #### Request Body - **mst** (string) - Required - The master ID of the law. - **articles** (array of strings) - Required - A list of article numbers to retrieve (e.g., ["제38조", "제39조"]). ### Request Example ```json { "mst": "279811", "articles": [ "제38조", "제39조", "제40조" ] } ``` ### Response #### Success Response (200) - **response preview** (string) - The content of the requested articles, including the law name and the text of each article. #### Response Example ```json { "response preview": "법령명: 관세법\n조회 조문: 제38조, 제39조, 제40조\n\n제38조 신고납부\n제38조(신고납부)\n① 물품(제39조에 따라 세관장이 부과고지하는 물품은 제외한다)을 수입하려는 자는 수입신고를 할 때에 세관장에게 관세의 납부에 관한 신고(이하 \"납세신고\"라 한다)를 하여야 한다.\n② 세관장은 납세신고를 받으면 수입신고서에 기재된 사항과 이 법에 따른 확인사항 등을 심사하되, 신고한 세액 등 납세신고 내용에 대한 심사(이하 \"세액심사\"라 한다)는 수입신고를 수리한 후에 한다. 다만, 신고한 세액에 대하여 관세채권을 확보하기가 곤란하거나..." } ``` ``` -------------------------------- ### Register New Tool in Tool Registry Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/DEVELOPMENT.md Add the newly defined tool's schema and handler to the `allTools` array in `src/tool-registry.ts` to make it available in the MCP. ```typescript import { NewToolSchema, newTool } from "./tools/new-tool.js" // allTools 배열에 추가 { name: "new_tool_name", description: "도구 설명", schema: NewToolSchema, handler: (client, input) => newTool(client, input) } ``` -------------------------------- ### Get Interpretation Text API Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves the full text of a specific legal interpretation by its ID. ```APIDOC ## GET /get_interpretation_text ### Description Retrieves the full text of a specific legal interpretation using its unique ID. ### Method GET ### Endpoint /get_interpretation_text ### Parameters #### Query Parameters - **id** (string) - Required - The ID of the interpretation. ### Request Example ```json { "id": "333393" } ``` ### Response #### Success Response (200) - **response preview** (string) - The full text of the interpretation, including basic information and the query summary. #### Response Example ```json { "response preview": "=== 고용노동부 - \"근로기준법\" 제74조제5항에 따라 임신 중인 여성근로자에게 금지되는 \"시간외근로\"의 기준이 되는 시간은 법정근로시간인지 소정근로시간인지 등(\"근로기준법\" 제74조제5항 등 관련) ===\n\n📋 기본 정보:\n 해석례번호: 333393\n 회신일자: 20220426\n 질의기관: 고용노동부\n 해석기관: 법제처\n\n📌 질의요지:\n「근로기준법」 제50조에서는 1주 간의 근로시간은 휴게시간을 제외하고 40시간을 초과할 수 없다고 규정(제1항)하면서, 1일의 근로시간은 휴게시간을 제외하고 8시간을 초과할 수 없다고 ..." } ``` ``` -------------------------------- ### Compare Old and New Law Versions Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Utilize the `compare_old_new` tool to view the differences between the old and new versions of a law, identified by its `mst` ID. This is useful for tracking legislative changes. ```json { "mst": "279811" } ``` -------------------------------- ### Verify Citations Tool Implementation Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/CHANGELOG.md Implementation of the 'verify_citations' tool for LLM hallucination prevention. ```typescript import { verifyCitations } from "./src/tools/verify-citations.ts"; // Example usage (conceptual): const result = await verifyCitations("Input text with citations."); // Result can be ✓ (exists), ✗ (does not exist), ⚠ (ambiguous/failed) ``` -------------------------------- ### Get Precedent Text API Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves the full text of a specific legal precedent by its ID. ```APIDOC ## GET /get_precedent_text ### Description Retrieves the full text of a specific legal precedent using its unique ID. ### Method GET ### Endpoint /get_precedent_text ### Parameters #### Query Parameters - **id** (string) - Required - The ID of the precedent. ### Request Example ```json { "id": "609561" } ``` ### Response #### Success Response (200) - **response preview** (string) - The full text of the precedent, including basic information, holdings, and other relevant details. #### Response Example ```json { "response preview": "=== 여객자동차운수사업법위반 ===\n\n📋 Basic Information:\n Case Number: 2025고단1110\n Court: 인천지법\n Date: 20250910\n Case Type: 형사\n Judgment Type: 판결 : 항소\n\n📌 Holdings (판시사항):\n
자동차대여사업자 등인 피고인들이 상호 업무제휴계약을 맺고 공모하여, 외국항공사인 甲 항공과 체결한 ‘甲 항공 일등석 및 비즈니스석 승객 대상 서울지역 운송서비스 계약’에 따라 甲 항공으로부터 VIP 고객의 이름, 입출국 시간, 승하차 ..." } ``` ``` -------------------------------- ### Get Interpretation Text Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Retrieves the full text of a specific legal interpretation using its ID. ```json { "id": "333393" } ``` -------------------------------- ### AI Search to Detailed Law Lookup Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/API.md Illustrates using AI to find relevant laws based on a query, then retrieving the specific article text using the law name and article number. ```python 1. search_ai_law(query="음주운전 처벌") → 도로교통법 제148조의2 발견 2. get_law_text(lawId="도로교통법", jo="제148조의2") ``` -------------------------------- ### Get Ordinance Data Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/test-results-final.txt Attempt to retrieve ordinance data using `ordinSeq`. This tool may return no data if the ordinance is not found or not available. ```json { "ordinSeq": "5000001" } ``` -------------------------------- ### Action Plan - Step-by-Step Guidance Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Provides a 5-step guidance system: STEP 1 Situation Diagnosis (automatically identifying the relevant law, e.g., Housing Lease Protection Act), STEP 2 Rights/Remedies (precedents), STEP 3 Application Agency/Deadline (administrative rules + interpretations), STEP 4 Required Documents/Forms (appendices), and STEP 5 Pitfalls/Precautions (statute of limitations, legal aid corporation). It converts natural language queries into actionable steps. ```Korean "전세금 못 받았어" ``` -------------------------------- ### API Overview and Standards Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/docs/API.md General information regarding ID formats, JO code structures, error handling, and system constraints for the Korean Law MCP. ```APIDOC ## API Standards ### ID Formats - **Statute (mst/lawId)**: 6 digits - **Administrative Rule (id)**: 13 digits - **Ordinance (ordinSeq)**: 7 digits - **Precedent (id)**: 6 digits - **Interpretation (id)**: 6 digits ### JO Code (Article Number) Format: `AAAABB` (AAAA: Article number 0001-9999, BB: Sub-article number 00-99). Example: 제5조 -> 000500, 제10조의2 -> 001002. ### Error Response ```json { "content": [{ "type": "text", "text": "[Error Code] Tool Name: Error Message\n\n💡 Solution: ..." }], "isError": true } ``` ``` -------------------------------- ### Troubleshooting: Force HTTPS Clone Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Workaround for 'Permission denied (publickey)' error by forcing HTTPS clone. ```bash git config --global url."https://github.com/".insteadOf "git@github.com:" ``` -------------------------------- ### Troubleshooting: Generate SSH Key Source: https://github.com/chrisryugj/korean-law-mcp/blob/main/README.md Steps to generate an SSH key and add it to GitHub. ```bash ssh-keygen -t ed25519 -C "your-email@example.com" # 엔터 3번 cat ~/.ssh/id_ed25519.pub # 출력 복사 ```