npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

korea-law

v2.1.0

Published

Korea Law MCP Server - AI Legal Auditor for Korean Law Verification (한국 법률 MCP 서버)

Downloads

506

Readme

⚖️ korea-law

AI 법률 인용 환각 검증 MCP 서버 (Korean Law Verification MCP Server)

AI가 인용한 한국 법령·판례가 실제로 존재하고 정확한지, 국가법령정보센터(법제처) 공식 데이터로 검증합니다.

"Don't just trust AI's memory. Audit it against the current law."

npx korea-law 한 줄로 실행되는 stdio MCP 서버입니다. 별도 서버·계정 없이 법제처 무료 OC 키 하나만 있으면 됩니다.

  • 🔎 환각 감지: 인용 문자열 하나로 법령명·조문번호·조문 제목까지 대조 (TITLE_MISMATCH 판정)
  • 📜 개정 diff: 법제처 신구법 대비표 기반 조문 단위 개정 비교 (versions)
  • 🔤 약칭 확장: "화관법" → "화학물질관리법" 결정론적 확장 (공식·관용 약칭 사전)
  • 🧰 얇은 도구 표면: MCP에 10개 hub 도구만 노출, 내부 73개 도구는 메타 도구로 접근

🚀 빠른 시작 (Quick Start)

1. 법제처 OC 키 발급 (무료)

open.law.go.kr → 회원가입 → OPEN API 활용 신청. 발급되는 OC 키는 가입 이메일의 ID 부분입니다 (예: hong_gildong).

2. 실행

KOREA_LAW_API_KEY=<발급받은_OC키> npx -y korea-law

기본 실행은 stdio MCP 서버입니다. 아래 클라이언트 설정에 붙이면 끝입니다. (korea-law setup 으로 클라이언트 설정을 자동 구성할 수도 있습니다.)

3. 클라이언트 연결

Claude Code

claude mcp add -e KOREA_LAW_API_KEY=<OC키> korea-law -- npx -y korea-law

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "korea-law": {
      "command": "npx",
      "args": ["-y", "korea-law"],
      "env": { "KOREA_LAW_API_KEY": "<OC키>" }
    }
  }
}

Cursor (.cursor/mcp.json)

{
  "mcpServers": {
    "korea-law": {
      "command": "npx",
      "args": ["-y", "korea-law"],
      "env": { "KOREA_LAW_API_KEY": "<OC키>" }
    }
  }
}

🌐 원격 접속 — Streamable HTTP (serve)

stdio 대신 HTTP로 띄워 여러 클라이언트/서버에서 공유할 수 있습니다.

korea-law serve --port 8080
# POST /mcp    — JSON-RPC 2.0 (Streamable HTTP, stateless)
# GET  /health — { status, tools: { exposed: 10, total: 73 } }
# Claude Code 에서 HTTP 로 연결
claude mcp add --transport http --header "x-api-key: <OC키>" \
  korea-law http://localhost:8080/mcp

키 전달 우선순위 (4-way)

요청마다 아래 순서로 OC 키를 해석합니다. 헤더가 쿼리스트링보다 우선합니다 (쿼리 키는 프록시 액세스 로그에 남을 수 있어 후순위).

  1. x-api-key 헤더
  2. Authorization: Bearer <OC키> 헤더
  3. ?key= 쿼리 파라미터
  4. 서버 프로세스의 KOREA_LAW_API_KEY 환경변수

요청별 키는 서로 격리되므로, 한 서버를 여러 사용자가 각자의 OC 키로 쓸 수 있습니다.

내장 보호 장치

  • Rate limit: IP당 분당 tools/call 60회 기본 (KOREA_LAW_RATE_RPM). initialize/tools/list는 계수 제외.
  • 배치 상한: JSON-RPC 배치당 tools/call 20개 기본 (KOREA_LAW_MAX_BATCH).
  • 본문 크기 제한: 1MB 기본 (KOREA_LAW_MAX_BODY_BYTES), 초과 시 413.
  • 프록시 뒤 배포: 신뢰 프록시 뒤일 때만 KOREA_LAW_TRUST_PROXY=1X-Forwarded-For를 신뢰 (기본은 소켓 IP — 스푸핑 방지).

🧰 도구 표면 (10개)

MCP tools/list에는 10개만 노출됩니다. 내부 73개 도구는 list_capabilities로 탐색하고 invoke_capability로 실행합니다. (v1.x의 legacy 도구명 직접 호출도 하위호환으로 계속 동작합니다.)

| 도구 | 역할 | |---|---| | hub_research | 다단계 통합 리서치. flow로 유형 선택 (full / action_basis / compare_old_new / interpretation / annexes / delegation / similar_precedents / specialized) | | hub_audit | 통합 검증 허브. check로 종류 선택 (statute / enforcement / citation / references / compliance / amendment / versions / timeline / definition / hierarchy / daily_diff / case_exists) | | find_statute | 법령명·키워드로 현행 법령 검색 (RAG+CAG 하이브리드) | | read_statute | 특정 법령/조문 본문 조회 (약칭 자동 확장: "화관법 제23조" OK) | | find_rulings | 판례·심판·해석례 검색. domain으로 출처 선택 (precedent / tribunal / committee / ministry / ftc / tax / treaty / ordinance / english / labor) | | read_ruling | 심판·해석례·조약·자치법규 전문 조회 (domain + id — tribunal / committee / ministry / ftc / tax / treaty / ordinance / labor) | | read_annex | 법령 별표·별지서식 조회 (HWP → Markdown 변환, PDF만 제공되는 별표는 원문 링크 반환) | | search_corpus | Elasticsearch 법률 코퍼스 RAG 검색 (직접 ES 설정 시에만 활성) | | list_capabilities | 내부 도구 카탈로그 탐색 (카테고리별 73개, 키워드 필터) | | invoke_capability | 내부 도구를 이름으로 직접 실행 |

대표 시나리오 — AI 인용 환각 검증

AI가 생성한 인용 문자열을 그대로 넣으면, 법령명·조문번호에 더해 괄호 안 조문 제목까지 실제 조문과 대조합니다.

{
  "name": "hub_audit",
  "arguments": {
    "check": "citation",
    "citation": "근로기준법 제23조(정리해고의 절차)"
  }
}

조문은 존재하지만 인용된 제목이 실제 조문 제목과 다르면:

{ "status": "TITLE_MISMATCH", "verified": false, "...": "환각 의심 — 실제 조문 제목 동봉" }

verified는 3-state입니다 — true(일치) / false(불일치·환각 의심) / null(검증 불가). 법령 약칭도 결정론 사전으로 자동 확장되며, 애매한 이름은 재조회 대신 didYouMean 제안만 합니다 (내부 도구 expand_abbreviation으로 직접 호출 가능).

대표 시나리오 — 개정 전후 비교 (신구법 diff)

{
  "name": "hub_audit",
  "arguments": {
    "check": "versions",
    "law_name": "화학물질관리법"
  }
}

법제처 공식 신구법 대비표를 기반으로 최신 개정 이벤트의 조문 단위 추가/수정/삭제 diff와 provenance(공포일·시행일·원문 링크)를 반환합니다. 특정 개정 이벤트는 amendment_mst_id, 기간은 effective_date_from/to로 지정합니다.


⚙️ 환경변수 레퍼런스

| 변수 | 필수 | 기본값 | 설명 | |---|---|---|---| | KOREA_LAW_API_KEY | ✅ | — | 법제처 OC 키. 미설정 시 도구 호출이 명확한 에러로 즉시 실패 (fail-fast). serve 모드에서는 요청별 키(헤더/쿼리)로 대체 가능 | | KOREA_LAW_DB_PATH | | data/korea-law.db | 로컬 SQLite DB 경로 (korea-law sync로 생성) | | KOREA_LAW_REFERER | | https://www.law.go.kr/ | 법제처 API Referer 헤더. 자체 도메인으로 키를 등록했다면 그 도메인으로 지정 | | LAW_OC | | — | ⚠️ deprecated. 읽기는 되지만 경고 출력 — KOREA_LAW_API_KEY로 교체 | | KOREA_LAW_PROTOCOL | | https | 법제처 API 프로토콜 (https/http) | | KOREA_LAW_HTTPS_PROXY | | — | 폐쇄망용 CONNECT 프록시 (전용 변수, NO_PROXY 무시하고 강제) | | HTTPS_PROXY / HTTP_PROXY / NO_PROXY | | — | 표준 프록시 변수 지원 (소문자 포함) | | serve 전용 | | | | | PORT | | 8080 | HTTP 포트 (--port 플래그가 우선) | | KOREA_LAW_RATE_RPM | | 60 | IP당 분당 tools/call 상한 | | KOREA_LAW_MAX_BATCH | | 20 | JSON-RPC 배치당 tools/call 상한 | | KOREA_LAW_MAX_BODY_BYTES | | 1048576 | 요청 본문 최대 크기 | | KOREA_LAW_TRUST_PROXY | | — | 1이면 X-Forwarded-For 첫 홉을 클라이언트 IP로 신뢰 | | Elasticsearch (선택 — search_corpus) | | | | | ELASTICSEARCH_URL (또는 ELASTICSEARCH_ADDR) | | — | ES 엔드포인트. 미설정 시 search_corpus만 비활성, 나머지 도구는 정상 | | ELASTICSEARCH_USERNAME / ELASTICSEARCH_PASSWORD | | — | ES 인증 | | KOREA_LAW_CORPUS_INDEX | | legal_corpus_v1 | search_corpus가 조회할 ES 인덱스명 |


🖥 CLI

korea-law                      # (기본) stdio MCP 서버 시작
korea-law serve --port 8080    # Streamable HTTP MCP 서버
korea-law setup                # 클라이언트 설정 도우미
korea-law sync                 # 로컬 SQLite 법령 DB 수동 동기화
korea-law audit 근로기준법 제23조   # 조문 검증 (터미널에서 바로)
korea-law verify 2023다12345    # 판례 존재 확인
korea-law help

☁️ 호스티드 옵션 — Law Check 게이트웨이

직접 띄우지 않고 호스티드 게이트웨이를 쓸 수도 있습니다: law-check.com — 키 발급 대시보드, 사용량 집계, REST API를 제공합니다. 게이트웨이 키는 law-check.com 에서 발급하는 별도 키로, 이 패키지의 KOREA_LAW_API_KEY(법제처 OC 키)와는 다릅니다. 설정은 해당 사이트 가이드를 참조하세요.


⚠️ 법적 고지 (Disclaimer)

이 패키지는 AI 인용 검증용(verification) 도구입니다.

  • 반환 데이터는 AI 법률 인용의 정확성을 검증하기 위한 기준값입니다.
  • 법적 효력의 최종 판단은 반드시 국가법령정보센터(law.go.kr) 원문을 확인하세요.
  • 이 도구의 결과를 법률 자문으로 사용하지 마세요.
  • 개인 운영 오픈소스 프로젝트이며 특정 정부 기관과 무관합니다.

📄 라이선스

MIT