Weather-MCP-with-Playwright
使用 MCP、Gemini 和 Playwright 的 AI 天气代理
概述
本项目实现了一个 AI 代理,使用模型上下文协议(MCP)、Google Gemini 和 Playwright 获取以色列城市的当前天气信息。
当用户询问某个城市的天气时,代理会打开天气网站,搜索所请求的城市,从页面中提取天气信息,并根据网站内容返回答案。
该项目还包含一个简单的检索步骤,即从网页中提取天气信息,并将其作为附加上下文提供给语言模型,然后再生成最终响应。
技术栈
Python
Google Gemini API
MCP(模型上下文协议)
Playwright
AsyncIO
python-dotenv
项目结构
host.py # Main chat application
client.py # MCP client
weather_Israel.py # MCP weather server
README.md
requirements.txt工作原理
用户询问以色列某个城市的天气。
Gemini 选择适当的 MCP 工具。
Playwright 打开天气网站。
在搜索框中输入所请求的城市。
从自动完成列表中选择该城市。
加载天气页面。
从页面中提取天气信息。
将提取的文本返回给 Gemini。
Gemini 使用提取的信息生成最终答案。
功能特点
支持以色列城市的天气查询。
接受希伯来语或英语的城市名称。
使用 Playwright 导航实时天气网站。
直接从网站提取天气信息。
在回答之前将提取的内容提供给语言模型。
使用网站内容,而不是依赖模型的内部知识。
安装
克隆仓库:
git clone https://github.com/YisNiz/AI-MCP-with-RAG-project安装所需的包:
pip install -r requirements.txt创建一个包含以下内容的 .env 文件:
GEMINI_API_KEY=YOUR_API_KEY安装 Playwright 浏览器:
playwright install运行项目:
python host.py示例问题
耶路撒冷的天气怎么样?
特拉维夫的天气
מזג האוויר בחיפה
מה מזג האוויר בבאר שבע?
备注
天气信息从实时天气网站获取。
语言模型被指示使用提取的网站内容来回答。
该项目展示了 LLM 与 MCP 工具及浏览器自动化的集成。
作者
Yisca Nazri
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 Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server for Google Veo AI video generation
MCP server for Grok Imagine AI video generation
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/leahlevovitz/Weather-MCP-with-Playwright'
If you have feedback or need assistance with the MCP directory API, please join our Discord server