Token导航 LogoToken导航TokenDH.com
MCP Full Demo logo
AI代理stdio官方级别未说明来源级核验

MCP Full Demo

MCP Server

一个基于Model Context Protocol (MCP)的天气查询工具,通过Anthropic Claude模型和自定义天气MCP服务器,提供实时天气警报和预报查询功能。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
位置天气实时天气PythonClaudeAPI集成Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Ranxin2023

提供方

Ranxin2023

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python mcp_client/client.py weather/weather.py

详细介绍

🌤️ MCP天气助理

介绍

该项目演示了如何构建 工具增强会话人工智能 使用 模型上下文协议(MCP).\ 它连接了一个 人物克劳德 模型到a 自定义天气MCP服务器美国国家气象局(NWS API).

🚀 特性

  • FastMCP服务器 (weather.py)

- 显示以下工具: - get_alerts(state) → 获取美国各州的活跃天气警报。 - get_forecast(latitude, longitude) → 获取给定位置的详细天气预报。 - 使用官方 NWS API.

  • MCP客户端 (client.py)

- 启动MCP服务器并通过stdio连接。 - 与集成 人物克劳德 (claude-sonnet-4-5-20250929). - 让克劳德 自动调用天气工具 当响应用户查询时。 - 提供 交互式聊天循环 用户可以键入以下查询: > “显示加利福尼亚州的天气警报”\ > “37.77,-122.42附近的预测是什么?”

  • .env支持

- 通过自动加载您的Anthropic API密钥 dotenv.

🧠 运作原理

🧠 系统流程

User Query  →  MCP Client  →  Claude Model (via Anthropic API)
                    ↓
              MCP Server Tools
              ↙︎               ↘︎
    get_alerts(state)     get_forecast(lat, lon)

项目结构

BASICMCP/
│
├── mcp_client/
│   ├── .venv/                     # Virtual environment for MCP client
│   ├── .env                       # Stores Anthropic API key
│   ├── client.py                  # MCP client that connects to the weather server
│   ├── list_models.py             # Lists available Anthropic models
│   ├── code_explanation.md        # Explanation of the MCP client code
│   ├── pyproject.toml             # Project dependencies for MCP client
│   ├── uv.lock                    # uv dependency lock file
│   └── README.md                  # Documentation for the MCP client
│
├── weather/
│   ├── .venv/                     # Virtual environment for weather server
│   ├── weather.py                 # FastMCP server defining get_alerts & get_forecast tools
│   ├── StateCodes.py              # Contains state code mappings for NWS API
│   ├── main.py                    # Entry point to run the weather MCP server
│   ├── code_explanation.md        # Explanation of the weather server logic
│   ├── pyproject.toml             # Project dependencies for weather server
│   ├── uv.lock                    # uv dependency lock file
│   └── README.md                  # Documentation for the weather module
│
└── README.md                      # Main project documentation

架构概述

  1. weather.py (位于天气文件夹内)
  • 运行a FastMCP服务器 它定义了两个可调用的工具:

- get_alerts(state) → 获取美国某个州的当前天气警报。 - get_forecast(latitude, longitude) → 返回给定坐标的短期预测。

  1. client.py (位于mcp_client文件夹内)
  • 启动一个 MCP客户端 连接到天气服务器,初始化MCP会话,并允许通过Anthropic的Claude API进行交互。
  1. 当你问克劳德一个问题时,它可以决定 调用工具.
  2. 结果被发送回Claude进行推理和生成响应。

🛠️ 安装(使用紫外线)

1.安装uv

🪟 Windows(PowerShell)

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

🐧macOS/Linux

curl -LsSf https://astral.sh/uv/install.sh | sh

1.克隆存储库

git clone https://github.com/yourusername/mcp-weather-assistant.git
cd mcp-weather-assistant

2.设置虚拟环境

# Create a new directory for your project
uv init weather
cd weather

# Create virtual environment and activate it
uv venv
.venv\Scripts\activate

# Install dependencies
uv add mcp[cli] httpx anthropic python-dotenv

# (Optional) Create a new server file
New-Item weather.py

3.运行项目

python mcp_client/client.py weather/weather.py

使用代理技能的首次运行结果

Travel Briefing Result

目录标签

目录标签

位置天气实时天气PythonClaudeAPI集成天气查询本地部署MCP协议AI助手

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP