本项目提供了一个Weather MCP服务器,借助OpenWeatherMap的One Call API 3.0,能够获取特定地区的当前天气和未来8天的天气预报,为用户提供风速、降水量等详细的天气信息。
pip install openweathermap-api python-multipart
OPENWEATHER_API_KEY:export OPENWEATHER_API_KEY="your_api_key"
api_key 参数。python3 weather_mcp_server.py
get_weather 和 get_current_weather。# 获取当前天气
python3 weather_mcp_server.py --current-weather --city New York
# 获取天气预报
python3 weather_mcp_server.py --weather-forecast --location "Beijing,China"
{
"city": "New York",
"state": "NY",
"country": "US"
}
{
"current_weather": {
"temperature": 22,
"condition": "Partly Cloudy",
"wind_speed": 12,
"humidity": 65
},
"hourly_forecast": [...],
"daily_forecast": [...]
}
python test_weather_mcp.py
python integration_test.py
# 运行测试客户端
python3 weather_test_client.py --test-all
2023年11月4日