We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/woongaro/KMA-WEATHER-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import sys
import os
import asyncio
from dotenv import load_dotenv
# Ensure import works
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
try:
from server import fetch_ultra_srt_ncst, get_ultra_short_term_forecast, convert_latlon_to_grid
except ImportError:
# Fallback if running from root
sys.path.append(os.path.join(current_dir, "src"))
from src.server import fetch_ultra_srt_ncst, get_ultra_short_term_forecast, convert_latlon_to_grid
load_dotenv()
async def main():
# Gangnam-gu Office Coordinates
lat = 37.5172
lon = 127.0473
nx, ny = convert_latlon_to_grid(lat, lon)
print(f"๐ Gangnam-gu ({lat}, {lon}) -> Grid ({nx}, {ny})")
print("\n1๏ธโฃ Fetching Current Weather...")
try:
import json
result_str = await fetch_ultra_srt_ncst(nx, ny)
data = json.loads(result_str)
try:
items = data['response']['body']['items']['item']
weather = {}
for item in items:
weather[item['category']] = item['obsrValue']
t1h = float(weather.get('T1H', -999))
pty = int(weather.get('PTY', 0))
reh = float(weather.get('REH', 0))
wsd = float(weather.get('WSD', 0))
pty_map = {0: "์์", 1: "๋น", 2: "๋น/๋", 3: "๋", 5: "๋น๋ฐฉ์ธ", 6: "๋น๋ฐฉ์ธ/๋๋ ๋ฆผ", 7: "๋๋ ๋ฆผ"}
pty_str = pty_map.get(pty, str(pty))
print(f" ๐ก๏ธ ๊ธฐ์จ: {t1h} โ")
print(f" ๐ง ์ต๋: {reh} %")
print(f" ๐ฌ๏ธ ํ์: {wsd} m/s")
print(f" โ ๊ฐ์: {pty_str}")
if t1h < 0:
print(" ๐ฅถ ๊ฒฐ๋ก : ์ํ๊ถ์
๋๋ค. ๋งค์ฐ ์ถฅ์ต๋๋ค.")
elif t1h < 5:
print(" ๐งฅ ๊ฒฐ๋ก : ์์ํฉ๋๋ค. ๋๊บผ์ด ์ธํฌ๊ฐ ํ์ํฉ๋๋ค.")
else:
print(" ๐ ๊ฒฐ๋ก : ๋ง์ด ์ถฅ์ง๋ ์์ต๋๋ค.")
except (KeyError, ValueError) as e:
print(f"โ ๏ธ ๋ฐ์ดํฐ ํ์ฑ ์คํจ: {e}")
print(f"Raw: {result_str[:200]}...")
except Exception as e:
print(f"โ Error: {e}")
if __name__ == "__main__":
asyncio.run(main())