
mcp-weather

2025.03.30
0
Python天气服务AI Agent工具位置服务
mcp-weather 是一个为 AI Agent 提供的 MCP Server 示例,用于获取美国各州的天气预报和警示信息。它基于 SSE(Server-Sent Events)技术,支持远程连接和解耦的进程模式,适合云原生应用场景。
View on GitHub
Overview
基本能力
产品定位
mcp-weather 是一个天气信息服务,专门为 AI Agent 提供美国各州的天气数据和警示信息。
核心功能
- 提供美国各州的天气预报 (
get_forecast
) - 提供美国各州的天气警示 (
get_alerts
) - 基于 SSE 的 MCP 服务器,支持远程连接和解耦的进程模式
适用场景
- AI Agent 需要获取天气信息的场景
- 云原生应用中的天气数据服务
- 需要实时天气数据的自动化系统
工具列表
get_alerts
: 获取指定州的天气警示信息get_forecast
: 获取指定经纬度的天气预报信息
常见问题解答
- 为什么使用 SSE?SSE 允许服务器和客户端解耦,适合云原生用例。
- 如何修改服务器地址和端口?可以通过命令行参数
--host
和--port
进行配置。
使用教程
使用依赖
- 安装 uv 依赖管理工具:
$ curl -LsSf https://astral.sh/uv/install.sh | sh
- 安装 Node.js 和 npm:
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
# Download and install Node.js:
nvm install 22
安装教程
- 下载源代码:
$ git clone https://github.com/erhwenkuo/mcp-weather.git
$ cd mcp-weather
$ uv sync
- 启动服务:
$ uv run server
或者使用 Docker:
$ docker build -t mcp-weather .
$ docker run -d -p 5488:5488 mcp-weather
调试方式
- 启动 MCP inspector:
$ npx @modelcontextprotocol/inspector
- 在浏览器中打开
http://localhost:5173
- 选择 Transport Type 为
SSE
- 输入服务器地址
http://localhost:5488/sse
- 点击
Connect
测试连接 - 在 Tools Tab 中测试
get_alerts
和get_forecast
工具