# MCP Server Integration Guide
agentic_ai 프로젝트와 MCP 서버를 통합하는 방법입니다.
## 통합 방법
### Option 1: Claude Desktop과 통합
1. Claude Desktop 설정 파일 수정:
**macOS:**
```bash
~/Library/Application Support/Claude/claude_desktop_config.json
```
**Windows:**
```bash
%APPDATA%/Claude/claude_desktop_config.json
```
2. 다음 설정 추가:
```json
{
"mcpServers": {
"external-data-connector": {
"command": "/Users/swkeum/work/mcp_server/.venv/bin/python",
"args": ["/Users/swkeum/work/mcp_server/server.py"]
}
}
}
```
3. Claude Desktop 재시작
4. Claude에서 다음과 같이 사용:
```
"빗물받이가 막혔어요"라는 신고에 대해 위도 37.5665, 경도 126.9780의 기상 정보를 조회해줘.
```
### Option 2: Python 코드에서 직접 사용
agentic_ai 프로젝트의 `external_data_connector.py`를 MCP 클라이언트로 교체:
```python
# 기존 방식 (더미 데이터)
from modules.external_data_connector import ExternalDataConnector
connector = ExternalDataConnector()
weather = connector.get_weather_info(37.5665, 126.9780)
```
```python
# MCP 방식 (향후 실제 API 연동 가능)
import asyncio
from mcp_client import MCPExternalDataConnector
async def get_data():
async with MCPExternalDataConnector() as connector:
weather = await connector.get_weather_info(37.5665, 126.9780)
return weather
weather = asyncio.run(get_data())
```
## MCP 서버 업데이트 방법
실제 API를 연동하려면 `server.py`의 메서드를 수정:
### 예: 실제 기상 API 연동
```python
async def get_weather_info(self, latitude: float, longitude: float):
"""실제 기상청 API 연동"""
import aiohttp
api_key = "YOUR_API_KEY"
url = f"https://api.weather.gov/..."
async with aiohttp.ClientSession() as session:
async with session.get(url, params={
"lat": latitude,
"lon": longitude,
"key": api_key
}) as response:
data = await response.json()
return {
"temperature": data["temperature"],
"humidity": data["humidity"],
"rainfall": data["rainfall"],
"forecast": data["forecast"],
"timestamp": datetime.now().isoformat(),
"location": {
"latitude": latitude,
"longitude": longitude
}
}
```
## 장점
1. **표준화**: MCP 프로토콜을 사용하여 다양한 클라이언트와 호환
2. **확장성**: 서버만 업데이트하면 모든 클라이언트가 자동으로 업데이트됨
3. **재사용성**: 다른 프로젝트에서도 같은 MCP 서버 사용 가능
4. **테스트 용이**: 서버와 클라이언트를 독립적으로 테스트 가능
## 다음 단계
1. 실제 기상 API 연동
2. 데이터베이스 연동 (신고 이력)
3. 인프라 모니터링 시스템 연동
4. 인증 및 권한 관리 추가
5. 캐싱 및 성능 최적화