Skip to main content
Glama

⛅ Weather MCP with Playwright

שרת MCP עצמאי ששולף תחזית מזג אוויר ישראלית על ידי הפעלת דפדפן אמיתי עם Playwright — במקום קריאה ל‑API. ה‑Host מחבר את הכלים למודל Google Gemini, כך שה‑LLM עונה על שאלת המשתמש ישירות בצ׳אט (מעין RAG מעל תוכן הדף).

צילום מסך של ממשק הצ׳אט

איך זה עובד

  1. המשתמש שואל שאלה בצ׳אט (Gradio).

  2. Gemini מחליט להפעיל את הכלי get_israel_forecast.

  3. הכלי מריץ דפדפן Chrome אמיתי: נכנס לאתר התחזית → מקליד את שם העיר → בוחר עיר מהרשימה → מחלץ ומנקה את טקסט הדף.

  4. הטקסט הנקי חוזר ל‑Gemini, שמנסח תשובה קצרה בשפת המשתמש.

Related MCP server: Weather Israel MCP Server

מבנה הפרויקט

קובץ

תפקיד

weather_Israel.py

שרת MCP — כלי Playwright לאתר התחזית הישראלי

weather_USA.py

שרת MCP — תחזית ארה״ב דרך ה‑API של NWS

client.py

MCPClient — התחברות לשרת MCP דרך stdio

host.py

ChatHost — גשר בין כלי MCP למודל Gemini (לולאת tool‑calling)

app.py

ממשק צ׳אט ב‑Gradio

הכלים

שרת weather-Israel — כל הכלים מוגדרים עם @mcp.tool() ומחוברים ל‑Host:

שלב א׳

  • open_weather_forecast_israel — פתיחת אתר התחזית

  • enter_weather_forecast_city_israel(city) — הזנת שם עיר

  • select_weather_forecast_city_israel — בחירת העיר מרשימת ההשלמה

שלב ב׳

  • get_weather_page_content_israel — חילוץ וניקוי טקסט הדף כדי שה‑LLM יענה מהנתונים

נוחות

  • get_israel_forecast(city) — מריץ את כל הרצף בקריאה אחת (כדי לחסוך בבקשות ל‑Gemini)

הרצה

דרישות: Python 3.13+, uv, ו‑Google Chrome מותקן.

uv sync

צרו קובץ .env:

GEMINI_API_KEY=...        # מפתח חינם: https://aistudio.google.com/apikey
# WEATHER_HEADLESS=1      # אופציונלי — הרצת הדפדפן ללא חלון גלוי

ממשק גרפי:

uv run python app.py     # פותח http://127.0.0.1:7860

טרמינל:

uv run python host.py

הערות

  • מכסת Gemini החינמית מוגבלת במספר בקשות ליום לכל מודל. אם היא נגמרת — היא מתאפסת אוטומטית תוך 24 שעות, או שאפשר לשנות את MODEL ב‑host.py.

  • הקוד מגדיר verify=False בבקשות ה‑HTTPS כדי לעבור דרך פרוקסי TLS מקומי (כגון NetFree).

  • .env ו‑.venv/ לא נכללים ב‑git — כל מי שמריץ צריך .env משלו.

Available Tools

5 tools
enter_weather_forecast_city_israelA

Types the specific city name into the search bar. Requires 'city' argument. Must be called right after opening the browser.

Inputs: city (required). Returns: result

get_israel_forecastA

One call that does the whole flow: open the forecast site, search for 'city', pick the first match, and return the cleaned forecast text. Use this for a normal weather question - it keeps the conversation short. The separate open/enter/select tools are for stepping through the browser manually.

Inputs: city (required). Returns: result

get_weather_page_content_israelA

Extracts and returns the visible text content of the currently open weather page. Call this after navigating to a city forecast to give the LLM the actual weather data.

Inputs: no named parameters. Returns: result

open_weather_forecast_israelB

Open Chrome and navigate to the Israel weather forecast page.

Inputs: no named parameters. Returns: result

select_weather_forecast_city_israelA

Clicks the first suggestion in the search dropdown menu. Call this ONLY after enter_weather_forecast_city_israel has finished executing. Takes no arguments.

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

    A4.1/5.0

    Scored across 5 tools

    Disambiguation4/5

    The high-level get_israel_forecast tool is clearly distinct from the manual browser steps, and its description explicitly directs agents to use it for normal queries. The four step-by-step tools are sequential and have clear dependencies, so an agent can distinguish them. However, both paths ultimately return weather data, creating slight overlap in purpose.

    Naming Consistency4/5

    All tools end with '_israel' and use clear verbs (get, open, enter, select, get). The pattern is mostly verb + object + israel, though get_israel_forecast breaks the order (get + israel + forecast) and some names are verbose. Overall, the naming is readable and predictable, with only minor deviations.

    Tool Count5/5

    With 5 tools, the server is well-scoped. The high-level tool provides a quick path, while the four low-level tools enable manual browser control. This is a reasonable size that avoids redundancy and keeps the surface manageable.

    Completeness5/5

    The tool set covers the full weather retrieval workflow: the high-level tool handles everything in one call, and the manual tools cover open, search, select, and read steps. There are no missing operations for the stated purpose of fetching Israel weather forecasts, and the domain is read-only, so no CRUD gaps exist.

    Related MCP Connectors

    Related MCP Servers