MCP 天气服务示例

MCP 天气服务示例

提供一个基于 AI Agent 的 MCP Server 示例,用于获取美国各州天气预报与警报信息。

快速入门

环境准备

  1. 安装 uv 工具:
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. 克隆项目并安装依赖:
    git clone https://github.com/erhwenkuo/mcp-weather.git
    cd mcp-weather
    uv sync
    

启动服务

使用 uv 运行:

uv run server

服务默认运行在 http://0.0.0.0:8080

使用 Docker 运行:

  1. 构建镜像:
    docker build -t mcp-weather .
    
  2. 启动容器:
    docker run -d -p 5488:5488 mcp-weather
    

测试工具

  1. 安装 Node.js 并启动 MCP Inspector:
    npx @modelcontextprotocol/inspector
    
  2. 打开浏览器访问 http://localhost:5173,连接到 http://localhost:5488/sse
  3. 使用 Tools 面板测试 get_alertsget_forecast 功能。