Skip to main content
Glama

HRFCO Service

TYPESCRIPT_DEPLOYMENT.md3.81 kB
# 🚀 TypeScript Netlify Functions 배포 가이드 ## ✅ 완료된 TypeScript 변환 ### 🔄 **Python → TypeScript 변환 완료** - **Python FastAPI** → **Netlify Functions** - **Python 유사도 계산** → **TypeScript 문자열 매칭** - **Python 지역 매핑** → **TypeScript 상수 객체** - **응답 크기 최적화** → **동일하게 유지 (1KB 미만)** ### 📁 **Netlify Functions 구조** ``` netlify/functions/ ├── utils.ts # 공통 유틸리티 (지역 매핑, 유사도 계산) ├── search-station.ts # search_water_station_by_name ├── get-water-info.ts # get_water_info_by_location ├── recommend-stations.ts # recommend_nearby_stations └── openai-functions.ts # OpenAI Function 정의 ``` ### 🎯 **핵심 기능 변환** #### 1. **지역 매핑 로직** (TypeScript) ```typescript export const REGION_MAPPING: Record<string, string[]> = { '서울': ['서울', '한강', '청계천'], '부산': ['부산', '낙동강', '수영강'], // ... 16개 지역 완전 매핑 }; ``` #### 2. **유사도 계산** (한글 특화) ```typescript export function calculateSimilarity(station: Station, queryInfo: QueryInfo): number { let score = 0; // 키워드 직접 매칭 + 문자열 유사도 return Math.min(score, 1.0); } ``` #### 3. **API 엔드포인트** - `/.netlify/functions/search-station` - `/.netlify/functions/get-water-info` - `/.netlify/functions/recommend-stations` - `/.netlify/functions/openai-functions` ## 🌐 **Netlify 배포 단계** ### 1. **GitHub 연동** ```bash # GitHub 저장소 생성 후 git init git add . git commit -m "TypeScript Netlify Functions" git remote add origin https://github.com/username/hrfco-mcp.git git push -u origin main ``` ### 2. **Netlify 배포** 1. Netlify 대시보드에서 "New site from Git" 선택 2. GitHub 저장소 연결 3. 빌드 설정: - **Build command**: `npm run build` - **Publish directory**: `public` - **Functions directory**: `netlify/functions` ### 3. **환경변수 설정** Netlify 대시보드 → Site settings → Environment variables: ``` HRFCO_API_KEY = FE18B23B-A81B-4246-9674-E8D641902A42 ``` ## 🔧 **OpenAI Function Calling 연동** ### **Function 정의 가져오기** ```bash curl https://hrfco-mcp.netlify.app/.netlify/functions/openai-functions ``` ### **OpenAI API 호출 예제** ```javascript // ChatGPT API에서 이렇게 호출 const response = await fetch( 'https://hrfco-mcp.netlify.app/.netlify/functions/get-water-info', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: "한강 수위", limit: 3 }) } ); ``` ## 📊 **성능 최적화 유지** ### ✅ **응답 크기 제한** - **search-station**: ~346 bytes - **get-water-info**: ~399 bytes - **recommend-stations**: ~522 bytes - **모든 응답 1KB 미만 보장** ### ✅ **검색 정확도** - **지역 매핑**: 서울 → 서울 지역 관측소 자동 발견 - **강 이름 매칭**: 한강 → 한강 유역 관측소 매칭 - **유사도 검색**: 부분 일치 및 오타 허용 ## 🎉 **배포 후 예상 결과** ### **엔드포인트** ``` https://hrfco-mcp.netlify.app/.netlify/functions/search-station https://hrfco-mcp.netlify.app/.netlify/functions/get-water-info https://hrfco-mcp.netlify.app/.netlify/functions/recommend-stations ``` ### **OpenAI 연동** ChatGPT에서 자연어로 "한강 수위 알려줘" 요청 시: 1. OpenAI가 `get_water_info_by_location` 함수 호출 2. Netlify Function이 HRFCO API 조회 3. 지능형 검색으로 한강 관련 관측소 발견 4. 실시간 수위 데이터 반환 --- **🎯 핵심 성과**: Python 지능형 검색 시스템을 TypeScript로 완전 변환, Netlify 서버리스 배포 준비 완료!

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kwenhwang/hrfco-service'

If you have feedback or need assistance with the MCP directory API, please join our Discord server