Initial commit: RAG MCP Server with relationship graph

Features:
- Vector search with Pinecone + Vertex AI embeddings
- Document relationships (link, unlink, related, graph)
- Auto-link with LLM analysis
- Intelligent merge with Gemini

Modular structure:
- clients/: Pinecone, Vertex AI
- tools/: core, relations, stats
- utils/: validation, logging

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-02-03 11:05:45 +09:00
commit 2858e0a344
17 changed files with 1450 additions and 0 deletions

68
README.md Normal file
View File

@@ -0,0 +1,68 @@
# RAG MCP Server
Vector DB 기반 장기 기억 시스템 + 관계 그래프 지원 MCP 서버
## 기능
### 핵심 도구
- `rag_save` - 정보 저장 (auto_link로 자동 관계 생성 가능)
- `rag_retrieve` - 벡터 유사도 검색
- `rag_update` - LLM 기반 지능형 병합 (충돌 시 새 정보 우선)
- `rag_delete` - 문서 삭제 (관계 자동 정리)
### 관계 그래프
- `rag_link` - 두 문서 간 관계 생성 (양방향)
- `rag_unlink` - 관계 제거
- `rag_related` - 특정 문서의 관련 문서 조회
- `rag_graph` - 관계 그래프 탐색 (depth 지정 가능)
- `rag_stats` - 전체 통계 조회
### 관계 타입
| 관계 | 역관계 | 용도 |
|------|--------|------|
| `depends_on` | `required_by` | 의존성 |
| `part_of` | `contains` | 포함 관계 |
| `updates` | `updated_by` | 업데이트 |
| `see_also` | `see_also` | 참조 (대칭) |
| `extends` | `extended_by` | 확장 |
| `contradicts` | `contradicts` | 모순 (대칭) |
| `related` | `related` | 일반 관계 (대칭) |
## 스택
- **FastMCP** - MCP 서버 프레임워크
- **Pinecone** - 벡터 데이터베이스
- **Vertex AI** - 임베딩 (text-embedding-004) + LLM (Gemini)
## 설정
```bash
cp .env.example .env
# .env 파일에 API 키 설정
```
### 환경 변수
| 변수 | 설명 | 기본값 |
|------|------|--------|
| `VERTEX_API_KEY` | Google Vertex AI API 키 | (필수) |
| `PINECONE_API_KEY` | Pinecone API 키 | (필수) |
| `PINECONE_INDEX_NAME` | Pinecone 인덱스명 | `memory-index` |
| `GOOGLE_CLOUD_PROJECT` | GCP 프로젝트 ID | - |
| `GOOGLE_CLOUD_LOCATION` | GCP 리전 | `us-central1` |
| `AUTO_LINK_THRESHOLD` | 자동 관계 생성 유사도 임계값 | `0.75` |
| `AUTO_LINK_TOP_K` | 자동 관계 분석 시 검색할 문서 수 | `5` |
| `FASTMCP_HOST` | 서버 호스트 | `0.0.0.0` |
| `FASTMCP_PORT` | 서버 포트 | `8000` |
## 실행
```bash
# 의존성 설치
pip install -e .
# 서버 실행
python server.py
```
## 배포 위치
- Container: `jp1:rag-mcp`
- IP: `10.253.100.107:8000`