Content
[](https://lobehub.com/mcp/seonaru-lexguard-mcp)




# Tool List
> **A Korean legal information integration server that connects laws, precedents, and interpretations in an AI-friendly format.**
>
> Based on official data from the Open Law Information Center, it provides laws, articles, precedents, interpretations, administrative appeals, and constitutional judgments in **a single query flow**.
- **Execution Method**: A self-hosted MCP server that runs directly with your own Open Law Information Center API key (no separate hosting service)
- **GitHub**: [https://github.com/SeoNaRu/lexguard-mcp](https://github.com/SeoNaRu/lexguard-mcp)
### Quick Start (5 minutes)
1. **API Key Issuance** — Free issuance available at [open.law.go.kr](https://open.law.go.kr). **Your IP registration** is required (see [API Key Issuance](#api-key-issuance-essential) below)
2. **Server Execution**
```bash
git clone https://github.com/SeoNaRu/lexguard-mcp
cd lexguard-mcp
cp .env.example .env # Set LAW_API_KEY=issued key
docker compose up --build # or: pip install -r requirements.txt && python -m src.main
```
3. **Client Connection** — MCP URL: `http://localhost:9099/mcp`
- Cursor: Merge the contents of [`examples/cursor-mcp.local.json`](examples/cursor-mcp.local.json) into `.cursor/mcp.json`
- Claude Desktop: Merge [`examples/claude-desktop-mcp.local.json`](examples/claude-desktop-mcp.local.json) into `mcpServers` of `claude_desktop_config.json` (Node.js required)
Static metadata for marketplace and crawler: [`mcp/manifest.json`](mcp/manifest.json) · Prompt index [`prompts/`](prompts/) · Resource URI guide [`resources/README.md`](resources/README.md) · Cursor development skills [`.cursor/skills/lexguard-mcp-dev/SKILL.md`](.cursor/skills/lexguard-mcp-dev/SKILL.md)
---
## Why LexGuard?
The law often seems distant and difficult to understand when we need it.
High costs, unfamiliar terms, and complex structures.
**LexGuard MCP** starts with this problem.
- Users ask questions in **natural language**
- AI analyzes the intent of the question
- Provides **official law and precedent data** as a clue
> Not intended to replace judgment or legal advice.
> However, it aims to make **the first encounter with the law less difficult**.
---
## Core Features
| Feature | Description |
|------|------|
| **18 MCP Tools** | Covers all areas from integrated QA to ministry-specific interpretations, law history, and linked queries |
| **Integrated Legal QA** | Parallel comprehensive search for laws, precedents, interpretations, administrative appeals, and constitutional judgments |
| **Article Precise Query** | Direct query of specific articles by law name and article number |
| **Document and Contract Analysis** | Automatic detection of legal issues for each clause by pasting contracts and terms |
| **Precedent Number Direct Detection** | Automatic recognition and immediate search in the format of `2023da12345`, `2021heonma123` |
| **Automatic Domain Classification** | 10 legal domains such as labor, personal information, real estate, consumer, tax, and finance |
| **Natural Language Time Conditions** | Automatic parsing of natural language time expressions such as "last 3 years", "after 2023" |
| **Reranker Pipeline** | Reorders search results based on query relevance (BM25 + Keyword Hybrid) |
| **Parallel Search** | Minimizes response speed with multi-API concurrent calls based on `asyncio.gather` |
| **Rate Limiting** | IP-based 600 req/min limit (default, adjustable with `LEXGUARD_MCP_RATE_LIMIT`) |
---
## MCP Tools
### `legal_qa_tool` — General Legal QA
A single entry point for all legal questions. It searches and integrates laws, precedents, interpretations, and committee decisions with a single question.
**Capabilities**
- Automatic classification of 10 domains
- Multi-detection and prioritization of question intent
- Parallel search for laws, precedents, interpretations, and committee decisions
- Natural language time condition filtering (`date_from` / `date_to` automatic conversion)
**Input Schema**
| Parameter | Type | Required | Description |
|---------|------|------|------|
| `query` | string | ✅ | User's legal question |
| `max_results_per_type` | integer | — | Maximum number of results per type (default: 3, maximum: 10) |
**Example Prompts**
```
Are there any precedents where freelancers are recognized as workers?
Please provide precedents on unfair dismissal for the last 3 years.
What are the legal consequences of personal information leakage?
Find the precedent 2023da12345.
```
---
### `law_article_tool` — Precise Law Article Query
Directly queries specific articles when the law name and article number are known. While `legal_qa_tool` is "search", this tool is "precise query".
**Input Schema**
| Parameter | Type | Required | Description |
|---------|------|------|------|
| `law_name` | string | ✅ | Law name (e.g., Labor Standards Act, Civil Act) |
| `article_number` | string | — | Article number (e.g., `50`, `2`). Omitted returns law overview |
| `hang` | string | — | Sub-article number (e.g., `1`, `2`) |
| `ho` | string | — | Section number (e.g., `1`, `2`) |
| `mok` | string | — | Item number (e.g., `a`, `b`) |
**Example Prompts**
```
Please provide the content of Article 50 of the Labor Standards Act.
What is Article 750, Section 3 of the Civil Act?
```
---
### `law_comparison_tool` — Law Comparison and History
Queries new and old law comparisons, histories, and three-stage comparisons based on the law name.
**Input Schema**
| Parameter | Type | Required | Description |
|---------|------|------|------|
| `law_name` | string | ✅ | Law name (e.g., Criminal Act, Civil Act) |
| `compare_type` | string | — | `new_vs_old_law` · `history` · `three_stage_comparison` (default: `new_vs_old_law`, uses the corresponding value if present in the question) |
**Example Prompts**
```
Please compare the new and old Labor Standards Act.
Show the history of the Civil Act.
```
---
### `document_issue_tool` — Contract and Terms Analysis
Analyzes documents and extracts legal issues by clause, and automatically searches for relevant laws and precedents.
**Input Schema**
| Parameter | Type | Required | Description |
|---------|------|------|------|
| `document_text` | string | ✅ | Contract or terms text |
| `auto_search` | boolean | — | Automatic law search for each clause (default: true) |
| `max_clauses` | integer | — | Maximum number of clauses to analyze (default: 3) |
| `max_results_per_type` | integer | — | Maximum number of results per type (default: 3) |
**Supported Document Types**
- `labor` — Employment contract / Service contract
- `lease` — Lease agreement
- `terms` — Terms and conditions
**Example Prompts**
```
Please check if there are any issues with this freelancer contract.
Identify unfavorable clauses in the lease agreement below.
```
---
### `health` — Server Status Check
Checks the MCP server operation, API key configuration, and environment variables.
---
### Specialized Search Tools (Limited Sources)
Used when searching for **specific data only**, instead of integrated search (`legal_qa_tool`).
| Tool Name | Purpose | Main Input |
|---------|------|-----------|
| `precedent_lookup_tool` | Precedents only | `keyword` or `case_number` |
| `interpretation_tool` | Interpretations and authoritative interpretations, etc. | `query`, optional `agency` |
| `administrative_appeal_tool` | Administrative appeals decisions only | `query`, optional period |
| `constitutional_decision_tool` | Constitutional Court decisions only | `query`, optional period |
| `committee_decision_tool` | Independent committee decisions | `committee_type`, `query` |
| `special_administrative_appeal_tool` | Special administrative appeals decisions | `tribunal_type`, `query` |
| `local_ordinance_tool` | Local ordinances (ordinances, etc.) only | `query` or `local_government` |
| `administrative_rule_tool` | Administrative rules only | `query` or `agency` |
---
### Extended Query Tools
Used when additional information, history, forms, and links are needed.
#### `ministry_interpretation_tool` — Ministry-specific Interpretations
Searches a database of interpretations (inquiries and responses) specific to 39 ministries.
| Parameter | Type | Description |
|---------|------|------|
| `query` | string | Search keyword |
| `agency` | string | Ministry name (e.g., `Ministry of Employment and Labor`, `National Tax Service`, `Ministry of Health and Welfare`) |
| `page` / `per_page` | integer | Page settings |
Supported Ministries: Ministry of Employment and Labor, Ministry of Land, Infrastructure and Transport, Ministry of Strategy and Finance, National Tax Service, Korea Customs Service, Ministry of Education, Ministry of Health and Welfare, Ministry of Justice, Office of Legislative Affairs, Korea Food and Drug Administration, National Police Agency, National Fire Agency, Korea Coast Guard, and 39 other agencies
---
#### `law_history_tool` — Law and Article Change History
Tracks changes to laws and articles.
| `search_type` value | Description |
|-----------------|------|
| `law_change` | List of law change history |
| `article_change` | List of article change history by date |
| `article_detail` | Detailed change history of a specific article (`law_id` required) |
**Example Prompts**
```
Please provide the revision history of the Labor Standards Act.
The revision history of Article 17 of the Personal Information Protection Act.
```
---
#### `law_info_tool` — Law Supplementary Information
Queries supplementary information such as English laws, international treaties, law structure diagrams, and abbreviations.
| `info_type` value | Description |
|--------------|------|
| `english_law` | English law |
| `treaty` | International treaties |
| `structure` | Law structure diagram |
| `oneview` | Law summary (one-view) |
| `abbreviation` | Law abbreviation |
| `deleted` | Deleted laws and articles history |
---
#### `law_form_tool` — Form and Appendix Search
Searches for forms and appendices of laws, administrative rules, and local ordinances by form name or related law name.
| `form_type` value | Description |
|--------------|------|
| `law` | Law forms and appendices |
| `admin_rule` | Administrative rule forms and appendices |
| `ordinance` | Local ordinance forms and appendices |
---
#### `law_link_tool` — Law and Local Ordinance Link Query
Checks the list of linked ordinances, the status by ministry and local government.
| `link_type` value | Description |
|--------------|------|
| `law_to_ordinance` | Law-local ordinance link list |
| `ordinance_articles` | Ordinance article list by linked law |
| `by_department` | Linked law list by ministry |
| `linked_ordinance` | Linked ordinance list |
| `law_linked_ordinance` | Linked ordinance list by law |
| `by_region` | Linked ordinance list by region |
---
## MCP Prompts
Supports `prompts/list` and `prompts/get` endpoints.
| Prompt Name | Description |
|-------------|------|
| `legal_basis_answer` | Requests answers including relevant law articles and precedent summaries |
| `precedent_summary` | Summarizes precedents into facts / issues / judgments |
| `contract_risk_check` | General contract/terms risk clause check. **High-density review for labor/service contracts** uses `labor_contract_review` or `document_issue_tool` (when document is classified as labor) |
| `labor_contract_review` | Review of labor/service contract clauses (Type B) |
| `legal_qa` | Explains legal perspectives on specific situations |
---
## MCP Resources
Supports `resources/list` and `resources/read` endpoints.
### URI Scheme
| Format | Description | Example |
|------|------|------|
| `law://{law_name}` | Law text query | `law://LaborStandardsAct` |
| `case://{search_term}` | Precedent search (top 5) | `case://unfair dismissal` |
| `interpret://{search_term}` | Interpretation search (top 5) | `interpret://worker_status` |
### Featured Resources (Provided by Default)
Major laws such as the Labor Standards Act, Civil Act, Criminal Act, Personal Information Protection Act, Commercial Act, National Public Officials Act, and Administrative Litigation Act can be queried immediately.
---
## Installation
### Method 1. Local (Python)
```bash
git clone https://github.com/SeoNaRu/lexguard-mcp
cd lexguard-mcp
pip install -r requirements.txt
cp .env.example .env # Set LAW_API_KEY
python -m src.main
```
### Method 2. Docker Compose (Recommended)
```bash
git clone https://github.com/SeoNaRu/lexguard-mcp
cd lexguard-mcp
cp .env.example .env # Edit LAW_API_KEY
docker compose up --build
```
MCP URL for browser/client: `http://localhost:9099/mcp` · Health check: `http://localhost:9099/health`
### Method 3. Docker (run only)
```bash
docker build -t lexguard-mcp .
docker run -p 9099:9099 -e LAW_API_KEY=your_key lexguard-mcp
```
### Client Connection
When the server is running locally, the MCP URL is `http://localhost:9099/mcp`.
**Cursor** (`.cursor/mcp.json`) — Same as [`examples/cursor-mcp.local.json`](examples/cursor-mcp.local.json) file:
```json
{
"mcpServers": {
"lexguard-mcp": {
"url": "http://localhost:9099/mcp"
}
}
}
```
**Claude Desktop** (`claude_desktop_config.json`) — Same as [`examples/claude-desktop-mcp.local.json`](examples/claude-desktop-mcp.local.json) file. Claude Desktop does not directly support local HTTP URLs, so use the `mcp-remote` bridge (Node.js required):
```json
{
"mcpServers": {
"lexguard-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:9099/mcp"]
}
}
}
```
> **Claude.ai Web Connector Guide**: The web connector requires a public HTTPS URL, so it cannot connect to a locally running server. We recommend using Claude Desktop or Cursor. If you must use it on the web, deploy it directly on your own server (fixed IP + HTTPS) and register that IP on open.law.go.kr.
### API Key Issuance (Required)
You need an Open API key from the National Law Information Center. Both issuance and usage are free.
1. Sign up at [https://open.law.go.kr](https://open.law.go.kr)
2. Apply for OPEN API usage — At this time, **register the IP or domain of the server (your PC) that will send requests**. law.go.kr only allows requests from registered IPs.
3. Set `LAW_API_KEY=issued_key` in `.env`
> **Caution with dynamic IP**: General home network connections may have changing IPs. If you get a `"User information verification failed"` error, re-register with the current IP in [open.law.go.kr → API authentication key management].
### DRF Scheme Selection
`lexguard-mcp` fixes the host/path of the National Law Information Center's DRF URL and allows the scheme to be selected with `.env`.
```env
LAW_GO_KR_DRF_SCHEME=https
```
- Allowed values: `http`, `https`
- Default value: `https`
- In restricted corporate networks/firewall environments, you may need a path like `http://www.law.go.kr/DRF/...` as per the official guide.
This setting is an option to adjust the latent URL-generation issue that might have been accidentally obscured by hardcoding `https` in general environments.
## Architecture
```
Client (Cursor / Claude)
│ JSON-RPC 2.0 over SSE
▼
FastAPI (/mcp POST)
│ Rate Limiting (slowapi, 600 req/min/IP default)
▼
MCP Routes (tools/call · prompts/get · resources/read)
│
▼
Services (SmartSearchService · SituationGuidanceService)
│ asyncio.gather (parallel multi-API calls)
▼
Repositories (Law · Precedent · Interpretation · Appeal · Constitutional …)
│ httpx (sync/async HTTP client)
│ TTLCache (search results 30 minutes / failures 5 minutes)
│ Exponential Backoff Retry
▼
National Law Information Center DRF API (159 entries / 88 unique targets)
```
**Search Pipeline**
```
Question input
→ Early detection of case number patterns (2023da12345 / 2021heonma123)
→ Domain classification + Intent analysis
→ Time condition parsing
→ asyncio.gather parallel API calls
→ Reranker (BM25 + Keyword Hybrid reordering)
→ Response formatting
```
**Main Technology Stack**
| Category | Technology Used |
|----------|------------------|
| Web Framework | FastAPI + Uvicorn |
| MCP Transport | Streamable HTTP (SSE) |
| HTTP Client | httpx (sync + async) |
| Cache | cachetools TTLCache |
| Rate Limiting | slowapi |
| Search Ranking | BM25 + Keyword Hybrid Reranker |
| CI/CD | GitHub Actions (Python 3.11 / 3.12) |
| Testing | pytest + pytest-asyncio |
## Development
```bash
# Run tests
pytest tests/ -v
# Lint
ruff check src/
# Local server (auto-reload)
RELOAD=true python -m src.main
```
## License
The full text is in the [`LICENSE`](LICENSE) file at the repository root.
- **Usage:** Like MIT, research, personal, commercial use, modification, distribution, and resale are allowed.
- **Selling / Paid provision:** If you sell this software alone or include it in a product/service, you must include **copyright notice and this license text** in materials (documents, credits/license screens, package metadata, etc.) delivered to end-users.
This guide is a summary, and the legal effect is governed by the `LICENSE` text.
## Contribution
Issues & PRs are always welcome.
We welcome legal domain data, search quality improvements, and new MCP tool ideas.
> **LexGuard MCP — Finding the thread of legal information.**
> The law is difficult, but the first thread can be easier.
MCP Config
Below is the configuration for this MCP Server. You can copy it directly to Cursor or other MCP clients.
mcp.json
Connection Info
You Might Also Like
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Agent-Reach
Give your AI agent eyes to see the entire internet. Read & search Twitter,...
Fetch
Retrieve and process content from web pages by converting HTML into markdown format.
Context 7
Context7 MCP provides up-to-date code documentation for any prompt.
context7-mcp
Context7 MCP Server provides natural language access to documentation for...
mempalace
The highest-scoring AI memory system ever benchmarked. And it's free.