Skip to main content
Glama

Weather MCP Server

by ctermiii
test-simple.js2.07 kB
#!/usr/bin/env node /** * 简单测试 - 只测试API调用 */ async function testAPI() { console.log('测试 Open-Meteo API...\n'); try { // 测试地理编码 const geoUrl = 'https://geocoding-api.open-meteo.com/v1/search?name=Beijing&count=1&language=zh&format=json'; console.log('1. 测试地理编码...'); const geoResponse = await fetch(geoUrl); const geoData = await geoResponse.json(); console.log('✅ 地理编码成功:', geoData.results[0]); const lat = geoData.results[0].latitude; const lon = geoData.results[0].longitude; // 测试天气API const weatherUrl = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}&current=temperature_2m,relative_humidity_2m,apparent_temperature,weathercode,windspeed_10m,winddirection_10m,uv_index,pm2_5,pm10&daily=temperature_2m_max,temperature_2m_min,weathercode,precipitation_sum,rain_sum,snowfall_sum,windspeed_10m_max,windgusts_10m_max,winddirection_10m_dominant,sunrise,sunset,uv_index_max&forecast_days=7&timezone=auto`; console.log('\n2. 测试天气API...'); const weatherResponse = await fetch(weatherUrl); const weatherData = await weatherResponse.json(); console.log('✅ 天气数据成功'); console.log('\n返回的数据键:', Object.keys(weatherData)); if (weatherData.error) { console.error('⚠️ API 返回错误:', weatherData.error); console.error('原因:', weatherData.reason); } console.log('Current 数据:', weatherData.current ? '存在' : '不存在'); console.log('Daily 数据:', weatherData.daily ? '存在' : '不存在'); if (weatherData.current) { console.log('\nCurrent 数据键:', Object.keys(weatherData.current)); } if (weatherData.daily) { console.log('Daily 数据键:', Object.keys(weatherData.daily)); console.log('预报天数:', weatherData.daily.time?.length || 0); } console.log('\n✅ 所有测试通过!'); } catch (error) { console.error('\n❌ 测试失败:', error.message); } } testAPI();

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/ctermiii/weather-mcp-metro'

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