Used for configuration management by loading environment variables from a .env file, specifically for storing the OpenWeatherMap API key and other configuration settings
Provides data validation and parsing for weather API requests and responses, ensuring proper data structure and types
Core runtime environment for the weather server, with the server implementation written in Python
Used for configuration and data serialization within the weather server implementation
<<<<<<< HEAD <<<<<<< HEAD
Weather Server
全球天气查询MCP服务器 - 提供实时天气、天气预报和多城市天气比较功能
🌤️ 功能特性
- 实时天气查询: 获取任意城市的当前天气信息
- 坐标天气查询: 支持经纬度坐标查询天气
- 天气预报: 提供最多5天的天气预报
- 多城市比较: 同时查询多个城市的天气信息
- 多语言支持: 支持中英文等多种语言
- 智能提示: 根据查询类型生成相应的提示模板
🚀 快速开始
1. 环境配置
首先需要获取OpenWeatherMap API密钥:
- 访问 OpenWeatherMap 注册账号
- 获取免费的API密钥
- 配置环境变量:
2. 安装依赖
3. 启动服务器
🛠️ 可用工具
1. 城市天气查询
city
: 城市名称(必填)country
: 国家代码(选填,如 "CN", "US")units
: 温度单位(metric/imperial/kelvin)
示例:
get_weather_by_city("Beijing")
get_weather_by_city("New York", "US")
get_weather_by_city("London", "GB", "imperial")
2. 坐标天气查询
latitude
: 纬度longitude
: 经度units
: 温度单位
示例:
get_weather_by_coordinates(39.9042, 116.4074)
# 北京get_weather_by_coordinates(40.7128, -74.0060)
# 纽约
3. 天气预报
city
: 城市名称country
: 国家代码(选填)days
: 预报天数(1-5天)units
: 温度单位
示例:
get_weather_forecast("Shanghai", "CN", 3)
get_weather_forecast("Paris", "FR", 5, "metric")
4. 多城市天气比较
cities
: 城市列表,支持 "城市名,国家代码" 格式units
: 温度单位
示例:
get_multiple_cities_weather(["Beijing", "Shanghai", "Guangzhou"])
get_multiple_cities_weather(["New York,US", "London,GB", "Tokyo,JP"])
📊 返回数据格式
当前天气返回数据
天气预报返回数据
📋 资源功能
1. API配置信息
返回天气API的配置信息和使用说明。
2. 支持的城市列表
返回常用城市列表和使用示例。
💡 提示模板
天气查询提示
query_type
: 查询类型(current/forecast/multiple/coordinates)location
: 位置信息context
: 额外上下文
根据查询类型和语言环境生成相应的提示模板。
🌍 支持的城市
服务器支持全球任意城市的天气查询,包括但不限于:
🇨🇳 中国
- 北京 (Beijing)
- 上海 (Shanghai)
- 广州 (Guangzhou)
- 深圳 (Shenzhen)
- 香港 (Hong Kong)
🇺🇸 美国
- 纽约 (New York)
- 洛杉矶 (Los Angeles)
- 芝加哥 (Chicago)
- 旧金山 (San Francisco)
🇬🇧 欧洲
- 伦敦 (London)
- 巴黎 (Paris)
- 柏林 (Berlin)
- 罗马 (Rome)
🇯🇵 亚洲
- 东京 (Tokyo)
- 首尔 (Seoul)
- 新加坡 (Singapore)
- 孟买 (Mumbai)
⚠️ 注意事项
- API密钥必填: 需要配置有效的OpenWeatherMap API密钥
- 请求限制: 免费账户每天限制1000次请求
- 网络要求: 需要稳定的网络连接访问外部API
- 错误处理: 所有API调用都包含错误处理和友好的错误消息
🔧 故障排除
常见问题
- API密钥错误
- 检查
.env
文件中的WEATHER_API_KEY
是否正确 - 确认API密钥是否已激活
- 检查
- 网络连接问题
- 检查网络连接
- 确认防火墙设置
- 城市名称无法识别
- 尝试使用英文城市名
- 添加国家代码,如 "Beijing,CN"
- 返回数据为空
- 检查城市名称拼写
- 确认该城市是否存在于OpenWeatherMap数据库中
📜 许可证
MIT License
🤝 贡献
欢迎提交Issue和Pull Request来改进这个项目!
由 MCP Factory 生成
weather-server
MCP server: weather-server
origin/main =======
weather-server
MCP server: weather-server
origin/main
This server cannot be installed
Provides global weather query services with features including real-time weather, weather forecasting, and multi-city weather comparison.
Related MCP Servers
- -securityAlicense-qualityWeather forecast server which returns 7 days of detailed weather anywhere in the world, using the OpenWeatherMap One Call API 3.0.Last updated -3PythonMIT License
- AsecurityAlicenseAqualityProvides Swiss weather forecast data, allowing users to search for Swiss locations and get detailed hourly and daily weather forecasts.Last updated -21JavaScriptMIT License
- -securityFlicense-qualityA standardized API server that enables AI agents and client applications to fetch current weather information for any location without directly interacting with external weather APIs.Last updated -Python
- AsecurityAlicenseAqualityA Model Context Protocol server that provides real-time weather data and forecasts for any city.Last updated -18ISC License