io.github.rubatoyd/kosis-openapi-mcp
# kosis-openapi-mcp
<!-- mcp-name: io.github.rubatoyd/kosis-openapi-mcp -->
[](https://github.com/rubatoyd/kosis-openapi-mcp/actions/workflows/ci.yml)
[](https://github.com/rubatoyd/kosis-openapi-mcp/releases/latest)
[](https://github.com/rubatoyd/kosis-openapi-mcp/releases)
<!-- usage:start -->
> ๐ **์ฌ์ฉ๋** โ ์ต๊ทผ 14์ผ ์กฐํ **0**ํ(๊ณ ์ 0) ยท ํด๋ก **0**ํ(๊ณ ์ 0) ยท ๋ฆด๋ฆฌ์ค ์์ฐ ๋์ ๋ค์ด๋ก๋ **15**
>
> 
>
> <sub>2026-09-12 ์๋ ๊ฐฑ์ ยท ์ ์ฒด ์ด๋ ฅ์ [`docs/usage.csv`](docs/usage.csv). GitHub ํธ๋ํฝ ํต๊ณ๋ 14์ผ ์ฐฝ๋ง ์ ๊ณตํ๋ฏ๋ก ์ด ์ ์ฅ์๊ฐ ๋งค์ผ ์ฐ์ด ๋์ ํ๋ค.</sub>
<!-- usage:end -->
**KOSIS(๊ตญ๊ฐํต๊ณํฌํธ) ๊ณต์ ์๋น์ค OpenAPI** ๋ฅผ ๊ฒ์ยท์์งํ๋ MCP ์๋ฒ + CLI.
ํต๊ณํ๋ฅผ ์ฐพ๊ณ , ํญ๋ชฉยท๋ถ๋ฅยท์ฃผ๊ธฐ๋ฅผ ํ์ธํ๊ณ , ์์น๋ฅผ ๋ฐ์ xlsxยทcsvยทjsonยทsqlite ๋ก
๋ด๋ณด๋ธ๋ค. **4๋ง ์
์ ํ์ ๊ฑธ๋ฆฌ๋ฉด ๊ธฐ๊ฐ์ ์์์ ์ชผ๊ฐ** ์ ์๋ฅผ ํ์ํ๋ค.
์๋งค ์ ์ฅ์: [law-openapi-mcp](https://github.com/rubatoyd/law-openapi-mcp)(๋ฒ์ ์ฒ) ยท
[na-openapi-mcp](https://github.com/rubatoyd/na-openapi-mcp)(๊ตญํ๋์๊ด) ยท
[nl-openapi-mcp](https://github.com/rubatoyd/nl-openapi-mcp)(๊ตญ๋ฆฝ์ค์๋์๊ด) ยท
[kci-openapi-mcp](https://github.com/rubatoyd/KCI_openAPI) ยท [scienceON-mcp](https://github.com/rubatoyd/scienceON-mcp)
---
## ๋ฌด์์ ๋๋ ค์ฃผ๋
**ํต๊ณ ๊ทธ ์์ฒด๋ค.** ํ์ ๋ฉํ(์์ฑ๊ธฐ๊ดยท์กฐ์ฌ๋ช
ยท์๋ก๊ธฐ๊ฐยท์ฃผ๊ธฐ)์ ์์น(์์ ร ๋ถ๋ฅ ร
ํญ๋ชฉ โ ๊ฐ)๋ฅผ ๋๋ฉ์ธ ๊ทธ๋๋ก ์ค๋ค.
์์งยท์ธ์ฉ ํ์์ **๋ถ๊ฐ ๊ธฐ๋ฅ**(`kosis_citation`)์ผ๋ก ๋ฐ๋ก ๋์๋ค. ์์ง๊ด๋ฆฌ ๋๊ตฌ๋ก
๋๊ธธ ๋๋ง ์ฐ๋ฉด ๋๊ณ , ๊ทธ ๋๊ตฌ๊ฐ ์๋ ์ ํ ๋ชฉ๋ก์ด ํต๊ณ ์๋ต์ ๋ชจ์์ ๋ฐ๊พธ์ง๋ ์๋๋ค.
## ์ค๋น๋ฌผ
์ธ์ฆํค ํ๋. [kosis.kr](https://kosis.kr) ํ์๊ฐ์
ํ ๊ณต์ ์๋น์ค ํ์ฉ์ ์ฒญ(์๋ ์น์ธ).
```bash
cp .env.example .env # KOSIS_API_KEY=... ๋ฅผ ์ฑ์ด๋ค
```
> ๐ด **๋ฐ๊ธ๋ ๊ฐ์ ๊ทธ๋๋ก ๋ฃ์ผ์ธ์.** base64 ์ฒ๋ผ ๋ณด์ฌ๋(๋์ด `=`) ๋์ฝ๋ํ๋ฉด
> `err 11`(์ ํจํ์ง ์์ ์ธ์ฆํค)์ด ๋ฉ๋๋ค.
## ์ค์นยท์คํ
```bash
uv sync
uv run kosis status
uv run kosis search ์ฌ๊ต์ก๋น
uv run kosis meta --org 101 --tbl DT_1PE201 --kind ITM # ํญ๋ชฉ ID ํ์ธ
uv run kosis data --org 101 --tbl DT_1PE201 --prd Y --start 2020 --end 2025
uv run kosis collect --org 101 --tbl DT_1B040A3 --prd M --start 202101 --end 202512
# ๋ถ๋ฅ์ถ์ด ์ฌ๋ฟ์ธ ํ๋ ๊ทธ๋๋ก โ ์ถ ๊ฐ์๋ ์์์ ๋ง์ถ๋ค(์ฐ์
ร ๊ท๋ชจ)
uv run kosis data --org 118 --tbl DT_118N_MON051 --prd H --start 202401 --end 202401
# ์ฃผ์์งํ(ํต๊ณํ์ ๋ค๋ฅธ ๊ณ์ด) โ ํ ๊ตฌ์กฐ๋ฅผ ๋ชฐ๋ผ๋ ๊ฐ๊น์ง ๋ฐ๋ก
uv run kosis indicator ์ถ์ฐ์จ
uv run kosis indicator-data --id 13 --start 2020 --end 2025
```
MCP ๋ฑ๋ก:
```json
{
"mcpServers": {
"kosis": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "git+https://github.com/rubatoyd/kosis-openapi-mcp", "kosis-mcp"],
"env": { "KOSIS_API_KEY": "๋ฐ๊ธ๋ฐ์_๊ฐ_๊ทธ๋๋ก" }
}
}
}
```
> PyPI ์ ์ฌ๋ฆฐ ํจํค์ง๊ฐ ์์ง ์์ด **์ ์ฅ์์์ ๋ฐ๋ก** ๋ฐ์ ์ด๋ค(์๋งค ์ ์ฅ์์ ๊ฐ์ ๋ฐฉ์).
> `main` ์ HEAD ๋ฅผ ์ฐ๋ฏ๋ก ๋ค์ ๊ธฐ๋์ ์ต์ ์ด ๋ฐ์๋๋ค.
## MCP ๋๊ตฌ
| ๋๊ตฌ | ํ๋ ์ผ |
|------|---------|
| `kosis_status` | ์ธ์ฆํค ๋ณด์ ์ฌ๋ถ + ์ค์ ์๋ณต 1ํ |
| `kosis_guide` | ์๋น์ค๋ทฐยท์ฃผ๊ธฐยท๋ฉํ ์ข
๋ฅยท์ค๋ฅ์ฝ๋ยทํ๊ณยทํจ์ |
| `kosis_search` | ํต๊ณํ ์ฐพ๊ธฐ(ํตํฉ๊ฒ์) |
| `kosis_list` | ํต๊ณ๋ชฉ๋ก ํธ๋ฆฌ ํ ๋จ๊ณ(์ฃผ์ ๋ณยท๊ธฐ๊ด๋ณ โฆ) |
| `kosis_meta` | ํ์ ํญ๋ชฉ(ITM)ยท๋ถ๋ฅ(NCD)ยท์ฃผ๊ธฐ(PRD)ยท์ถ์ฒ ๋ฑ |
| `kosis_explain` | ํต๊ณ์ค๋ช
(์กฐ์ฌ๊ฐ์) |
| `kosis_data` | ์์น โ **4๋ง ์
์ด๊ณผ ์ ๊ธฐ๊ฐ ์๋ ๋ถํ ** |
| `kosis_citation` | ํ๋ฅผ ์์ง ์นธ์ผ๋ก ํฌ์(๋ถ๊ฐ ๊ธฐ๋ฅ) |
| `kosis_collect` | ์์น๋ฅผ xlsx/csv/json/sqlite ๋ก ์ ์ฅ |
| `kosis_indicator_search` | **์ฃผ์์งํ** ์ฐพ๊ธฐ(ํต๊ณํ์ ๋ค๋ฅธ ๊ณ์ด) โ ํ์ด์ง ์ ์ ํ์ |
| `kosis_indicator_data` | ์ฃผ์์งํ์ ์์ ๋ณ ์์น โ **์๋ฒ๊ฐ ์ ๊ฑฐ๋ฅด๋ ์์ ์ ๋์ ๊ฑฐ๋ฅธ๋ค** |
## ์์ ๋ ๊ฒ (์ ๋ถ ์ค์ธก)
172์ชฝ์ง๋ฆฌ ๊ณต์ ๊ฐ๋ฐ๊ฐ์ด๋๊ฐ ์๋๋ฐ๋ **๊ฐ์ฅ ์ค์ํ ์
์ด ๊ทธ ์์ ์๊ฑฐ๋ ํ๋ฆฌ๋ค**:
- ๐ด **`jsonVD=Y` ๊ฐ ์์ผ๋ฉด JSON ์ด ์๋๋ค** โ ํค์ ๋ฐ์ดํ๊ฐ ์๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด
๋ฆฌํฐ๋ด์ด ์จ๋ค. ์ด ํ๋ผ๋ฏธํฐ๋ ๊ฐ์ด๋์ ์
๋ ฅ ๋ณ์ ํ์ **์๊ณ ** JSP ์์ ์์๋ง ์๋ค.
- ๐ด **ํต๊ณ์๋ฃ๋ฅผ `orgId`/`tblId` ๋ก ๋ถ๋ฅด๋ ค๋ฉด `/openapi/Param/statisticsParameterData.do`**
๋ฅผ ์จ์ผ ํ๋ค. ๊ฐ์ด๋๊ฐ ํ๋ฅผ ์ค์ด ๋ `statisticsData.do` ๋ก ๋ณด๋ด๋ฉด **ํญ์ err 20**.
- ๐ด **์ธ์ฆํค๋ฅผ ๋์ฝ๋ํ์ง ๋ง ๊ฒ.**
๊ทธ ๋ฐ์:
- ๐ด **๋ถ๋ฅ์ถ(`objL`) ๊ฐ์๊ฐ ํ์ ์ถ ์์ ์ ํํ ๋ง์์ผ ํ๋ค** โ ๋ชจ์๋ผ๋ฉด `err 20 (objL)`,
๋์น๋ฉด `err 21`. ๊ทธ๋ฐ๋ฐ ์ถ ๊ฐ์๋ฅผ ์๋ ค ์ฃผ๋ ๋ฉํ ์๋น์ค๊ฐ **์๋ค**(`NCD` ๋ ๋ถ๋ฅ๊ฐ ์๋๋ผ
์ ๊ท์๋ก ์์ ์ด๊ณ `OBJ`ยท`CLS` ๋ `err 30`). `kosis_data` ๊ฐ ์ถ์ ํ๋์ฉ ๋๋ ค ๋ง์ถ๋ฏ๋ก
**๋ค์ถ ํ(์: ์ฐ์
ร ๊ท๋ชจ)๋ ๊ทธ๋ฅ ๋ถ๋ฅด๋ฉด ๋๋ค** โ ํ์ ๋ ์ถ์ `meta.obj_levels` ์ ์ค๋ฆฐ๋ค.
- **๋ชจ๋ ์คํจ๊ฐ HTTP 200 ์ด๋ค.** ์ฑ๊ณต์ ๋ฐฐ์ด, ์คํจ๋ `{err, errMsg}` ๊ฐ์ฒด.
`Content-Type` ์ ๋ ๋ค `text/html` ์ด๋ผ ๋ฏฟ์ ์ ์๋ค.
- **`err 30`(๊ฒฐ๊ณผ ์์)์ ์ค๋ฅ๊ฐ ์๋๋ค** โ 0๊ฑด๊ณผ ์คํจ๋ฅผ ๊ตฌ๋ถํด์ ๋ณด๊ณ ํ๋ค.
- **์์ฒญ๋น 4๋ง ์
**(err 31) ยท **๋ถ๋น 200๊ฑด**(err 40).
- **ํ์ด์ง์ด ์๋ค** โ ํตํฉ๊ฒ์ยท๋ชฉ๋กยทํต๊ณ์๋ฃ๋ ์๋ฒ๊ฐ ์ค ๋งํผ์ด ์ ๋ถ๋ค(์กฐ์ฉํ ์๋ฅด์ง ์๊ณ ์๋ฆฐ๋ค).
๋จ **ํต๊ณ์ฃผ์์งํ ๊ณ์ด๋ง ์์ธ**๋ก `pageNo`ยท`numOfRows` ๋ฅผ ๋ฐ๊ณ ์ ์ฃผ๋ฉด 10๊ฑด์์ ์๋ฆฐ๋ค โ
`kosis_indicator_*` ๊ฐ ๋๊น์ง ๋๊ฒจ ์ ์๋ฅผ ํ์ํ๋ค([docs](docs/KOSIS_API_GUIDE.md) ยง7).
- ๐ด **์ฃผ์์งํ ๊ณ์ด์ ์์ ๋ฒ์๋ฅผ ๊ฑฐ๋ฅด์ง ์๋๋ค**(๋ชจ๋ ์ค์์น์ผ ๋ฟ ๊ฐ์ ๋ฌด์๋๋ค).
`kosis_indicator_data` ๊ฐ ์ ๊ตฌ๊ฐ์ ๋ฐ์ ์ง์ ๊ฑฐ๋ฅด๊ณ `meta.server_filtered=false` ๋ก ์๋ฆฐ๋ค.
- `parentListId` ๋ ํ์๋ผ๊ณ ์ ํ ์์ง๋ง **์๋ตํ๋ฉด ์ต์์**๊ฐ ์จ๋ค.
์์ธํ ๊ทผ๊ฑฐ์ ์ฌํ ๋ฐฉ๋ฒ์ [docs/KOSIS_API_GUIDE.md](docs/KOSIS_API_GUIDE.md).
## ๋ผ์ด์ ์ค
MIT
TDQS
Scored across 11 tools
Each tool has a single clear role: table search vs indicator search, table data vs indicator data, metadata vs survey explanation, data retrieval vs file export. The detailed descriptions explicitly distinguish the similar indicator/table families, so an agent can reliably choose between them.
All tools share the kosis_ prefix and snake_case, and the search/data pairs are parallel (kosis_search/kosis_indicator_search, kosis_data/kosis_indicator_data). However, the second part mixes bare verbs (search, list, explain, collect) with bare nouns (meta, data, citation, guide), so it is not a strict verb_noun convention.
11 tools is well within the ideal range and each one earns its place: status/guide for orientation, search/explain/list/meta/data for the table workflow, indicator_search/indicator_data for the indicator workflow, plus collect and citation for output and scholarship.
For a read-only statistical data API, the surface is complete: users can discover tables by search or tree, read survey descriptions and table metadata, fetch full table data with automatic axis/period handling, access major indicators, export to files, and generate citations. No obvious dead ends or missing core operations remain.