MCP_SERVER_INTEGRATION.md•3.79 kB
# 🚀 K-Water MCP 서버 통합 완료
## 📋 개요
4개의 Netlify Functions를 **하나의 MCP JSON-RPC 2.0 표준 서버**로 성공적으로 통합했습니다!
## 🔧 통합된 기능
### 기존 4개 함수 → 3개 MCP 도구로 통합
1. **`search_water_station_by_name`** - 지역명으로 관측소 검색
2. **`get_water_info_by_location`** - 자연어 수문 정보 조회
3. **`recommend_nearby_stations`** - 주변 관측소 추천
## 🌐 ChatGPT Tools 등록 정보
```json
{
"url": "https://hrfco-mcp-functions.netlify.app/.netlify/functions/mcp",
"label": "K-Water 수문정보",
"description": "한국 수자원공사 실시간 수문 데이터 조회 시스템",
"authentication": "none"
}
```
## 📡 MCP JSON-RPC 2.0 API 사용법
### 1. Initialize (초기화)
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {}
}
```
### 2. Tools List (도구 목록 조회)
```json
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}
```
### 3. Tools Call (도구 실행)
#### 한강 수위 조회
```json
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_water_info_by_location",
"arguments": {
"query": "한강 수위",
"limit": 5
}
}
}
```
#### 서울 지역 관측소 검색
```json
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "search_water_station_by_name",
"arguments": {
"location_name": "서울",
"data_type": "waterlevel",
"limit": 5
}
}
}
```
#### 부산 주변 관측소 추천
```json
{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "recommend_nearby_stations",
"arguments": {
"location": "부산",
"radius": 20,
"priority": "distance"
}
}
}
```
## 🧪 테스트 방법
### 로컬 테스트
```bash
cd /home/ubuntu/hrfco-service
node test-mcp-server.js
```
### cURL 테스트
```bash
# Tools List 조회
curl -X POST https://hrfco-mcp-functions.netlify.app/.netlify/functions/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}'
# 한강 수위 조회
curl -X POST https://hrfco-mcp-functions.netlify.app/.netlify/functions/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "get_water_info_by_location",
"arguments": {
"query": "한강 수위",
"limit": 3
}
}
}'
```
## 🎯 ChatGPT에서 사용 예시
ChatGPT Tools에 등록 후 다음과 같이 사용할 수 있습니다:
**사용자**: "한강 수위 어때?"
↓
**ChatGPT**: MCP 서버의 `get_water_info_by_location` 호출
↓
**MCP 서버**: HRFCO API 조회 후 결과 반환
↓
**ChatGPT**: "현재 한강 유역 관측소 3곳의 수위는..."
## ✨ 주요 특징
- ✅ **MCP JSON-RPC 2.0 완전 준수**
- ✅ **기존 지능형 검색 로직 100% 유지**
- ✅ **ChatGPT Tools 호환**
- ✅ **3개 도구 통합 제공**
- ✅ **CORS 지원**
- ✅ **에러 처리 표준화**
## 📁 파일 구조
```
netlify/functions/
├── mcp.ts # 🆕 통합 MCP 서버
├── utils.ts # 공통 유틸리티 (기존)
├── search-station.ts # 기존 함수 (유지)
├── get-water-info.ts # 기존 함수 (유지)
└── recommend-stations.ts # 기존 함수 (유지)
```
## 🚀 배포 상태
- **MCP 서버**: `https://hrfco-mcp-functions.netlify.app/.netlify/functions/mcp`
- **상태**: ✅ 배포 완료
- **ChatGPT 등록**: ✅ 준비 완료
---
**🎉 이제 ChatGPT에서 한국 수자원 데이터를 자연어로 조회할 수 있습니다!**