Skip to main content
Glama
Weather-MCP

Weather-MCP

by Efrat-Fr

šŸŒ¤ļø — Israel Weather Forecast

A learning project in MCP (Model Context Protocol) development: an LLM-based agent that can fetch weather forecasts for cities in Israel and the US, and answer in free language in the terminal chat.


šŸŽÆ Project Goal

Build a dedicated MCP server that "teaches" the LLM to perform a task it can't do on its own — fetch a weather forecast from an Israeli site that has no API.

The agent does this in two ways:

  1. Israel server (weather-Israel) — automates a real browser with Playwright: opens weather2day.co.il/forecast, searches for a city, selects it, and then extracts the forecast page content and feeds it to the LLM to answer on its own (RAG approach).

  2. US server (weather-USA) — fetches forecast and alerts via the official NWS (National Weather Service) API.

The Host connects all servers to the LLM (Gemini, via the OpenAI-compatible API), automatically collects all the Tools from them, and runs a chat loop where the LLM chooses which tool to use and activates them one by one until an answer is received.


Related MCP server: Israeli Weather MCP

šŸ—ļø Project Structure

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

Israel Server Tools

#

Tool

Role

1

open_weather_forecast_israel

Opens a Chromium browser and navigates to the forecast site

2

enter_weather_forecast_city_israel

Types a city name in the search field

3

select_weather_forecast_city_israel

Selects the first city from the suggestions list

4

get_weather_forecast_content_israel

Extracts the forecast page content (including iframes) and returns it to the LLM

šŸ’” The first three share the same browser via a global state (_page), because they all run in the same server process. The fourth iterates over all frames in the page, because the forecast itself loads inside an <iframe> that the main body doesn't see.


āš™ļø Installation and Running

Prerequisites

  • Python ≄ 3.13

  • uv (environment and dependency manager)

  • Gemini API key (get a free key)

Steps

# 1. ×”×Ŗ×§× ×Ŗ ×”×Ŗ×œ×•×™×•×Ŗ ×•×”×§×ž×Ŗ הביבת העבודה
uv sync

# 2. ×”×Ŗ×§× ×Ŗ דפדפן Chromium עבור Playwright
uv run playwright install chromium

Setting Environment Variables

Create a .env file in the project directory:

GEMINI_API_KEY=your_api_key_here
GEMINI_MODEL=gemini-2.0-flash

Running

uv run host.py

After launching, a Query: prompt will appear — type a question (or quit to exit).


šŸ’¬ Example Questions the Agent Can Answer

Israel Forecast (Playwright)

A browser window opens showing the forecast page, and the LLM also answers in the chat.

  • "What's the forecast in Tel Aviv?"

  • "How many degrees are expected tomorrow in Jerusalem?"

  • "How's the weather in Haifa today?"

  • "Open the forecast for Be'er Sheva for me"

US Forecast and Alerts (NWS API)

  • "What's the weather forecast for San Francisco?" (latitude/longitude)

  • "Are there any weather alerts in California?"

  • "Show me active weather alerts for NY"


🧩 How It Works (Flowchart)

×ž×©×Ŗ×ž×© → "מה ×”×Ŗ×—×–×™×Ŗ ×‘×Ŗ×œ אביב?"
   │
   ā–¼
 Host  ──►  LLM (Gemini) בוחר Tools להפעיל
   │
   ā–¼  (שרת ×™×©×Ø××œ, בזה אחר זה)
 open → enter("תל אביב") → select → get_content
   │
   ā–¼
 ×Ŗ×•×›×Ÿ ×”×Ŗ×—×–×™×Ŗ חוזר ל-LLM (RAG)
   │
   ā–¼
 LLM כותב תשובה בשפה חופשית בצ'אט ✨

šŸ“ Notes

  • The LLM is the one that decides which Tools to run and in what order — we didn't write hard-coded logic.

  • Two server files = two separate processes, so any shared state (like the open browser) must live inside only one server.

Available Tools

4 tools
enter_weather_forecast_city_israelB

Type a city name into the search field on the Israeli forecast page.

Args: city: The name of the city to search for (in Hebrew)

Inputs: city (required). Returns: result

get_weather_forecast_content_israelA

Extract the weather forecast text from the currently open forecast page.

Returns the cleaned textual content so the LLM can answer the user directly.

Inputs: no named parameters. Returns: result

open_weather_forecast_israelA

Open a browser and navigate to the Israeli weather forecast website.

Inputs: no named parameters. Returns: result

select_weather_forecast_city_israelB

Select the first city from the autocomplete suggestion list.

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

    A3.8/5.0

    Scored across 4 tools

    Disambiguation4/5

    Each tool covers a distinct workflow step: opening the page, typing a city, selecting an autocomplete result, and extracting content. The main ambiguity is between open_weather_forecast_israel and get_weather_forecast_content_israel, since both could sound like they return forecast data without reading the descriptions carefully.

    Naming Consistency5/5

    All tool names follow the same verb-first snake_case pattern and consistently include weather_forecast and israel context. This makes the order and purpose of the tools predictable.

    Tool Count5/5

    Four tools is appropriate for the narrow browser-automation workflow this server provides. Each tool contributes one essential step, and the set is neither bloated nor too thin.

    Completeness4/5

    The tool surface covers the full workflow from opening the forecast site to retrieving the forecast text for a chosen city. It lacks fallback or reset tools, but those are not essential for the core task.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      MCP 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.
      -
    • F
      license
      A
      quality
      D
      maintenance
      An 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
      -
    • F
      license
      B
      quality
      D
      maintenance
      MCP server that enables LLMs to retrieve weather forecasts for Israeli cities by automating a browser with Playwright, and also provides US weather alerts and forecasts via NWS API.
      4
      -