天气服务工具

一个基于MCP协议的AI天气应用,通过OpenRouter连接大型语言模型,提供实时天气警报和预报服务。

  • by nemesgyadam
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 nemesgyadam/mcp-boilerplate

使用说明

MCP锅炉板服务

使用(MCP)的现代人工智能天气应用程序https://github.com/modelcontextprotocol通过OpenRouter实现与大型语言模型的无缝工具集成。此软件包基于官方的anthropic教程,但修复了几个错误,并将提供者更改为openrouter。

概述

本项目演示了使用MCP构建的客户端-服务器架构:

  • MCP客户端:通过OpenRouter连接到LLM,处理对话流和工具执行
  • 气象局:一个MCP服务器,展示任何AI模型都可以调用的天气数据工具

特性

  • 🤖 将Claude 3(通过OpenRouter)与外部天气数据工具连接起来
  • 🌦️ 通过美国国家气象局API实时发布美国天气警报和预报
  • 🔄 具有完整对话上下文的工具增强模式
  • 🌐 与任何兼容OpenAI的API轻松集成

项目结构

metacortex/
├── mcp-client/        # Client connecting OpenRouter with MCP servers
│   └── client.py      # Main client implementation
└── weather/           # MCP server exposing weather tools
    └── weather.py     # Weather service implementation

入门指南

先决条件

  • Python 3.11+
  • OpenRouter API密钥

设置

  1. 克隆存储库
  2. 设置环境(每个组件都有自己的环境):
# For the MCP client
cd mcp-client
cp example.env .env  # Edit to add your OpenRouter API key
uv venv
uv pip install -e .

# For the weather service
cd ../weather
uv venv
uv pip install -e .

用法

  1. 与MCP客户端开始对话,指向天气服务:
cd mcp-client
python client.py ../weather/weather.py
  1. 询问有关天气预报或警报的问题:
    • 纽约市的天气预报是什么?纬度/经度是40.7128,-74.0060
    • “加利福尼亚州有天气警报吗?州代码是CA”

技术

  • (MCP) -AI工具使用协议
  • OpenRouter-用于访问多个LLM提供程序的API网关
  • Claude 3-具有函数调用功能的高级LLM
  • 美国国家气象局API-天气数据来源

许可证

麻省理工学院