weather-mcp
🌦️ Weather MCP RAG Assistant
一个基于 Model Context Protocol (MCP)、检索增强生成 (RAG)、LangChain、ChromaDB、Groq LLM 和 OpenWeather API 构建的 AI 天气助手。
该项目提供了一个自定义的 MCP 工具,用于检索实时天气数据,并将其与 RAG 流水线相结合,以生成具有上下文感知的自然语言天气洞察。
🚀 主要功能
使用 FastMCP 构建的自定义 MCP 服务器
使用 OpenWeather API 实时检索天气数据
用于上下文响应的 检索增强生成 (RAG) 流水线
用于存储和检索天气上下文的 ChromaDB 向量存储
使用
all-MiniLM-L6-v2的 Sentence Transformer 嵌入通过 LangChain 集成 Groq 托管的 LLM
与 VS Code / GitHub Copilot 的 MCP 工具集成
支持针对不同城市的动态天气查询
使用环境变量进行安全的 API 密钥管理
Related MCP server: Weather MCP Server
🧠 工作原理
User Query
↓
GitHub Copilot / MCP Client
↓
Weather MCP Server
↓
get_weather(location)
↓
OpenWeather API
↓
Weather Data Processing
↓
ChromaDB Vector Store
↓
RAG Retrieval
↓
Groq LLM
↓
Context-Aware Weather Response🛠️ 技术栈
语言: Python
AI / GenAI: LLMs、RAG、提示工程、Sentence Transformers
框架: LangChain、FastMCP
向量数据库: ChromaDB
LLM 提供商: Groq
外部 API: OpenWeather API
协议: Model Context Protocol (MCP)
开发环境: VS Code、Git、GitHub
📂 项目结构
Weather-MCP-RAG-Assistant/
│
├── rag/
│ ├── embedding.py
│ ├── llm.py
│ ├── retriever.py
│ └── vector_store.py
│
├── services/
│ └── weather_service.py
│
├── utils/
│ └── parser.py
│
├── config.py
├── server.py
├── requirements.txt
├── env.example
├── .gitignore
└── README.md⚙️ 设置
1. 克隆仓库
git clone https://github.com/rudraniai/Weather-MCP-RAG-Assistant.git
cd Weather-MCP-RAG-Assistant2. 创建虚拟环境
python -m venv .venv在 Windows 上激活:
.venv\Scripts\activate3. 安装依赖
pip install -r requirements.txt4. 配置环境变量
复制示例环境文件:
copy env.example .env将你的凭据添加到 .env:
OPENWEATHER_API_KEY=your_openweather_api_key
GROQ_API_KEY=your_groq_api_key
GROQ_MODEL=your_groq_model
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
CHROMA_DB_DIR=./chroma_db使用
.gitignore将 API 凭据排除在版本控制之外。
5. 运行 MCP 服务器
python server.py🔌 MCP 配置
在 VS Code 中使用以下配置本地 MCP 服务器:
{
"servers": {
"weather-mcp": {
"type": "stdio",
"command": "python",
"args": [
"PATH_TO_PROJECT/server.py"
]
}
},
"inputs": []
}将 PATH_TO_PROJECT 替换为 server.py 的本地路径。
配置完成后:
打开 VS Code 命令面板。
选择
MCP: List Servers。选择
weather-mcp。启动 MCP 服务器。
打开 GitHub Copilot Chat,并在请求时允许 MCP 工具。
🎥 项目演示
以下演示展示了通过 GitHub Copilot 调用自定义 weather-mcp MCP 工具来检索和生成上下文天气信息的过程。

💬 示例用法
向 Copilot 提问:
Use the weather-mcp MCP tool to get the weather in Pune.其他示例:
Use the weather-mcp MCP tool to get the weather in Mumbai.
Use the weather-mcp MCP tool to get the weather in Nagpur.助手返回的示例信息包括:
当前温度
体感温度
湿度
风速和风向
云量状况
天气摘要
空气质量信息(如有)
🔐 安全性
API 密钥等敏感凭据存储在本地 .env 文件中。
以下文件/目录被排除在 Git 之外:
.env
chroma_db/
__pycache__/
.vscode/切勿将真实的 API 密钥提交到仓库中。
📌 所学内容
通过这个项目,我获得了以下方面的实践经验:
通过 Model Context Protocol (MCP) 构建和暴露工具
将外部 API 与基于 LLM 的应用程序集成
实现 RAG 流水线
使用嵌入和向量数据库
使用 ChromaDB 进行上下文检索
将 LangChain 与托管的 LLM 连接
将自定义 MCP 服务器与 GitHub Copilot 集成
安全管理环境变量和 API 凭据
🔮 未来改进
添加多日天气预报
添加天气警报和建议
改进检索和上下文记忆
添加更多天气和环境数据源
使用 Streamlit 或 FastAPI 构建独立的 Web 界面
使用 Docker 将应用程序容器化
👩💻 作者
Rudrani Gulhane
计算机科学与工程学士——人工智能与机器学习
对 AI/ML、生成式 AI、RAG、LLMs、AI 智能体以及基于 MCP 的应用程序 感兴趣。
📄 许可证
本项目仅供教育、作品集和实验用途。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI agents to fetch real-time weather data for any location using the OpenWeatherMap API. Demonstrates how to build a simple MCP server that exposes weather information as a tool for LLMs.1GPL 3.0
- FlicenseNot gradedqualityDmaintenanceProvides real-time weather updates and city geocoding by integrating the Nominatim and Open-Meteo APIs. It enables users to retrieve current weather conditions for any location through natural language queries in MCP-compatible clients.15
- AlicenseNot gradedqualityDmaintenanceProvides weather data from OpenWeatherMap API through MCP tools and a REST API with OpenAPI support. Enables LLM agents to retrieve current weather, forecasts, and temperature ranges by city or coordinates.21MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents like GitHub Copilot to retrieve real-time weather data for any city using the Open-Meteo API, no API key required.9
Related MCP Connectors
OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)
Open-Meteo MCP — weather forecast + historical reanalysis + sister APIs
WeatherAPI.com MCP — wraps WeatherAPI.com (api.weatherapi.com)
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rudraniai/Weather-MCP-RAG-Assistant'
If you have feedback or need assistance with the MCP directory API, please join our Discord server