Weather-MCP
🌤️ — 以色列天气预报
一个关于开发 MCP(模型上下文协议) 的学习项目:一个基于 LLM 的智能体(Agent),能够获取以色列和美国城市的天气预报,并在终端聊天中以自由语言回答。
🎯 项目目标
构建一个专用的 MCP 服务器,用于“教会”LLM 完成它自己无法完成的任务——从没有 API 的以色列网站获取天气预报。
智能体通过两种方式完成此任务:
以色列服务器(
weather-Israel) — 使用 Playwright 操作真实浏览器:打开 weather2day.co.il/forecast,搜索城市,选择城市,然后提取天气预报页面内容并将其提供给 LLM,以便它自行回答(RAG 方法)。美国服务器(
weather-USA) — 通过 NWS(美国国家气象局)的官方 API 获取天气预报和警报。
Host 将所有服务器连接到 LLM(Gemini,通过兼容 OpenAI 的 API),自动收集所有工具,并运行一个聊天循环,由 LLM 决定使用哪个工具并逐一调用它们,直到获得答案。
Related MCP server: mcp-playwright-weather-israel
🏗️ 项目结构
project-template/
├── host.py # צ'אט בטרמינל שמחבר את ה-LLM לכל שרתי ה-MCP
├── client.py # MCP Client גנרי (מתחבר לשרת, מריץ Tools)
├── weather_USA.py # שרת MCP לארה"ב — דרך NWS API
├── weather_Israel.py # שרת MCP לישראל — דרך אטמוט דפדפן (Playwright)
├── pyproject.toml # תלויות הפרויקט
└── README.md以色列服务器的工具
# | 工具 | 功能 |
1 |
| 打开 Chromium 浏览器并导航到天气预报网站 |
2 |
| 在搜索框中输入城市名称 |
3 |
| 从建议列表中选择第一个城市 |
4 |
| 提取天气预报页面内容(包括 iframes)并将其返回给 LLM |
💡 前三个工具通过全局状态(
_page)共享同一个浏览器,因为它们都在同一个服务器进程中运行。第四个工具会遍历页面上的所有 frames,因为预报本身是加载在<iframe>中的,而主body中看不到。
⚙️ 安装与运行
前置要求
步骤
# 1. התקנת התלויות והקמת סביבת העבודה
uv sync
# 2. התקנת דפדפן Chromium עבור Playwright
uv run playwright install chromium设置环境变量
在项目目录中创建 .env 文件:
GEMINI_API_KEY=your_api_key_here
GEMINI_MODEL=gemini-2.0-flash运行
uv run host.py启动后会出现 Query: 提示符——输入问题(或输入 quit 退出)。
💬 问题示例
以色列天气预报(Playwright)
会打开一个浏览器窗口,您可以看到天气预报页面,同时 LLM 也会在聊天中回答。
“特拉维夫的天气预报是什么?”
“耶路撒冷明天预计多少度?”
“今天海法的天气怎么样?”
“打开贝尔谢巴的天气预报给我看”
美国天气预报和警报(NWS API)
“旧金山的天气预报是什么?” (纬度/经度)
“加利福尼亚州有天气警报吗?”
“显示纽约的活跃警报”
🧩 工作原理(流程图)
משתמש → "מה התחזית בתל אביב?"
│
▼
Host ──► LLM (Gemini) בוחר Tools להפעיל
│
▼ (שרת ישראל, בזה אחר זה)
open → enter("תל אביב") → select → get_content
│
▼
תוכן התחזית חוזר ל-LLM (RAG)
│
▼
LLM כותב תשובה בשפה חופשית בצ'אט ✨📝 备注
是 LLM 决定调用哪些工具以及调用顺序——我们没有编写任何硬编码逻辑。
两个服务器文件 = 两个独立进程,因此任何共享状态(如打开的浏览器页面)只能存在于单个服务器内部。
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
- FlicenseAqualityCmaintenanceMCP server enabling LLMs to fetch Israeli weather forecasts by automating a browser with Playwright to scrape weather2day.co.il.4
- FlicenseAqualityCmaintenanceAn MCP server that uses Playwright to scrape Israeli weather forecasts from weather2day.co.il by automating a real browser, enabling an LLM to answer questions about current conditions and hourly forecasts for Israeli cities.5
- FlicenseNot gradedqualityCmaintenanceMCP server that lets users obtain current Israeli city weather forecasts. It uses Playwright to browse Weather2day, extract the forecast page, and feed the cleaned data back to the LLM for natural language responses.
- FlicenseAqualityCmaintenanceAn MCP server that provides real-time weather data for Israel by automating browser searches via Playwright. It allows LLMs to get current forecasts for Israeli cities through natural language queries.4
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server exposing the Backtest360 engine API as tools for AI agents.
Hosted MCP server to manage a restaurant menu from AI agents - 39 tools over the DuckHub API.
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/Efrat-Fr/Weather-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server