Skip to main content
Glama
legal-search-mcp

legal-search-mcp

by LimEulYoung

Legal Search MCP

English | 한국어

Korean case law, statutes and sentencing data as MCP tools. Connect an AI client to find judgments, look up statutes as of a date, check what a judgment held in its own words and gather the statutory penalties, guideline ranges and actual sentences for a case's charges.

Five read-only tools:

Tool

What it does

precedent_search

Find judgments by facts, charge, court, year or case number

precedent_dive

Read one judgment body and answer a question about it

statute_search

Find statutes, administrative rules and tax treaties by name or keywords; a statute named with article numbers returns those articles

statute_read

Read a found statute's articles, current or as of a date, or list its article titles

sentencing_analysis

Statutory penalties, guideline ranges and factors, and first-instance sentences for one charge or several

This repository publishes the MCP tools used by 로풀 (Lawful), a free Korean legal-AI service. The tools in src/lawful_mcp/harness_local are the code the hosted service runs, copied unchanged; this repository adds a server you can run yourself and a sample corpus. The web application and hosted Agent API are maintained separately. The research prototype and benchmark archive live in legal_mcp — see Paper.

Quick start — hosted

The hosted service provides the full corpus, including statute amendment history, with no rate limits. Three ways to connect:

Claude / ChatGPT on the web — no code. Add a custom connector with this URL, sign in with OAuth when asked, and the five tools appear. No API key needed:

https://mcp.crow-tit.com/mcp

Step-by-step with the exact menu clicks: crow-tit.com/docs#mcp

Claude Code — one command, with a free key from console.crow-tit.com:

claude mcp add --transport http lawful https://mcp.crow-tit.com/mcp \
  --header "Authorization: Bearer ct_..."

Clients with HTTP MCP configuration — use the same key. Configuration formats vary; for clients that accept an mcpServers HTTP entry:

{
  "mcpServers": {
    "lawful": {
      "url": "https://mcp.crow-tit.com/mcp",
      "headers": { "Authorization": "Bearer ct_..." }
    }
  }
}

Related MCP server: Korean Law MCP

Quick start — self-host

Requires Python 3.11+. Install in a virtual environment; the bundled sample works without API keys:

git clone https://github.com/LimEulYoung/lawful-mcp
cd lawful-mcp
python3 -m venv .venv
.venv/bin/python -m pip install -e .

For a local stdio client, replace the path below with the absolute path to your clone. The client starts the server:

{
  "mcpServers": {
    "lawful-mcp": {
      "command": "/absolute/path/to/lawful-mcp/.venv/bin/lawful-mcp"
    }
  }
}

For HTTP at http://127.0.0.1:8100/mcp, run:

.venv/bin/lawful-mcp --transport http --port 8100

The self-hosted server has no authentication or usage metering. Access control for a shared HTTP endpoint belongs to your deployment.

Configuration and data flow

Settings are listed in .env.example. The server reads process environment variables; it does not load .env automatically. Export values in the launching shell or set them in your MCP client's env configuration.

With the defaults, four tools run locally against the corpus. precedent_dive additionally sends the selected public judgment text, case metadata and the supplied question to your configured model endpoint. Keep that question limited to issues in the public judgment.

export DIVE_API_KEY=...
export DIVE_BASE_URL=https://api.openai.com/v1   # any OpenAI-compatible endpoint
export DIVE_MODEL=...

All three values are required to register precedent_dive. Without them, the other four tools still work. Restart the server after changing settings.

precedent_search also takes an optional issue: the legal question the search is meant to answer. With JEV_API_KEY (an OpenRouter key) set, it sends each candidate's result block — public case metadata, holding and preview — and that question to OpenRouter's Jev endpoint, and returns the cases that decided the question first. Without the key, or when a request fails or takes longer than 1.5 seconds, results keep their keyword order.

Check the installation

The tests use the bundled sample and constructed test data; no network or model keys are needed:

.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/python -m pytest tests/ -q

The corpus

The tools read one SQLite file. The bundled sample is about 49 MiB:

Sample (data/fixture.db)

Hosted

Judgments

600

220,000+

Statutes

27 core laws, current text and addenda

All, with amendment history

Administrative rules

20

All

Tax treaties

3 partners and the multilateral conventions, 7 documents

All

Sentencing guidelines

Complete

Complete

Charge taxonomy

Complete

Complete

The sample supports local trials and testing. Use the hosted service for the full corpus, or set CORPUS_DB to a compatible database you maintain.

The sample holds each law as in force on the day it was built: amendments taking effect later and earlier wordings are left out, so lookups as of another date need the hosted corpus.

Statute lookups distinguish repeal from loss of effect, such as expiry, when the corpus supplies that information. The sample's lapse register is empty; those rules are covered by constructed test data.

A tax treaty comes with every document of the same partner and the multilateral conventions, in order of entry into force. The official source has no consolidated text and records no termination, so the lookup does not say which wording is current.

Default search combines trigram and Kiwi morpheme indexes using reciprocal rank fusion. The morpheme index makes two-character charge names such as 사기, 절도 and 폭행 searchable.

Judgments are non-copyrightable under Article 7 of the Korean Copyright Act. Court and case-number provenance is preserved in the data.

Building your own

scripts/build_sample_db.py extracts a sample from an existing compatible corpus and rebuilds its search indexes. It also documents the schema: every table is created from the source's definition, and the build stops if one the tools read is missing. It does not download the hosted corpus:

.venv/bin/python scripts/build_sample_db.py --source /path/to/corpus.db \
    --dest my_sample.db --cases 5000 --statutes all

Paper

The retrieval and tool-use design was evaluated on the Korean Bar Examination:

Agentic RAG for Legal Question Answering in Civil Law: Evidence From the Korean Bar Examination Eul Young Lim and Jihun Park IEEE Access, vol. 14, pp. 124441–124458, 2026. doi:10.1109/ACCESS.2026.3722717 — open access

Benchmark code, questions and per-model results are archived in legal_mcp. If you use this tool in research, please cite the paper (CITATION.cff).

Also available

  • Lawful Agent API — one question in, a grounded answer out. crow-tit.com

  • 로풀 (Lawful) — the free consumer service, 법률AI: chat, search, labour calculators, legal document drafting. lawful.crow-tit.com

Notes

This is a search tool over public legal sources, not legal advice. What it returns is source material and statistics; deciding what they mean for a particular matter is a lawyer's job.

Development happens in a private repository and lands here in batches, so issues are welcome but pull requests may be merged by hand rather than through the button.

Report vulnerabilities privately using SECURITY.md. Code is MIT licensed.

Available Tools

4 tools
compute_sentencing_rangeA
Read-onlyIdempotent

통합 양형 도구 — 죄명에서 법정형→처단형→권고형→선고 검증까지, 인자를 채울수록 깊은 단계로 자동 진행: charge만=lookup(법정형·권고범위·인자 enum) / +statutory_modifications=처단형(형법§56 순서 적용) / +guideline_type·guideline_factors=권고형 / +sentence_months·fine_amount(+probation_factors)=final(선고형·집행유예 검증). 결과는 양형기준이 정한 '범위'(예측 아님). 호출 간 상태가 없으므로 후속 호출마다 charge와 확정 선택·플래그·offense_date를 반복하고 새 인자를 추가. Args: charge=판결문형 죄명 문자열(예 '살인','도로교통법위반(음주운전)') — 호출당 하나(여러 죄는 각각 호출; list면 죄명별 유도[multiple_charges]), 숫자·ID 불가(조문번호·charge_id 아님; 숫자면 유도[charge_numeric]). offense_date=행위 일자(지정 시 행위시 조문). sg_category_id·statute_choice·branch_key·reference_choice=ambiguous_* 응답이 후보를 줄 때. is_attempted·is_accessory·is_solicitor=미수·방조·교사. statutory_modifications=가중감경 list(lookup enum에서). guideline_type·guideline_leaf_id·guideline_factors=권고유형(lookup 목록 명칭 그대로)·leaf_id·특별인자. sentence_months=검증 선고형(자유형·월)·fine_amount=벌금(원)·probation_factors=집행유예 인자(dict). act_count=동종 다행위 수(≥2면 경합범 가중 자동). 후속 단계 값은 이전 응답 enum에 있는 key만 쓰고 추측 금지. 응답의 '출처'(해설서 PDF)가 있으면 인용 링크로 제시.

Inputs: charge (required), act_count, branch_key, fine_amount, +13 more. Returns: result

sentence_statisticsA
Read-onlyIdempotent

양형 선고 통계 — charges 또는 charge_id 중 하나는 필수. ① charges 하나로 정제된 죄명 후보(charge_id+표본수)를 반환(status=candidates), ② 후보에서 고른 charge_id 하나를 주면 그 죄명 하나만 유죄인 피고인의 1심 선고 분포(표본 30↑=형종별 평균·표준편차·집유율 + 11분위 비교판례 / 미만=개별 사례 그리드). 죄명이 이미 특정되면 곧바로 통계가 옵니다. 형량 전망·구형/양형 근거·자기 사건 위치를 가늠할 때 결론 전에 호출(compute_sentencing_range 공식 '범위'를 실데이터로 보완). status=candidates는 통계가 아니라 선택지 — 사안에 맞는 charge_id 하나로 재호출. 죄명·charge_id는 한 번에 하나씩. 경합 사안의 죄명별 단독 분포를 합산·평균·1.5배해 경합범 분포로 만들지 마세요. 형법 38조는 가장 중한 죄 장기(벌금은 다액)의 1/2까지 가중하되 각 죄 장기·다액 합계를 넘지 못하게 하는 처단형 상한이지 통계 결합식이 아닙니다. status=low_n_grid는 단독 개별 사례라 일반화 금지. Args: charges=죄명 텍스트 하나(후보 검색용; 구어 '보이스피싱·몰카·마약'·카테고리 '성범죄'·법률명 '도로교통법위반'도 인식). charge_id=후보에서 고른 pool id 하나(int; 통계 조회용, charges와 택일). year_from/year_to=판결 연도 범위. reference_year=비교 판례·그리드 기준 연도(가까운 사건 우선; None=최근). 비교 판례·그리드의 url만 인용 링크로, 집계 분포 수치는 링크 없이 제시.

Inputs: charges, year_to, charge_id, year_from, +1 more. Returns: result

statute_lookupA
Read-onlyIdempotent

법령·행정규칙 조회 — 법령의 요건·효과·기간·절차가 답의 뼈대가 되는 국면의 기본 도구이며, 죄명·법조 식별 후 조문 본문 확인에도 씁니다. 조문은 개정되므로 현행 본문은 이 도구만 압니다. 법률·대통령령·부령·규칙과 행정규칙(고시·훈령·예규)을 한 번에 검색합니다 — 종류를 가리는 인자는 없고 관련도 순으로 함께 나오며 각 결과에 종류가 붙습니다. 자주 쓰는 법령은 quick-access id로 바로 호출(statute_id+articles): 헌법 468·민법 584·상법 583·민사소송법 581·형법 578·형사소송법 574·행정기본법 4953·행정절차법 437·행정소송법 386·헌법재판소법 3629. query 또는 statute_id가 필수. 그 외는 two-step — ① query=법령명으로 후보 id를 받고 ② statute_id+articles로 본문 호출(조문 번호는 법령마다 달라 법령을 먼저 확정). Args: query=법령명·행정규칙명 또는 본문 키워드(id 모를 때). statute_id=검색이 준 식별자를 글자 그대로 — 법령은 정수(예 584; 위 목록 밖은 추측 금지 — 574는 형사소송법), 행정규칙은 'admrul-18060'. 접두사를 떼면 같은 번호의 다른 법령이 조회됩니다. articles=조문 번호 list[str] 최대 8개('347'/'제347조'=본조+가지, '347의2'=가지만, 범위 ['3','4','5']; 미지정 시 outline; 8개 초과는 앞 8개만 조회하고 나머지를 message로 알림 — 나눠 재호출). limit=검색 모드 최대 결과 수(기본 10·최대 50). offense_date=행위 일자(예 '2013.7.30') 지정 시 행위시점 조문, 미지정 시 현행. url만 인용 링크로 쓰고, text_kind: 공식 … 원문인 조문·행정규칙 본문만 직접인용하세요.

Inputs: limit, query, articles, statute_id, +1 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool targets a distinct resource: precedents, statutes, empirical sentencing data, and guideline-based range calculation. The sentencing pair is explicitly differentiated, with compute_sentencing_range producing guideline ranges and sentence_statistics providing real case distributions.

    Naming Consistency3/5

    All names are lowercase snake_case and readable, but they mix conventions: precedent_search and statute_lookup are object+verb, sentence_statistics is a noun phrase, and compute_sentencing_range is verb+object. The pattern is not predictable enough for an agent to infer a new tool's name.

    Tool Count5/5

    Four tools is well-scoped for a legal research and sentencing assistant. Each tool is broad and complex enough to justify its place, with no redundant tools.

    Completeness2/5

    The set covers statutes and sentencing well, but precedent_search explicitly instructs callers to continue with precedent_dive, which is not exposed in the tool list. This creates a dead end for full-text precedent access and is a significant gap for the stated legal-research purpose.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers