Search and retrieve Korean statutes and administrative rules with precise filters. Access English translations and drill down to articles, paragraphs, and sub-items. Explore linkages with local ordinances and delegated authority to speed up legal research.
🌐 Read this in other languages: English | 한국어 (Korean)
LexLink is an MCP (Model Context Protocol) server that exposes the Korean National Law Information API (open.law.go.kr) to AI agents and LLM applications. It enables AI systems to search, retrieve, and analyze Korean legal information through standardized MCP tools.
lexlink://law/{name})🎉 Production Ready - Phase 9 Complete!
| Metric | Status |
|---|---|
| Tools Implemented | 54/54 (100%) ✅ |
| Semantic Validation | 26/26 (Phase 1-5 tools) ✅ |
| MCP Prompts | 9/9 (100%) ✅ |
| MCP Resources | 2 (1 static + 1 template) ✅ |
| API Coverage | ~28% of 191+ endpoints |
| LLM Integration | ✅ Validated (Gemini) |
| Code Quality | Clean, documented, tested |
| Version | v2.1.0 |
Latest: v2.1.0 — 54 tools (Phase 9 added), intelligent caching (cache.py), law name resolution (resolver.py), chain tools for multi-step research workflows.
uv sync
Option A: Environment Variable (Recommended)
# Set OC in your environment
export OC=your_id_here
Option B: Pass in Tool Arguments
# Override OC in each tool call
eflaw_search(query="법령명", oc="your_id")
# Stdio transport (for Claude Code, Cursor, etc.)
OC=your_oc uv run stdio
# HTTP transport (for Kakao PlayMCP)
OC=your_oc TRANSPORT=http uv run serve
eflaw_search - Search Laws by Effective DateSearch for laws organized by effective date (시행일 기준).
eflaw_search(
query="자동차관리법", # Search keyword
display=10, # Results per page
type="XML", # Response format
ef_yd="20240101~20241231" # Optional date range
)
law_search - Search Laws by Announcement DateSearch for laws organized by announcement date (공포일 기준).
law_search(
query="민법",
display=10,
type="XML"
)
eflaw_service - Retrieve Law Content (Effective Date)Get full law text and articles by effective date.
IMPORTANT: For specific article queries (e.g., "제174조"), use the
joparameter. Some laws have 400+ articles and responses can exceed 1MB withoutjo.
# Get specific article (RECOMMENDED)
eflaw_service(
mst="279823", # Law MST
jo="017400", # Article 174 (제174조)
type="XML"
)
# Get full law (WARNING: large response)
eflaw_service(
id="001823",
type="XML"
)
law_service - Retrieve Law Content (Announcement Date)Get full law text and articles by announcement date.
IMPORTANT: For specific article queries (e.g., "제174조"), use the
joparameter. Some laws have 400+ articles and responses can exceed 1MB withoutjo.
# Get specific article (RECOMMENDED)
law_service(
mst="279823", # Law MST
jo="017400", # Article 174 (제174조)
type="XML"
)
eflaw_josub - Query Article/Paragraph (Effective Date)Best tool for querying specific articles. Returns only the requested article/paragraph.
eflaw_josub(
mst="279823", # Law MST
jo="017400", # Article 174 (제174조)
type="XML"
)
# jo format: "XXXXXX" where first 4 digits = article (zero-padded), last 2 = branch (00=main)
# Examples: "017400" (제174조), "000300" (제3조), "001502" (제15조의2)
law_josub - Query Article/Paragraph (Announcement Date)Best tool for querying specific articles. Returns only the requested article/paragraph.
law_josub(
mst="279823", # Law MST
jo="017200", # Article 172 (제172조)
type="XML"
)
elaw_search - Search English-Translated LawsSearch for Korean laws translated to English.
elaw_search(
query="employment",
display=10,
type="XML"
)
elaw_service - Retrieve English Law ContentGet full English-translated law text.
elaw_service(
id="009589",
type="XML"
)
admrul_search - Search Administrative RulesSearch administrative rules (훈령, 예규, 고시, 공고, 지침).
admrul_search(
query="학교",
display=10,
type="XML"
)
admrul_service - Retrieve Administrative Rule ContentGet full administrative rule text with annexes.
admrul_service(
id="62505",
type="XML"
)
lnkLs_search - Search Law-Ordinance LinkageFind laws linked to local ordinances.
lnkLs_search(
query="건축",
display=10,
type="XML"
)
lnkLsOrdJo_search - Search Ordinance Articles by LawFind ordinance articles linked to specific law articles.
lnkLsOrdJo_search(
knd="002118", # Law ID
display=10,
type="XML"
)
lnkDep_search - Search Law-Ordinance Links by MinistryFind laws linked to ordinances by government ministry.
lnkDep_search(
org="1400000", # Ministry code
display=10,
type="XML"
)
drlaw_search - Retrieve Law-Ordinance Linkage StatisticsGet linkage statistics table (HTML format).
drlaw_search(
lid="001823", # Law ID
type="HTML"
)
lsDelegated_service - Retrieve Delegated Law InformationGet information about delegated laws, rules, and ordinances.
lsDelegated_service(
id="001823",
type="XML"
)
Tip: All
*_servicetools in Phase 3 support asections="summary"parameter to return only a brief summary instead of the full document text.
prec_search - Search Court PrecedentsSearch Korean court precedents from Supreme Court and lower courts.
prec_search(
query="담보권",
display=10,
type="XML",
curt="대법원" # Optional: Court name filter
)
prec_service - Retrieve Court Precedent Full TextGet complete court precedent text with case details.
prec_service(
id="228541",
type="XML"
)
detc_search - Search Constitutional Court DecisionsSearch Korean Constitutional Court decisions.
detc_search(
query="벌금",
display=10,
type="XML"
)
detc_service - Retrieve Constitutional Court Decision Full TextGet complete Constitutional Court decision text.
detc_service(
id="58386",
type="XML"
)
expc_search - Search Legal InterpretationsSearch legal interpretation precedents issued by government agencies.
expc_search(
query="임차",
display=10,
type="XML"
)
expc_service - Retrieve Legal Interpretation Full TextGet complete legal interpretation text.
expc_service(
id="334617",
type="XML"
)
decc_search - Search Administrative Appeal DecisionsSearch Korean administrative appeal decisions.
decc_search(
query="*", # Search all decisions
display=10,
type="XML"
)
decc_service - Retrieve Administrative Appeal Decision Full TextGet complete administrative appeal decision text.
decc_service(
id="243263",
type="XML"
)
article_citation - Extract Citations from Law ArticleExtract all legal citations referenced by a specific law article.
# First, search for the law to get MST
eflaw_search(query="건축법") # Returns MST: 268611
# Then extract citations
article_citation(
mst="268611", # Law MST from search result
law_name="건축법", # Law name
article=3 # Article number (제3조)
)
Response:
{
"success": true,
"law_name": "건축법",
"article": "제3조",
"citation_count": 12,
"internal_count": 4,
"external_count": 8,
"citations": [
{
"type": "external",
"target_law_name": "「국토의 계획 및 이용에 관한 법률」",
"target_article": 56,
"target_paragraph": 1
}
]
}
Key Features:
aiSearch - AI-Powered Semantic Law Search⭐ PREFERRED TOOL for vague or natural language queries. Use this FIRST when user's intent is unclear or conversational.
Uses intelligent/semantic search to find relevant law articles with full article text.
aiSearch(
query="뺑소니 처벌", # Natural language query
search=0, # 0: law articles, 1: appendix, 2: admin rules, 3: admin appendix
display=20, # Results per page
page=1, # Page number
type="JSON" # Response format (JSON default)
)
Best for: Natural language queries like "음주운전 벌금", "이혼 재산분할", "상속 문제"
aiRltLs_search - AI-Powered Related Laws Search⭐ PREFERRED TOOL for discovering related laws from vague topics. Use this when user wants to explore laws around a general subject.
Finds laws semantically related to a given law name or keyword.
aiRltLs_search(
query="민법", # Law name or keyword
search=0, # 0: law articles, 1: admin rule articles
type="JSON" # Response format (JSON default)
)
Best for: Finding related laws like "민법" → 상법, 의료법, 소송촉진법
| Category | Tools |
|---|---|
| 자치법규 (Local Ordinances) | ordin_search, ordin_service, ordinLsCon_search |
| 조약 (Treaties) | trty_search, trty_service |
| 법령정보 지식베이스 (Knowledge Base) | lstrm_ai_search, dlytrm_search, lstrm_rlt_search, dlytrm_rlt_search, lstrm_rlt_jo_search, jo_rlt_lstrm_search, ls_rlt_search |
| 위원회 결정문 (Committee Decisions) | committee_search, committee_service |
| 중앙부처 1차 해석 (Ministry Interpretations) | cgm_expc_search, cgm_expc_service |
| 특별행정심판 (Special Appeals) | special_decc_search, special_decc_service |
Inspired by korean-law-mcp, these tools run multi-step research workflows in a single call — eliminating the need for an LLM to orchestrate sequential tool calls manually.
| Tool | Description |
|---|---|
chain_full_research | Complete legal research: statutes + precedent analysis + interpretations |
chain_amendment_track | Revision history + article-level diff across amendments |
chain_dispute_prep | All case law sources across 4 databases (판례, 헌재결정례, 법령해석례, 행정심판례) |
chain_law_system | Full law hierarchy: delegation tree + admin rules + ordinances |
cache_stats | Cache and resolver performance monitoring |
When searching Korean law, select tools based on query clarity:
| Query Type | Recommended Tools | Examples |
|---|---|---|
| 🔍 Vague/Natural language | aiSearch, aiRltLs_search | "음주운전 처벌", "이혼 재산분할" |
| 📋 Specific law/article | eflaw_search, law_search | "형법 제148조의2", "민법 상속편" |
| ⚖️ Case law | prec_search, detc_search | "대법원 2023다12345" |
| 🔗 Related laws | aiRltLs_search | "민법과 관련된 법률" |
| Variable | Default | Description |
|---|---|---|
OC | (required) | law.go.kr API identifier (email local part) |
LEXLINK_BASE_URL | http://www.law.go.kr | API base URL |
LEXLINK_TIMEOUT | 60 | HTTP request timeout in seconds |
SLIM_RESPONSE | (unset) | Set true to remove redundant raw XML when parsed data exists (for PlayMCP) |
TRANSPORT | sse | Transport type: sse or http |
When resolving the OC identifier:
oc parameter in tool callOC env var (set via .env or HTTP header middleware)# Search for automobile management law
result = eflaw_search(
query="자동차관리법",
display=5,
type="XML"
)
# Returns:
{
"status": "ok",
"request_id": "uuid",
"upstream_type": "XML",
"data": {
# Law search results...
}
}
# Find laws effective in 2024
result = eflaw_search(
query="교통",
ef_yd="20240101~20241231",
type="XML"
)
# Missing OC parameter
result = eflaw_search(query="test")
# Returns helpful error:
{
"status": "error",
"error_code": "MISSING_OC",
"message": "OC parameter is required but not provided.",
"hints": [
"1. Tool argument: oc='your_value'",
"2. Environment variable: OC=your_value"
]
}
These examples demonstrate real-world conversation flows showing how LLMs interact with LexLink tools to answer legal research questions.
User Query: "What is Article 20 of the Civil Code?"
Tool Calls:
law_search(query="민법", display=50, type="XML") → Find Civil Code IDlaw_service(id="000021", jo="002000", type="XML") → Retrieve Article 20 textResult: LLM provides formatted explanation of Civil Code Article 20 with full legal text and context.
User Query: "Find recent Supreme Court precedents about security interests"
Tool Calls:
prec_search(query="담보권", curt="대법원", display=50, type="XML") → Search Supreme Court precedentsprec_service(id="228541", type="XML") → Retrieve top precedent detailsResult: LLM summarizes key precedents with case numbers, dates, and holdings related to security interests.
User Query: "How does the Labor Standards Act handle overtime, and are there relevant court precedents?"
Tool Calls:
eflaw_search(query="근로기준법", display=50, type="XML") → Find Labor Standards Acteflaw_service(id="001234", jo="005000", type="XML") → Retrieve Article 50 (overtime provisions)prec_search(query="근로기준법 연장근로", display=30, type="XML") → Search overtime precedentsprec_service(id="234567", type="XML") → Retrieve leading precedentResult: LLM provides comprehensive analysis combining statutory text with judicial interpretation, showing how courts apply the overtime provisions.
User Query: "Has the Constitutional Court reviewed laws about fines?"
Tool Calls:
detc_search(query="벌금", display=50, type="XML") → Search Constitutional Court decisionsdetc_service(id="58386", type="XML") → Retrieve decision full textlaw_search(query=<law_name_from_decision>, type="XML") → Find related law for contextResult: LLM explains Constitutional Court holdings on fine-related provisions and their impact on specific laws.
User Query: "What administrative rules exist for schools, and are there related legal interpretations?"
Tool Calls:
admrul_search(query="학교", display=50, type="XML") → Search school-related administrative rulesadmrul_service(id="62505", type="XML") → Retrieve rule contentexpc_search(query="학교", display=30, type="XML") → Search legal interpretationsexpc_service(id="334617", type="XML") → Retrieve interpretation detailsResult: LLM provides overview of administrative framework for schools with official agency interpretations.
User Query: "I'm researching rental housing disputes. Show me the relevant law, court precedents, and administrative appeal decisions."
Tool Calls:
eflaw_search(query="주택임대차보호법", display=50, type="XML") → Find Housing Lease Protection Acteflaw_service(id="002876", type="XML") → Retrieve full law textprec_search(query="주택임대차", display=50, type="XML") → Search housing lease precedentsprec_service(id="156789", type="XML") → Retrieve key precedentdecc_search(query="주택임대차", display=30, type="XML") → Search administrative appeal decisionsdecc_service(id="243263", type="XML") → Retrieve appeal decisionResult: LLM provides comprehensive legal research report covering statutory framework, judicial interpretation, and administrative precedents for rental housing disputes.
User Query: "What laws does Article 3 of the Building Act cite?"
Tool Calls:
eflaw_search(query="건축법", display=50, type="XML") → Find Building Act, get MSTarticle_citation(mst="268611", law_name="건축법", article=3) → Extract all citationsResult: LLM provides complete citation analysis showing 12 citations (8 external laws, 4 internal references) including specific article and paragraph references.
User Query: "What's the penalty for hit-and-run accidents?"
Tool Calls:
aiSearch(query="뺑소니 처벌", search=0, display=20, type="XML") → Semantic search for hit-and-run penaltiesResult: LLM receives full article text from relevant laws (특정범죄 가중처벌 등에 관한 법률 제5조의3) with complete provisions about hit-and-run penalties, enabling comprehensive answer without needing to know specific law names.
User Query: "What laws are related to the Civil Code?"
Tool Calls:
aiRltLs_search(query="민법", search=0, type="XML") → Find semantically related lawsResult: LLM discovers related laws like 상법 (Commercial Act), 의료법 (Medical Service Act), 소송촉진법 (Act on Special Cases Concerning Expedition of Litigation), showing connections across legal domains.
aiSearch or aiRltLs_search FIRST when user intent is unclear or conversationaltype="JSON"; specify type="XML" if your pipeline requires XMLlexlink-ko-mcp/
├── src/lexlink/
│ ├── server.py # Main MCP server with 54 tools
│ ├── _helpers.py # Shared helpers: run_search, run_service, TOOL_ANNOTATIONS
│ ├── cache.py # Intelligent per-tool TTL caching (~183 lines)
│ ├── resolver.py # Korean law name/abbreviation resolution (~225 lines)
│ ├── http_server.py # HTTP/SSE server for Kakao PlayMCP
│ ├── stdio_server.py # Stdio transport entry point
│ ├── params.py # Parameter resolution & mapping
│ ├── validation.py # Input validation
│ ├── parser.py # XML parsing utilities
│ ├── ranking.py # Relevance ranking
│ ├── citation.py # Article citation extraction (Phase 4)
│ ├── client.py # HTTP client for law.go.kr API
│ ├── errors.py # Error codes & responses
│ ├── raw_logger.py # PlayMCP traffic logging
│ └── log_processor.py # Log format converter
├── logs/playmcp/ # PlayMCP traffic logs (daily JSONL)
├── pyproject.toml # Project configuration
└── README.md # This file
# Install test dependencies
uv sync
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=src/lexlink --cov-report=html
# Run specific test category
uv run pytest -m unit
uv run pytest -m integration
uv run pytest -m e2e
Current Status: 54/54 tools implemented (Phase 1-9 complete). Phase 1-5 tools validated.
For implementing additional tools from the 124+ remaining APIs:
src/lexlink/server.pyctx: Context = None parameter for MCP logging/progressextract_items_list, update_items_list)Tool Implementation Pattern:
ctx: Context = None parameter for MCP contextLexLink can also be deployed as an HTTP server for platforms like Kakao PlayMCP.
Important: Kakao PlayMCP does not accept port numbers in URLs. You must use Nginx as a reverse proxy to serve on port 80.
Quick Start (Local Testing):
# Run the HTTP server
OC=your_oc uv run serve
# Server starts at: http://localhost:8000/sse
Production Setup:
Internet → Nginx (port 80) → LexLink (port 8000)
PlayMCP Registration:
| Field | Value |
|---|---|
| MCP Endpoint | http://YOUR_SERVER_IP/sse (no port!) |
| Authentication | Key/Token (Header: OC) |
For detailed deployment instructions (AWS EC2, Nginx, systemd, HTTPS), see docs/DEPLOYMENT_GUIDE.md.
LexLink includes built-in logging for PlayMCP traffic analysis. Logs are saved in dashboard-compatible JSONL format.
Log Location: logs/playmcp/YYYY-MM-DD.jsonl
Log Schema:
{
"rpc_id": "3",
"request_id": "d8ee45eb",
"session_id": "9ff9dc23431848a4901b4cb6326ba5bd",
"timestamp": "2025-12-25T05:40:23.957987",
"duration_ms": 1.52,
"method": "tools/call",
"tool_name": "aiSearch",
"params": { "arguments": {"query": "뺑소니 처벌"} },
"client": "PlayMCP",
"client_version": "2025.0.0",
"protocol_version": "2025-06-18",
"client_ip": "220.64.111.219",
"oc": "user_id",
"status": "success",
"status_code": 200,
"result": { ... }
}
Features:
Converting Old Raw Logs:
uv run python -m lexlink.log_processor input.jsonl output.jsonl
Solution: Set your OC identifier using one of the three methods above.
Solution: Ensure your terminal supports UTF-8:
export PYTHONIOENCODING=utf-8
Solution: Increase timeout via environment variable:
export LEXLINK_TIMEOUT=90 # Increase from default 60s
Solution: Re-sync dependencies:
uv sync --reinstall
Contributions are welcome! Please:
git checkout -b feature/amazing-feature)uv run pytest)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is open source. See LICENSE file for details.
New: Caching, Law Name Resolution, Chain Tools (Phase 9)
cache.py): search 1hr, articles 24hr, AI search 30minresolver.py): 52 seed aliases + dynamic learningchain_full_research, chain_amendment_track, chain_dispute_prep, chain_law_system, cache_statsMajor Release: Phase 7 Tools, JSON Default, sections Parameter
sections="summary" parameter for case law service tools_helpers.pyRefactor: Remove Smithery Dependency
smithery package and 8 transitive dependenciesstdio_server.py entry point for stdio transportFor the full changelog (v1.0.0 – v2.1.0), see CHANGELOG.md.
Powered by MCP
radiovisual/zoekt-mcp
rafa/minhamorada-pt
rafsilva85/skillflow
rafsilva85/skillflow-b3c0273d
ramboweb3/hivecast-x711
ravi8585/zgts-derma-roller