Skip to main content
Glama
ne-kosis-mcp

ne-kosis-mcp

by neneungyul2

ne-kosis-mcp

국가통계포털(KOSIS) OpenAPI를 쓰는 MCP(Model Context Protocol) 서버입니다. 인구, 지역별 학생 수, 사교육비 같은 통계를 찾고(find_table), 조회하고(kosis_data), 추이와 성장률을 계산하고(kosis_trend), 엑셀/CSV로 내보냅니다(kosis_export). 거시 트렌드와 시장 규모 파악이 목적입니다.

구조 참고: 설정, 캐시, 도구 허용 목록, 내보내기 구조는 ne-naver-api-mcp(원본: isnow890/naver-search-mcp, MIT License)에서 가져왔습니다. 원본의 저작권 고지는 LICENSE에 그대로 유지됩니다.

상태

  • 키 없이 검증한 것: 단위 테스트(가짜 응답), 기간 분할, 수치 파싱, 증감률·CAGR 계산, 카탈로그 검색, 서버 도구 등록.

  • 실제 KOSIS 호출로 아직 검증하지 못한 것: 응답 구조, 오류 형식(err/errMsg), 메타(getMeta ITM/OBJ) 응답 키, 반기 코드(H vs S), parentListId/parentId 중 맞는 이름. KOSIS 문서에 샘플 응답이 없어 추정으로 구현했습니다. 키를 넣고 KOSIS_LIVE_TEST=1 uv run pytest tests/live로 확인하세요.

  • 카탈로그(data/catalog.json)는 비어 있습니다. 통계표 ID를 기억에 의존해 적으면 틀린 값이 들어갈 수 있어서, 키로 실제 호출해 검증한 표만 넣기로 했습니다. 아래 "카탈로그 채우기"를 보세요. 그전에는 find_table이 KOSIS 통합검색으로 대신합니다.

Related MCP server: Korea Stats MCP

도구 (7개)

도구

하는 일

find_table

자연어로 통계표를 찾습니다. 카탈로그 → 없으면 KOSIS 통합검색

kosis_search

KOSIS 통합검색 직접 실행 (기관, 정렬, 페이지)

kosis_list

주제별/기관별 통계목록 트리 탐색

kosis_table_meta

통계표의 항목(ITM)과 분류(OBJ) 코드 조회

kosis_data

자료 조회 (기간 지정 또는 최근 N개 시점). 40,000셀을 넘으면 기간을 자동 분할

kosis_trend

시계열로 묶어 직전 시점 대비 증감률, 구간 변화량·증감률·연평균 성장률(CAGR) 계산

kosis_export

<표ID>.xlsx(원자료 + 시점별 가로 표)와 시트별 CSV(UTF-8 BOM) 저장

권장 흐름: find_table → kosis_table_meta → kosis_data 또는 kosis_trend → kosis_export.

설치

필요한 것: uv, KOSIS 인증키(https://kosis.kr/openapi 로그인 후 활용신청).

claude mcp add ne-kosis -s user ^
  -e KOSIS_API_KEY=발급키 ^
  -e KOSIS_EXPORT_DIR=C:\Users\내이름\Documents\kosis-exports ^
  -- uvx --from D:\repos\ne-kosis-mcp ne-kosis-mcp

(줄 끝 ^는 Windows cmd의 줄 이음입니다.) 개발 중에는 이 폴더의 .env에 KOSIS_API_KEY=...를 넣으면 서버가 읽습니다(.env는 git에 올라가지 않습니다).

환경변수

이름

설명

기본값

KOSIS_API_KEY

KOSIS 인증키 (필수)

—

KOSIS_EXPORT_DIR

엑셀/CSV 저장 폴더. 지정을 권장합니다

<작업 폴더>/exports

KOSIS_CACHE_DIR

API 응답 캐시 폴더

<홈>/.ne-kosis-mcp/cache

KOSIS_CACHE_TTL_HOURS

캐시 유지 시간

24

KOSIS_TOOLS_ALLOW

노출할 도구 이름(쉼표 구분, 비우면 전체)

전체

카탈로그

src/ne_kosis_mcp/data/catalog.json은 사람이 확인한 통계표 목록입니다. 항목 하나의 형식:

{
  "id": "student-count-by-region",
  "orgId": "...", "tblId": "...",
  "title": "표 이름",
  "topic": "교육 > 학생 수",
  "description": "무엇을 재는지, 어떤 질문에 답하는지",
  "prdSe": "Y", "period": "1990~2024",
  "unit": "명",
  "items": [{"id": "T1", "name": "학생수"}],
  "classifications": [{"level": 1, "name": "시도", "note": "ALL이면 전체 시도"}],
  "keywords": ["학생 수", "초등학생", "학령인구"],
  "notes": ["2021년부터 조사 기준 변경"],
  "verified": "YYYY-MM-DD"
}

find_table은 keywords(가중치 최고), title, topic, description 순으로 점수를 매깁니다.

카탈로그 채우기

키가 있으면 uv run python scripts/build_catalog.py "학생수" "사교육비" ...로 주제별 후보를 KOSIS 통합검색과 메타 조회로 모아 catalog.draft.json에 씁니다. 후보를 사람이 확인(실제 kosis_data 호출로 값 확인)하고 설명·키워드·주의사항을 채워 catalog.json에 옮깁니다.

한계

  • ELT 시장 규모처럼 KOSIS에 직접 없는 지표는 대리 지표(영어 사교육비, 학원업 사업체·매출, 학령인구 등)로 추정해야 합니다. 도구는 통계표의 값만 돌려주며 시장 규모를 추정하지 않습니다.

  • 통계표마다 단위와 조사 기준이 다릅니다. 모든 결과에 limitations가 붙습니다.

  • 기간 자동 분할은 연/반기/분기/월 주기와 시작·종료 지정일 때만 됩니다 (일 주기, 최근 N개는 범위를 직접 좁혀야 합니다).

개발

uv sync
uv run pytest

Available Tools

7 tools
find_tableA

자연어로 통계표를 찾습니다. 검증된 카탈로그(통계표 ID와 분류·항목 설명)를 먼저 보고, 없으면 KOSIS 통합검색으로 넘어갑니다. 통계 조회의 첫 단계입니다.

Inputs: query (required), max_results, include_search.

kosis_dataA

통계표 자료를 조회합니다 (기간 지정 또는 최근 N개 시점). 결과가 40,000셀을 넘으면 기간을 자동으로 나눠 받습니다. 행이 많으면 kosis_export를 쓰세요.

Inputs: org_id (required), prd_se (required), tbl_id (required), end, +5 more.

kosis_exportA

통계표 자료를 엑셀(xlsx)과 CSV로 저장합니다 (원자료 시트 + 시점별 가로 표 시트). 저장 폴더는 KOSIS_EXPORT_DIR로 지정합니다.

Inputs: org_id (required), prd_se (required), tbl_id (required), end, +5 more.

kosis_listB

KOSIS 통계목록(주제별/기관별 분류 트리)을 한 단계씩 탐색합니다.

Inputs: vw_cd, parent_id.

kosis_table_metaA

통계표의 항목(ITM)과 분류(OBJ) 코드를 조회합니다. kosis_data에 넣을 코드를 확인하는 단계입니다.

Inputs: org_id (required), tbl_id (required).

kosis_trendA

통계표 자료를 시계열로 묶어 직전 시점 대비 증감·증감률과 구간 요약(변화량, 증감률, 연평균 성장률 CAGR)을 계산합니다. 거시 추이와 시장 규모 변화를 볼 때 씁니다.

Inputs: itm_id (required), org_id (required), prd_se (required), tbl_id (required), +6 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools target distinct stages of the pipeline (navigate tree, find table, get codes, fetch data, analyze trend, export). The one soft overlap is find_table versus kosis_search, since both locate tables, but the descriptions clarify that find_table consults the catalog first while kosis_search hits KOSIS search directly. kosis_data and kosis_trend also both return data, but trend's change/CAGR framing distinguishes it.

    Naming Consistency4/5

    Six of seven tools share a clean kosis_ prefix with snake_case (kosis_list, kosis_search, kosis_table_meta, kosis_data, kosis_trend, kosis_export). The lone deviation is find_table, which drops the prefix and reads as an English verb_noun outlier. Minor but noticeable inconsistency.

    Tool Count5/5

    Seven tools is well-scoped for a statistics retrieval service, with each tool mapping to a clear stage (discover, inspect schema, fetch, analyze, export). No redundant or filler tools.

    Completeness4/5

    The surface covers the full read-only lifecycle: tree navigation, catalog/search discovery, metadata codes, data retrieval, trend analysis, and export. As a read-only data source there is no CRUD update/delete gap, though the slight find_table/kosis_search overlap hints at a small redundancy rather than a true hole.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables natural language querying of Korean statistical data from KOSIS, including population, employment, GDP, housing prices, and more, with support for regional and trend analysis.
      8
      13 npm
      17
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables querying Korean official statistics from KOSIS via natural language in MCP clients like Claude Desktop, wrapping the KOSIS OpenAPI for search, data retrieval, and metadata exploration.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to retrieve real-time official Korean statistics from the KOSIS database through natural language queries, with source citations.
      MIT