ks-local-mcp
Enables searching and viewing 1.89 million entries of the Seungjeongwon Ilgi and 380,000 articles of the Annals of the Joseon Dynasty from a local PostgreSQL database via Claude Desktop.
README
ks-local-mcp
승정원일기·조선왕조실록 로컬 PostgreSQL MCP 서버.
로컬 PostgreSQL DB에 직접 접속해 189만 건 승정원일기·38만 건 실록을 Claude Desktop에서 검색·조회한다.
전제 조건
- macOS 또는 Linux
- PostgreSQL 18이 로컬에 실행 중
sjwDB: 승정원일기 (국편 XML 적재 완료)sillokDB: 조선왕조실록 (국편 XML 적재 완료)- Claude Desktop 설치
설치
curl -LsSf https://raw.githubusercontent.com/namjiman/ks-local-mcp/main/install.sh | bash
설치 중 PostgreSQL 접속 URL과 비밀번호를 입력한다. 입력하지 않으면 기본값(postgresql://postgres@127.0.0.1:5432/sjw)을 사용한다.
설치 후 Claude Desktop을 재시작하면 도구 15개가 활성화된다.
수동 설치
~/Library/Application Support/Claude/claude_desktop_config.json에 추가:
{
"mcpServers": {
"ks_local_mcp": {
"command": "uvx",
"args": ["--from", "git+https://github.com/namjiman/ks-local-mcp", "ks-local-mcp"],
"env": {
"SJW_DATABASE_URL": "postgresql://postgres:비밀번호@127.0.0.1:5432/sjw",
"SILLOK_DATABASE_URL": "postgresql://postgres:비밀번호@127.0.0.1:5432/sillok"
}
}
}
}
도구 목록 (15개)
공통
| 도구 | 설명 |
|---|---|
list_sources |
사용 가능한 DB 목록과 개요 |
db_status |
두 DB의 실시간 건수·날짜 범위·색인 수 |
승정원일기 (sjw · 1623–1910 · 189만 건)
| 도구 | 설명 | 주요 파라미터 |
|---|---|---|
sjw_search |
본문 키워드 검색 | keyword, limit, offset, entry_type, and_terms, regex, normalize, with_snippet |
sjw_count |
건수만 반환 — 빈도 조사용 | keyword, field, normalize |
sjw_count_by_period |
시기별 빈도 집계 | keyword, by(reign/decade/year) |
sjw_index_search |
색인(이름·지명·서명) 검색 | value, index_type, limit, offset, exact |
sjw_date_search |
날짜 범위 검색 | date_from, date_to, keyword, offset, with_snippet |
sjw_get_entry |
기사/좌목 전문 조회 | entry_id, include_xml |
조선왕조실록 (sillok · 태조–철종 · 38만 건)
| 도구 | 설명 | 주요 파라미터 |
|---|---|---|
sillok_search |
본문 키워드 검색 | keyword, limit, offset, and_terms, regex, normalize, with_snippet |
sillok_count |
건수만 반환 — 빈도 조사용 | keyword, field, normalize |
sillok_count_by_period |
시기별 빈도 집계 | keyword, by(reign/decade/year) |
sillok_index_search |
색인(이름·지명·서명·연호·관직) 검색 | value, index_type, limit, offset, exact |
sillok_date_search |
날짜 범위 검색 | date_from, date_to, keyword, offset, with_snippet |
sillok_subject_search |
주제분류 검색 | subject, limit, offset |
sillok_get_article |
기사 전문 조회 | article_id, include_xml |
주요 기능
진짜 총건수 (total)
모든 검색 도구가 COUNT(*)를 별도로 실행해 limit에 잘리지 않은 실제 총건수를 반환한다.
{"total": 2699, "offset": 0, "limit": 20, "rows": 20, "docs": [...]}
페이지네이션 (offset)
offset 파라미터로 101번째 이후 결과를 순차적으로 수집할 수 있다.
sjw_search(keyword="呼望", limit=50, offset=0) → 1–50번
sjw_search(keyword="呼望", limit=50, offset=50) → 51–100번
경량 모드 (with_snippet=False)
with_snippet=False로 전수 ID 수집 시 응답 크기를 대폭 줄일 수 있다. ID·날짜·제목만 반환한다.
빈도 조사 (sjw_count, sillok_count)
본문 payload 없이 건수만 반환한다. 어휘 빈도 조사의 1단계에서 사용한다.
sjw_count(keyword="呼望") → {"total": 2699}
시기별 분포 (sjw_count_by_period)
재위·10년·연도 단위로 빈도를 집계한다.
sjw_count_by_period(keyword="呼望", by="reign")
→ [{"bucket": "영조01년", "n": 12}, ...]
AND 검색 + 정규식
sjw_search(keyword="呼望", and_terms=["牌招"]) → 두 어 동시 출현
sjw_search(keyword="", regex="呼望|牌招") → 정규식
HTML 실체참조 정규화
희귀 한자가 &#xNNNN; 형태로 저장된 경우 normalize=True로 양형 매칭한다.
sjw_search(keyword="實𧏮", normalize=True)
검색 권장 순서
sjw_count/sillok_count— 빈도 먼저 파악sjw_index_search— 색인에서 인명·지명·서명 확인sjw_search(with_snippet=False) — 전수 ID 수집sjw_get_entry— 필요한 건 전문 확인
날짜 기준
모든 검색 결과의 resolved_date는 coalesce(date_seogi, date_gregorian_resolved) (양력 기준).
date_seogi: 원문에서 직접 파싱된 날짜date_gregorian_resolved: KASI OpenAPI 양력 보정값date_seogi_raw: 원문 날짜 문자열 (수정 불가)
검색 속도 향상 (선택)
sql/ks_local_trgm_indexes.sql을 실행하면 ilike 검색이 수 배 빨라진다.
# sjw
/Library/PostgreSQL/18/bin/psql -h 127.0.0.1 -U postgres -d sjw \
-f sql/ks_local_trgm_indexes.sql
# sillok
/Library/PostgreSQL/18/bin/psql -h 127.0.0.1 -U postgres -d sillok \
-f sql/ks_local_trgm_indexes.sql
인덱스 생성은 CONCURRENTLY 옵션으로 실행 중에도 DB 읽기가 가능하다. 완료까지 수 분 소요.
근거 인용 형식
근거: 승정원일기 entry_id=SJW-A04020290-00001, date=1626-03-26, title=...
근거: 조선왕조실록 article_id=wka_12502030_001, date=1530-02-30, title=...
관련 MCP
| MCP | 용도 |
|---|---|
| db_mcp | 한국고전종합DB(ITKC) 온라인 API 검색 |
| ks-local-mcp (이 저장소) | 승정원일기·실록 로컬 PostgreSQL 검색 |
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。