날씨 MCP 도구(인도 중심)
OpenWeatherMap API를 사용하여 다음을 제공하는 MCP(모델 컨텍스트 프로토콜) 서버:
실시간 날씨 상황
5일 날씨 예보
대기질 데이터
위치 검색
🚀 설정
Python 3.10 이상 이 필요합니다.
종속성 설치:
지엑스피1
OpenWeatherMap 에서 API 키를 받으세요 .
루트 폴더에
.env.OPENWEATHER_API_KEY=your_api_key_here
Related MCP server: Weather Query MCP Server
🛠 사용 가능한 도구
get_current_weather(location: str)
주어진 위치의 현재 날씨를 반환합니다.
get_weather_forecast(location: str, days: int = 5)
해당 위치의 날씨 예보(최대 5일)를 반환합니다.
get_air_quality(location: str)
대기 질 지표와 AQI 수준을 반환합니다.
search_location(query: str)
쿼리에 따라 최대 5개의 위치 일치 항목을 반환합니다.
🧪 출력 예시(인도)
현재 날씨 (델리)
{
"location": {
"name": "Delhi",
"country": "IN",
"lat": 28.6139,
"lon": 77.2090
},
"temperature": {
"current": 32.4,
"feels_like": 35.1,
"min": 30.0,
"max": 36.2
},
"weather_condition": {
"main": "Haze",
"description": "smoky haze",
"icon": "50d"
},
"wind": {
"speed": 4.1,
"deg": 135
},
"clouds": 20,
"humidity": 58,
"pressure": 1005,
"visibility": 5000,
"sunrise": "2025-03-16T06:20:00",
"sunset": "2025-03-16T18:40:00",
"timestamp": "2025-03-16T14:30:00"
}
날씨 예보(뭄바이)
{
"location": {
"name": "Mumbai",
"country": "IN",
"lat": 19.0760,
"lon": 72.8777
},
"forecast": [
{
"datetime": "2025-03-16T12:00:00",
"temperature": {
"temp": 33.2,
"feels_like": 37.8,
"min": 31.5,
"max": 34.0
},
"weather_condition": {
"main": "Clouds",
"description": "scattered clouds",
"icon": "03d"
},
"wind": {
"speed": 3.9,
"deg": 200
},
"clouds": 40,
"humidity": 70,
"pressure": 1008,
"visibility": 10000,
"pop": 0.1
}
],
"days": 5
}
대기 질(방갈로르)
{
"location": {
"name": "Bengaluru",
"country": "IN",
"lat": 12.9716,
"lon": 77.5946
},
"air_quality_index": 2,
"air_quality_level": "Fair",
"components": {
"co": 102.4,
"no": 0.0,
"no2": 12.6,
"o3": 30.5,
"so2": 3.8,
"pm2_5": 45.1,
"pm10": 60.2,
"nh3": 1.5
},
"timestamp": "2025-03-16T14:30:00"
}
위치 검색
{
"results": [
{
"name": "Kolkata",
"state": "West Bengal",
"country": "IN",
"lat": 22.5726,
"lon": 88.3639
},
{
"name": "Kolkata",
"state": "",
"country": "IN",
"lat": 22.5675,
"lon": 88.3700
}
]
}
🧰 오류 처리
모든 도구는 명확한 오류 메시지를 반환합니다.
{ "error": "Location 'XYZ' not found" }
📌 참고사항
.env파일이 올바르게 구성되었는지 확인하세요.API 키를 활성화하는 데 시간이 걸릴 수 있습니다.
OpenWeatherMap 무료 계층: 분당 60개 API 호출.
🧑💻 서버 실행
mcp dev main.py
실행하면 이 서버를 Claude Desktop이나 다른 자동화 도구와 같은 MCP 호환 클라이언트와 함께 사용할 수 있습니다.