Skip to main content
Glama

MFDS-MCP — 식약처 법령·지침서 정제 검색 MCP

식약처(MFDS)의 법령정보(게시판 m_203)와 공무원 지침서/민원인 안내서(게시판 m_1059)를 크롤링·캐시하고, RA(인허가) 업무에서 "현행/최신 추정본을 근거와 함께" 검색·반환하는 MCP 서버.

Context7가 최신 라이브러리 문서를 정확히 뽑아주듯, 식약처 자료에서 폐지·구버전을 걸러 현행 추정본을 제공한다. 단, 현행임을 단정하지 않고 상태·근거·신뢰도를 함께 반환한다 (잘못된 "현행" 단정은 검색 실패보다 위험하다).

핵심 동작

  • 두 게시판 크롤링 (공개 API 없음 → HTML 크롤 + 첨부 파싱)

    • m_1059 지침서: view.do?seq=N 상세 + HWP/HWPX/PDF 첨부가 실제 내용 → 핵심 큐레이션 영역

    • m_203 법령: 각 항목이 외부 law.go.kr 로 연결되는 개정공포 피드

  • 첨부 전문 텍스트 추출 → SQLite FTS5(trigram) 한국어 전문검색

  • 버전 그룹핑 + 상태 판정: current / superseded / future / repealed / unknown + 근거 + 신뢰도

Related MCP server: LexLink

⚠️ 법령(m_203) 기능의 한계 (중요)

m_203은 개정공포 피드이지 현행 법령 본문 DB가 아니다. 따라서 본 서버의 법령 검색은 **"개정공포 검색"**이며, 각 결과의 법령 현행 여부는 항상 law_currency = "unknown"으로 반환하고 law.go.kr 원문 링크로 확인하도록 안내한다. "옛 시행령 필터링(현행 본문 제공)"의 완성은 Phase 2: law.go.kr 현행법령 공개 API 연동(무료 OC키)에서 이뤄진다.

설치

uv sync            # 또는: pip install -r requirements.txt

레거시 .hwp 전문추출 품질을 높이려면 (선택, 없어도 olefile+zlib 네이티브 경로로 동작):

uv sync --extra hwp

실행 / 등록

로컬(Claude Desktop, stdio):

uv run mcp_server.py

Claude Desktop/Code 설정은 mcp.json.example 참고. DB 경로는 MFDS_DB_PATH(선택, 기본 mfds_cache.db).

원격(Claude.ai 웹 + Desktop, 클라우드): → DEPLOY.md 참고. Prefect Horizon(구 FastMCP Cloud, 콘솔 horizon.prefect.io)에 GitHub 레포를 연결하면 https://<이름>.fastmcp.app/mcp URL이 생기고, Claude 설정 → 커넥터에 등록하면 웹/데스크톱 어디서나 쓸 수 있다. 엔트리포인트는 mcp_server.py:mcp. 임시 파일시스템 대응으로 시드 DB(mfds_seed.db) + 서버 내 백그라운드 자동 크롤을 사용한다.

로컬 HTTP 테스트:

MFDS_TRANSPORT=http MFDS_HTTP_PORT=8000 uv run mcp_server.py   # http://localhost:8000/mcp

데이터 적재 (운영 작업, 검색과 분리)

검색 도구는 읽기 전용이다. 데이터 적재/갱신은 별도 운영 명령으로 실행한다:

uv run admin.py refresh m_1059 --max-pages 5
uv run admin.py refresh m_203  --max-pages 5
uv run admin.py reindex            # FTS 재색인
uv run admin.py status             # 진단(문서수/파싱실패율/마지막 크롤)

(MCP 도구 mfds_refresh 로도 가능하나 느리고 쓰기 작업이므로 권장하지 않음.)

MCP 도구

도구

용도

mfds_search_guidelines

지침서(m_1059) 전문검색, 현행본 우선 + 상태/근거

mfds_search_law_notices

법령(m_203) 개정공포 검색 + law.go.kr 링크

mfds_get_document

단일 문서 조회 (meta/full/페이지 청크)

mfds_latest_version

주제→현행 후보 + 근거·신뢰도 + 이력

mfds_version_history

그룹 전체 판본·상태 감사(audit)

mfds_list_recent

최근 제·개정 모니터링

mfds_extract_section

키워드 주변 발췌 + 출처(첨부·페이지)

mfds_status

진단(크롤 시각·문서수·파싱실패율)

mfds_refresh

(쓰기) 크롤·갱신 — 운영용

출처 / 이용

데이터 출처: 식품의약품안전처(www.mfds.go.kr). 크롤링은 보수적 호출 빈도로 수행하며, 공공누리 등 출처 이용조건을 준수한다. 본 도구는 참조 보조용이며, 규제 판단의 최종 확인은 반드시 원문(첨부 원본 / law.go.kr)으로 해야 한다.

구조

mfds_client.py   HTTP 크롤 (목록/상세/첨부 다운로드, charset·UA·백오프·DOM검증)
parsers.py       HWP/HWPX/PDF → 텍스트 (+페이지경계, 품질점수)
versioning.py    그룹핑·상태판정·근거/신뢰도
db.py            SQLite upsert/FTS/조회 + override 반영
services.py      중수준: 크롤+캐시, 검색, 최신버전 해석
mcp_server.py    FastMCP(v2/v3) 도구 등록 + 백그라운드 자동크롤 (엔트리포인트 mcp_server.py:mcp)
admin.py         운영 CLI (refresh/reindex/status/override)
selftest.py      결정적 단위테스트 + 라이브 스모크
schema.sql       SQLite 스키마 (FTS5 trigram)
mfds_seed.db     시드 데이터 (배포 직후 즉시 검색용; 런타임 캐시는 mfds_cache.db)
DEPLOY.md        클라우드/원격 배포 가이드

Available Tools

9 tools
mfds_extract_sectionB
Read-only

긴 지침서 본문에서 키워드 주변 섹션만 발췌(출처 첨부명 포함).

Inputs: board (required), seq (required), keyword (required), window. Returns: object

mfds_get_documentA
Read-only

단일 문서 조회. 컨텍스트 절약을 위해 part='meta'(기본) 또는 'full'.

Inputs: board (required), seq (required), part, max_chars. Returns: object

mfds_latest_versionA
Read-only

주제/제목으로 현행 지침서 후보 1건을 근거·신뢰도와 함께 해석 + 판본 이력.

반환: current(현행 추정본), current_confidence, alternatives, version_history. ⚠ current 는 자동 추정. confidence 낮거나 status=unknown 이면 원문 확인 필수.

Inputs: title_or_topic (required), domain. Returns: object

mfds_list_recentA
Read-only

최근 제·개정 모니터링. board별 최근 문서를 게시일 내림차순으로.

Inputs: board (required), days, domain, limit. Returns: object

mfds_refreshA
Idempotent

[운영/쓰기] 게시판 크롤 → 첨부 파싱 → 적재 → 상태 재판정. 느릴 수 있음.

Inputs: board (required), max_pages, full. Returns: object

mfds_search_guidelinesA
Read-only

식약처 공무원 지침서/민원인 안내서(m_1059) 전문검색. 현행 추정본 우선.

Inputs: query (required), domain, current_only, include_superseded, +1 more. Returns: object

mfds_search_law_noticesA
Read-only

식약처 법령 '개정공포' 검색(m_203). ⚠ 현행 법령 본문이 아님.

각 항목은 law.go.kr 로 연결되는 개정공포 알림이며, 공포번호(anc_no)·공포일(anc_date)· 시행일(ef_date)·law_go_kr_url 을 제공한다. 법령의 현행 시행 여부(law_currency)는 항상 'unknown' 으로 반환하므로 반드시 law_go_kr_url 원문으로 확인하라.

Inputs: query, law_name, since_date, limit. Returns: object

mfds_statusB
Read-only

진단: board별 문서 수·상태 분포·첨부 파싱 실패·마지막 크롤 시각·구조 경고.

Inputs: no named parameters. Returns: object

mfds_version_historyB
Read-only

특정 문서가 속한 버전 그룹의 전체 판본·상태·판정근거(audit 뷰).

Inputs: board (required), seq (required). Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool targets a distinct operation: extracting sections, retrieving documents, finding latest versions, listing recent updates, refreshing data, searching guidelines, searching law notices, checking status, and viewing version history. There is minimal overlap.

    Naming Consistency3/5

    All tools share the 'mfds_' prefix, but the naming pattern is inconsistent: some use verb_noun (extract_section, get_document, search_guidelines), while others use noun phrases (latest_version, status, version_history) or verb_adj (list_recent). This could confuse an agent expecting a uniform pattern.

    Tool Count5/5

    With 9 tools, the server is well-scoped for the domain of MFDS document and law notice access. The count feels appropriate without being overwhelming or too sparse.

    Completeness3/5

    The server covers key reading and searching operations, but has notable gaps: there is no tool to retrieve actual current law text (only amendment notices with 'unknown' currency) and no browsing or listing of all documents beyond recent ones. Core workflows are supported but incomplete.

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables searching and retrieving Korean legal information including laws, court precedents, legal interpretations, and local ordinances from the Korean National Law Information Center API with intelligent search ranking.
      -
    • F
      license
      A
      quality
      B
      maintenance
      Enables AI systems to search, retrieve, and analyze Korean legal information from the National Law Information API (law.go.kr), including laws, administrative rules, English translations, and law-ordinance linkages.
      26
      2
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables real-time search and analysis of Korean laws, legal precedents, and administrative rules through the National Law Information Center Open API, allowing AI agents to access official legal information for contract review, compliance, and legal research.
      74
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI to search and retrieve South Korean legal information from the National Law Information Center. It allows users to look up specific laws, articles, and detailed legal provisions using natural language queries.
      133
      -