# weather_mcp_server **Repository Path**: boliu15/weather_mcp_server ## Basic Information - **Project Name**: weather_mcp_server - **Description**: 一个基于 Model Context Protocol (MCP) 的天气查询服务器,支持中国城市天气查询(高德API)和美国地区天气查询(NWS API)。 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-17 - **Last Updated**: 2025-12-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Weather MCP Server [![Python Version](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) [![MCP](https://img.shields.io/badge/MCP-1.0+-orange.svg)](https://modelcontextprotocol.io/) 一个基于 Model Context Protocol (MCP) 的天气查询服务器,支持中国城市天气查询(高德API)和美国地区天气查询(NWS API)。 ## ✨ 特性 - 🌏 **中国城市天气查询**:支持实时天气和未来天气预报(高德API) - 🇺🇸 **美国地区天气查询**:支持经纬度查询和天气警报(NWS API) - 🤖 **Claude Desktop 集成**:可直接在 Claude Desktop 中使用 - 🚀 **简单易用**:一键安装,配置即用 - 📦 **独立打包**:可打包分发给其他用户 ## 📦 快速安装 ### 方法1:从源码安装 ```bash # 克隆或下载项目 git clone https://gitee.com/boliu15/weather_mcp_server.git # 进入目录 cd weather_mcp_server # 安装build打包工具 python -m pip install build # 手动打包 python -m build # 安装生成的包 pip install dist/weather_mcp_server-0.1.0-py3-none-any.whl # 卸载已经安装的服务 pip uninstall weather-mcp-server ``` ## 🚀 使用方法 ``` ### 2. 配置 Claude Desktop 编辑配置文件:`%APPDATA%\Claude\claude_desktop_config.json`(Windows) ```json { "mcpServers": { "weather": { "command": "weather-mcp-server", "env": { "GAODE_API_KEY": "你的高德API密钥(可选)" } } } } ``` **Linux/Mac 配置文件路径:** - Linux: `~/.config/Claude/claude_desktop_config.json` - Mac: `~/Library/Application Support/Claude/claude_desktop_config.json` 重启 Claude Desktop 后即可使用! ## 📝 可用功能 ### 1. `get_weather(location)` 智能查询天气(支持中国城市或经纬度坐标) ```python # 查询城市 await get_weather("北京") # 查询经纬度(美国) await get_weather("39.7456,-104.9922") ``` ### 2. `get_china_weather(city)` 获取中国城市当前天气 ```python await get_china_weather("北京") # 城市名 await get_china_weather("110000") # 城市编码 ``` ### 3. `get_china_weather_forecast(city)` 获取中国城市未来天气预报 ```python await get_china_weather_forecast("上海") ``` ### 4. `get_forecast(latitude, longitude)` 获取美国地区天气预报 ```python await get_forecast(39.7456, -104.9922) ``` ### 5. `get_alerts(state)` 获取美国州的天气警报 ```python await get_alerts("CA") # 加利福尼亚州 ``` ## 📚 相关资源 - [MCP 官方文档](https://modelcontextprotocol.io/) - [FastMCP 文档](https://github.com/jlowin/fastmcp) - [高德天气API](https://lbs.amap.com/api/webservice/guide/api/weatherinfo) - [NWS API](https://www.weather.gov/documentation/services-web-api) ## 📄 许可证 本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件 ## 🤝 贡献 欢迎提交 Issue 和 Pull Request! ## 📧 联系方式 如有问题或建议,请提交 Issue 或联系维护者。 ---