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

MCP Openweather

MCP Server

一个基于Google Gemini 2.5 Flash模型的多代理系统,通过Model Context Protocol (MCP)服务器提供天气查询和计算功能。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
位置天气PythonAI代理

安装说明

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

作者 / 组织

Ovi-Poddar

提供方

Ovi-Poddar

最后核验

2026/5/17 20:22

运行时

Python

快速接入

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

命令预览

python -m venv venv

详细介绍

气象代理与MCP&Gemini

一个多智能体系统,使用 模型上下文协议(MCP) 服务器使用谷歌的Gemini 2.5 Flash模型回答天气和计算查询。

建筑

  • AI模型:谷歌Gemini 2.5 Flash(免费版)
  • 框架:LangGraph(代理工作流)
  • MCP服务器:天气(Go)+计算器(Python)
  • 工具:通过tool_use功能绑定到Gemini

______________________________________________________________________

先决条件

  • Python 3.10+ (或Python 3.14)
  • 转到1.16+ (用于构建天气服务器)
  • Git (用于克隆存储库)
  • (Python包管理器)

______________________________________________________________________

安装说明

第一步:创建Python虚拟环境

python -m venv venv

# On Windows:
.\venv\Scripts\Activate.ps1

# On macOS/Linux:
source venv/bin/activate

步骤2:安装Python依赖项

pip install -r requirements.txt

requirements.txt包括:

  • python-dotenv -环境变量管理
  • langchain-google-genai -Gemini集成
  • langchain-mcp-adapters -MCP协议支持
  • langgraph -代理工作流编排
  • mcp -MCP协议实现
  • mcp-server-calculator -计算器MCP服务器

______________________________________________________________________

设置MCP服务器

气象MCP服务器(Go)

步骤1:安装Go

从以下位置下载并安装:https://go.dev/dl/

步骤2:克隆和构建

git clone https://github.com/mschneider82/mcp-openweather.git
cd mcp-openweather
go build -o mcp-weather.exe

步骤3:获取OpenWeatherMap API密钥

  1. 访问https://openweathermap.org/api
  2. 创建免费帐户
  3. 生成并复制API密钥(称为 appid)
  4. 注意:API密钥可能需要几个小时才能激活

步骤4:验证可执行文件

建造完成后,确认 mcp-weather.exe 存在于 mcp-openweather 文件夹。

______________________________________________________________________

计算器MCP服务器(Python)

计算器服务器通过pip安装:

pip install mcp-server-calculator

这为代理提供了算术和计算能力。

______________________________________________________________________

配置

环境变量

创建一个 .env 项目根目录中的文件:

GOOGLE_API_KEY=your_gemini_api_key_here
OWM_API_KEY=your_openweathermap_api_key_here

获取Gemini API密钥:

  1. 访问https://aistudio.google.com/app/apikey
  2. 创建新的API密钥
  3. 复制并粘贴到 .env

______________________________________________________________________

运行代理

终端设置(需要3个终端)

终端1——气象MCP服务器:

cd mcp-openweather
.\mcp-weather.exe

⚠️ 让它在后台运行。

终端2–计算器MCP服务器:

python -m mcp_server_calculator

⚠️ 让它在后台运行。

3号航站楼——您的客户(主代理):

# Activate virtual environment (if not already active)
.\venv\Scripts\Activate.ps1

# Run the agent
python weather_mcp.py

______________________________________________________________________

使用代理

运行后,您将看到提示:

--- Weather Query ---

Ask me anything (weather or calculation) → 

查询示例

天气:

  • “伦敦今天天气怎么样?”
  • “东京现在的温度?”
  • “孟加拉国达卡的天气?”

计算:

  • “152乘以8是多少?”
  • “计算1000除以25”
  • “99+101是什么?”

混合的:

  • “柏林的天气怎么样,计算一下华氏5°C有多冷?”

调试输出

代理提供详细的调试信息:

[DEBUG] Message audit:
  [0] HumanMessage
  [1] AIMessage with tool_calls: ['weather']
  [2] ToolMessage (tool executed successfully)
  [3] AIMessage (no tool calls - model answered directly)

[DEBUG] Tool used: YES

这证实了答案是来自MCP工具还是直接来自模型。

______________________________________________________________________

运作原理

消息流

  1. 用户输入 →人道信息
  2. 双子座分析 → 决定调用哪个工具
  3. 带有工具调用的AIMessage → 列出工具名称(天气、计算器)
  4. 工具消息 → MCP服务器执行并返回数据
  5. A消息(综合) → Gemini为用户格式化最终答案

工具集成

  • 天气工具:返回当前天气、温度、湿度、风、压力
  • 计算器工具:执行数学运算
  • 签名:当Gemini收到工具数据时,它会在响应中签名 'extras': {'signature': ...}

______________________________________________________________________

文件结构

mcp-openweather/
├── weather_mcp.py          # Main agent script
├── .env                    # API keys (not in repo)
├── requirements.txt        # Python dependencies
├── README.md              # This file
├── mcp-openweather/
│   ├── main.go            # Weather server source
│   ├── mcp-weather.exe    # Built executable
│   └── go.mod             # Go dependencies
└── venv/                  # Virtual environment

______________________________________________________________________

快乐查询! 🚀

目录标签

目录标签

位置天气PythonAI代理天气查询本地部署计算工具多代理系统Gemini模型MCP协议

接入字段

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

stdio

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

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdionone部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP