使用说明
法律案件搜索管道
韩国金融法律文件搜索管道:爬行、预处理、嵌入、索引和MCP服务器。
概述
This pipeline crawls,preprocessses,embeds,index,and services Korean financial legal documents from regulatory sources,包括FSC(金融委员会)、FSS(金融监督院)和MOLEG(法制处)通过一个MCP server for hybrid search。
主要特点:
- 9数据来源:FSC(5)+FSS(3)+MOLEG(1)
- 混合搜索:密集(双子座3072昏暗)+稀疏(新西兰TF-IDF 2M声音)+RRF融合
- MCP 服务器:
search_cases和get_chunksAI代理集成工具 - Docker就绪:生产准备就绪,支持GCP e2介质
文档
| 文档 | 描述 |
|---|---|
| CRAWLER.md | 数据源、爬网模式、crontab设置 |
| 管道.md | 预处理、嵌入、索引 |
| 部署.md | Docker部署、GCP工作流 |
| MCP.md | MCP服务器API参考 |
| 更改日志.md | 版本历史 |
快速开始
先决条件
- Python 3.12+Docker
- Gemini API密钥(
GEMINI_API_KEY)
安装
# Clone and setup
cd RegLink-Search-ko-mcp
uv sync
# Or with Docker
docker run -d --name qdrant -p 6333:6333 -p 6334:6334 \
-v $(pwd)/data/qdrant_storage:/qdrant/storage qdrant/qdrant
docker-compose -f docker-compose.app.yml build
基本用法
# Run crawlers
uv run python scripts/crawl.py --source all --mode full
# Build IDF weights
uv run python scripts/build_idf.py --data-dir data/raw
# Build search index
uv run python scripts/index.py --source all --recreate-collection
# Run MCP server
uv run python -m src.mcp_server.server
Docker 使用
# Create .env file (automatically loaded by docker-compose)
cat > .env << 'EOF'
GEMINI_API_KEY=your-api-key
GOOGLE_API_KEYS=key1,key2,key3 # Multiple keys recommended for production
QDRANT_URL=http://localhost:6333
EOF
# Crawl + Index (one-liner)
docker-compose -f docker-compose.app.yml run --rm mcp bash -c "\
python scripts/crawl.py --source all --mode full && \
python scripts/build_idf.py --data-dir data/raw && \
python scripts/index.py --source all --recreate-collection"
# Start MCP server
docker-compose -f docker-compose.app.yml up -d
数据源
FSC(金融委员会)-5 Sources
| 来源 | 名称 | 类型 |
|---|---|---|
fsc_law 金融委员会法令解释ID-based |
||
fsc_opinion 金融委员会非措施意见书ID-based |
||
fsc_minutes |
金融委员会会议记录 | Page-based |
fsc_sm_minutes |
增选委备忘录 | Page-based |
fsc_ruling |
金融委员会规定/公告/公告/训令 | Page-based |
FSS(金融监督院)-3 Sources
| 来源 | 名称 | 类型 |
|---|---|---|
fss_dispute 金融监督院纠纷调解案例ID-based |
||
fss_bulletin |
金融监督院纠纷调解决定例 | Page-based |
fss_major_precedent 金融监督院主要判例Page-based |
MOLEG(法制处)-1 Source
| 来源 | 名称 | 类型 |
|---|---|---|
moleg_interpret |
法制处法令解释 | Page-based |
看 CRAWLER.md 了解完整的详细信息,包括删除的来源和文档数量估计。
项目结构
RegLink-Search-ko-mcp/
├── src/
│ ├── crawler/ # Data collection (9 source crawlers)
│ ├── preprocessor/ # Text cleaning, validation, chunking
│ ├── embedding/ # Gemini dense + Kiwi sparse encoders
│ ├── indexer/ # Qdrant batch indexing
│ ├── search/ # Hybrid search with RRF fusion
│ └── mcp_server/ # MCP server (search_cases, get_chunks)
│
├── scripts/ # CLI entry points
│ ├── crawl.py # Run crawlers
│ ├── build_idf.py # Build IDF weights
│ ├── index.py # Build search index
│ └── reindex_sparse.py # Re-index sparse vectors
│
├── config/
│ └── crawler_config.yaml # Crawler settings
│
├── data/
│ ├── raw/ # Crawled JSON files
│ ├── state/ # Crawl state tracking
│ ├── sparse/ # IDF weights
│ └── qdrant_storage/ # Qdrant persistent storage
│
├── Dockerfile
├── docker-compose.yml # Full stack (Qdrant + App)
└── docker-compose.app.yml # App only (external Qdrant)
MCP 服务器
MCP服务器为AI代理集成提供了两个工具:
| 工具 | 说明 |
|---|---|
search_cases |
具有模式选择的混合搜索(密集+稀疏+RRF) |
get_chunks |
通过doc_id检索其他块 |
# Search modes
search_cases(query="투자자 보호", mode="hybrid") # General queries
search_cases(query="제37조", mode="keyword") # Exact references
search_cases(query="금융회사 책임", mode="semantic") # Conceptual
看 MCP.md 以获取API的完整参考。
环境变量
| 变量 | 必填 | 描述 |
|---|---|---|
GOOGLE_API_KEYS |
推荐 | Comma-separated Gemini API键(用于旋转) |
GEMINI_API_KEY |
回退 | 单个Gemini API密钥 |
QDRANT_URL |
无 | Qdrant URL(默认值: http://localhost:6333) |
QDRANT_COLLECTION |
否 | 集合名称(默认值: legal_cases) |
依赖项
dependencies = [
"requests>=2.31.0",
"beautifulsoup4>=4.12.0",
"qdrant-client>=1.7.0",
"google-genai>=1.0.0",
"kiwipiepy>=0.16.0",
"pyhwp>=0.1b12",
"pymupdf>=1.23.0",
"fastmcp>=0.1.0",
]