使用说明
🌦️ 气象MCP服务器
模块化、支持异步的天气服务器,由 美国国家气象局API 和 FastMCP.使用 uv 用于快速和现代开发的Python工具链。
📦 项目概述
该项目提供:
- 🔔 天气警报 美国各州。
- 🌤️ 预测数据 按纬度/经度。
建立在 httpx 对于异步HTTP请求和 FastMCP 用于通过CLI或代理接口公开模块化工具。
🛠️ 入门指南
🧰 先决条件
- Python≥3.13
uv已安装(pip install uv)
🧑💻 Setup
# Create and enter the project directory
uv init weather
mv weather weather-mcp-server
cd weather-mcp-server
# Create virtual environment and activate it
uv venv
.venv\Scripts\activate # On Windows
# or
source .venv/bin/activate # On Unix
# Add dependencies
uv add mcp[cli] httpx
# Create your server file
touch weather.py # or use new-item on PowerShell
🚀 用法
运行MCP服务器
python weather.py
可用工具
🔹 获取活动天气警报
mcp run weather get_alerts --state TX
🔹 获取坐标预测
mcp run weather get_forecast --latitude 34.05 --longitude -118.25
返回加利福尼亚州洛杉矶未来5个时段的天气预报。
📁 项目结构
weather-mcp-server/
├── .venv/ # Virtual environment (created by uv venv)
├── pyproject.toml # Project config and dependencies
├── weather.py # MCP server with tools
└── README.md # Project documentation
⚙️ 使用的工具
📄 许可证
该项目根据MIT许可证获得许可。看 LICENSE 了解详情。