MCP-with-Playwright
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP-with-Playwright what's the weather in Tel Aviv?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
שרת MCP למזג אוויר בישראל (Playwright & Gemini) 🌦️🤖
מימוש של שרת מבוסס פרוטוקול הקשר למודלים (MCP - Model Context Protocol) המעניק למודל שפה גדול (LLM) יכולות שליטה אוטומטיות בדפדפן (Browser Use). הפרויקט משתמש בספריית Playwright כדי לנונווט, לבצע אינטראקציה ולשלוף נתוני מזג אוויר בזמן אמת מאתר התחזית הישראלי, תוך ביצוע לולאת RAG (Retrieval-Augmented Generation) מלאה ואוטונומית ישירות בתוך הטרמינל.
🎯 מטרות הפרויקט ויעדי למידה
ארכיטקטורת MCP: בנייה וחשיפה של כלים (Tools) מותאמים אישית ל-LLM באמצעות ה-SDK הרשמי של Anthropic.
אוטומציית דפדפן: שימוש ב-Microsoft Playwright לצורך שליטה תוכנתית בדפדפן Chromium, תוך עקיפת המגבלות של גירוד מידע (Scraping) סטטי רגיל.
סוכן RAG מבוסס פעולה (Agentic Flow): מתן אפשרות ל-LLM לנהל בעצמו ובאופן אוטומטי מספר שלבים בדפדפן בזה אחר זה (פתיחה ➔ חימוש ➔ בחירה ➔ חילוץ מידע) ולהשיב למשתמש על בסיס התוכן הדינמי של העמוד.
Related MCP server: MCP Playwright Weather Israel
🧩 ארכיטקטורה ועיצוב טכנולוגי
בניגוד למימושים פשוטים של Scraping, פרויקט זה מבטיח יציבות גבוהה ושמירה על מצב הדפדפן (State) באמצעות:
ניהול State גלובלי בשרת: מופע הדפדפן והעמוד (
browserו-page) מנוהלים כמשתנים גלובליים בתוך הקובץweather_Israel.py. השרת שומר על דפדפן פעיל אחד לאורך כל סבבי הקריאות של הכלים, במקום לפתוח ולסגור אותו מחדש בכל פעם. הדבר חוסך במשאבים ושומר על הקשר השיחה.סנכרון חסין (Robust Synchronization): שימוש בזמני המתנה אסינכרוניים מפורשים (
wait_for_selectorו-wait_for_load_state("networkidle")) כדי להבטיח שרשימות נפתחות (Dropdown) ומעברי דפים נטענים לחלוטין לפני שהסוכן מנסה ללחוץ או לקרוא מהם, מה שמונע קריסות בשמות ערים מורכבים.אופטימיזציית טוקנים (RAG נקי): במקום להעביר את כל קוד ה-HTML הגולמי והרועש של העמוד לתוך הקונטקסט של המודל, כלי השליפה מטרגט סלקטורים ספציפיים (CSS Selectors) המכילים את נתוני התחזית בלבד ומסנן רעשי רקע עיצוביים.
🛠️ סטאק טכנולוגי
MCP SDK: שכבת הפרוטוקול הרשמית של Anthropic לחיבור הכלים למודל.
Playwright: ספריית האוטומציה המודרנית של Microsoft לשליטה בדפדפנים.
UV: מנהל החבילות המהיר לפייתון לצורך התקנה וסנכרון סביבת העבודה.
Gemini 2.5 Flash: מודל השפה המרכזי המנהל את לולאת קבלת ההחלטות והפעלת הכלים.
🚀 התקנה והרצה
עקבי אחר השלבים הבאים כדי להרים את הסביבה ולהריץ את הפרויקט באופן מקומי:
סנכרון התלויות והפעלת סביבת העבודה:
uv sync התקנת דפדפן כרום (Chromium) עבור Playwright:
Bash uv run playwright install chromium הרצת צ'אט הטרמינל (ה-Client):
Bash uv run host.py 💻 דוגמת שימוש והרצה בזמן אמת לאחר הפעלת ה-Client, ניתן לשוחח עם הסוכן בשפה חופשית בעברית. המודל יחליט בעצמו באילו כלים להשתמש, יבצע את הפעולות בדפדפן הפתוח (הנפתח במצב נראה לעין - headless=False), ויציג את התחזית הסופית בטרמינל.
לוג הרצה מוצלח מהטרמינל (עבור ירושלים): Plaintext Query: מה המזג אוויר בירושלים? Connected to server with tools: ['open_weather_forecast_israel', 'enter_weather_forecast_city_israel', 'select_weather_forecast_city_israel', 'get_page_content_israel']
🤖 גמיני חושב... (סיבוב 1/5) 📞 המודל מפעיל את הכלי: weather_Israel__open_weather_forecast_israel עם הפרמטרים: {}
🤖 גמיני חושב... (סיבוב 2/5) 📞 המודל מפעיל את הכלי: weather_Israel__enter_weather_forecast_city_israel עם הפרמטרים: {'city_name': 'ירושלים'}
🤖 גמיני חושב... (סיבוב 3/5) 📞 המודל מפעיל את הכלי: weather_Israel__select_weather_forecast_city_israel עם הפרמטרים: {}
🤖 גמיני חושב... (סיבוב 4/5) 📞 המודל מפעיל את הכלי: weather_Israel__get_page_content_israel עם הפרמטרים: {}
🤖 גמיני חושב... (סיבוב 5/5)
[Calling tool weather_Israel__open_weather_forecast_israel] [Calling tool weather_Israel__enter_weather_forecast_city_israel] [Calling tool weather_Israel__select_weather_forecast_city_israel] [Calling tool weather_Israel__get_page_content_israel]
הטמפרטורה הנוכחית בירושלים היא 30.2 מעלות צלזיוס.
תחזית להיום: לאחר התפזרות עננות הבוקר, ייעשה בהיר. הטמפרטורות יוסיפו להיות מעט גבוהות מהרגיל לעונה, בעיקר בהרים ובפנים הארץ.
הלילה: מעונן חלקית עד בהיר.
תחזית לימים הקרובים:
רביעי: לאחר התפזרות עננות הבוקר, ייעשה נאה. תחול ירידה קלה בטמפרטורות בהרים ובפנים הארץ.
חמישי: לאחר התפזרות עננות הבוקר, ייעשה נאה. לא צפוי שינוי ניכר בטמפרטורות.
Available Tools
4 toolsenter_weather_forecast_city_israelB
Enters the specified city name into the search box using JS injection to bypass visibility issues. Input should be a string in Hebrew (e.g., 'ירושלים', 'חיפה').
Inputs: city_name (required). Returns: result
get_page_content_israelA
Extracts the text content from the loaded weather page for the LLM to read.
Inputs: no named parameters. Returns: result
open_weather_forecast_israelA
Opens the weather forecast website for Israel and initializes the browser. This must be called first.
Inputs: no named parameters. Returns: result
select_weather_forecast_city_israelA
Selects the city from the autocomplete dropdown, or presses Enter as a fallback.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct role in the workflow: opening the site, entering city, selecting from dropdown, and retrieving content. Only potential confusion is between enter and select, but descriptions clarify they are different steps.
Tool names use a mix of patterns: 'open_weather_forecast_israel' lacks 'city', while others include 'city' or 'page_content'. The verb prefixes are consistent, but the descriptive suffixes vary.
Four tools are well-scoped for the task of retrieving a weather forecast for an Israeli city. Each tool is necessary and none are superfluous.
The tools cover the essential steps of the weather retrieval workflow. A minor gap might be the absence of error handling or city validation, but the surface is complete for basic usage.
Maintenance
Related MCP Connectors
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Hosted Web Crawler MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Related MCP Servers
- FlicenseAqualityDmaintenanceMCP server enabling LLMs to fetch Israeli weather forecasts by automating a browser with Playwright to scrape weather2day.co.il.4-
- FlicenseAqualityDmaintenanceAn MCP server that uses Playwright to browse Israeli weather forecasts from weather2day.co.il, allowing LLMs to control a browser to fetch real-time weather data.5-
- FlicenseAqualityDmaintenanceAn 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 gradedqualityDmaintenanceMCP server that enables users to get real-time weather forecasts for Israeli cities by automating a browser with Playwright and using Gemini to answer natural language queries.-