Skip to main content
Glama
Weather Israel MCP Server

Weather Israel MCP Server

🌀️ Weather Israel β€” Agentic MCP Server with Browser Automation

An AI-powered weather assistant that autonomously controls a browser to fetch real-time Israeli weather forecasts using the Model Context Protocol (MCP) and Playwright.

Python MCP Playwright Gemini


πŸ“Œ Overview

This project implements a custom MCP (Model Context Protocol) Server that gives an LLM autonomous browser control capabilities. Instead of relying on a traditional weather API, the system opens a real browser, navigates to an Israeli weather website, searches for a city, and extracts the live forecast β€” just like a human would.

The LLM (Gemini 2.5 Flash) acts as the orchestrating agent, deciding which tools to invoke and in what sequence, creating a fully autonomous agentic pipeline.

Why is this interesting?

  • No API needed β€” scrapes data directly from the web using browser automation

  • Agentic architecture β€” the LLM decides which tools to call and when

  • MCP standard β€” uses Anthropic's open protocol for tool communication

  • RAG pattern β€” extracts page content and feeds it back to the LLM for reasoning


Related MCP server: MCP Playwright Weather Israel

🎯 Project Goals

  • Implement a custom MCP Server from scratch

  • Use Playwright to add browser automation capabilities to an LLM

  • Demonstrate agentic tool-calling with multi-step orchestration

  • Build a complete RAG pipeline β€” retrieve data β†’ augment context β†’ generate response


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         User Query                               β”‚
β”‚              "What's the weather in Tel Aviv?"                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    host.py (Orchestrator)                         β”‚
β”‚              Gemini 2.5 Flash + Tool Calling                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚ MCP Protocol
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               weather_Israel.py (MCP Server)                     β”‚
β”‚                                                                  β”‚
β”‚   Tool 1: open_weather_forecast_israel()                         β”‚
β”‚   Tool 2: enter_weather_forecast_city_israel(city)               β”‚
β”‚   Tool 3: select_weather_forecast_city_israel()                  β”‚
β”‚   Tool 4: get_weather_page_content()                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚ Playwright
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              weather2day.co.il (Live Website)                     β”‚
β”‚         Real-time weather data scraped from browser               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Technology

Purpose

Python 3.13+

Core language

MCP SDK

Model Context Protocol β€” exposes tools to the LLM

Playwright

Headless browser automation (Chromium)

Gemini 2.5 Flash

LLM for reasoning and tool orchestration

httpx

HTTP client for Gemini REST API calls

uv

Modern Python package manager


πŸ“ Project Structure

MCP/
β”œβ”€β”€ weather_Israel.py     # MCP Server β€” Israeli weather tools (Playwright)
β”œβ”€β”€ weather_USA.py        # MCP Server β€” US weather tools (API-based)
β”œβ”€β”€ host.py               # Orchestrator β€” Gemini + MCP client integration
β”œβ”€β”€ client.py             # Generic MCP client connector
β”œβ”€β”€ pyproject.toml        # Dependencies and project metadata
β”œβ”€β”€ .env.example          # Environment variable template
β”œβ”€β”€ .gitignore            # Git ignore rules
β”œβ”€β”€ uv.lock               # Locked dependencies
└── README.md             # This file

πŸ”§ MCP Tools β€” weather_Israel.py

#

Tool

Description

1

open_weather_forecast_israel()

Launches Chromium and navigates to the weather website

2

enter_weather_forecast_city_israel(city)

Types the city name into the search field using keyboard simulation

3

select_weather_forecast_city_israel()

Clicks the first autocomplete result from the dropdown

4

get_weather_page_content()

Extracts and cleans the visible text from the forecast page


⚑ Prerequisites

  • Python 3.13 or higher

  • uv package manager (pip install uv)

  • Gemini API Key from Google AI Studio


πŸ“¦ Installation

1. Clone the repository

git clone https://github.com/yael3222664-alt/MCP.git
cd MCP

2. Install dependencies

uv sync

3. Install Chromium for Playwright

uv run playwright install chromium

4. Configure environment variables

Create a .env file in the project root:

GEMINI_API_KEY=your_gemini_api_key_here

Get your free API key at Google AI Studio


πŸš€ Running the Application

python -m uv run host.py

You'll see:

MCP Client Started!
Type your queries or 'quit' to exit.

Query: 

πŸ’¬ Example Queries & Output

Query:

ΧžΧ” ΧžΧ–Χ’ האוויר Χ‘Χ‘Χ Χ™ Χ‘Χ¨Χ§?

Agent Actions:

[Calling tool weather_Israel__open_weather_forecast_israel with args {}]
[Calling tool weather_Israel__enter_weather_forecast_city_israel with args {'city': 'Χ‘Χ Χ™ Χ‘Χ¨Χ§'}]
[Calling tool weather_Israel__select_weather_forecast_city_israel with args {}]
[Calling tool weather_Israel__get_weather_page_content with args {}]

Response:

The current temperature in Bnei Brak is 30Β°C with wind speed of 15 km/h 
and gusts up to 37 km/h from the west. Humidity is at 52%.

Hourly forecast for today:
β€’ 14:00 β€” 30Β°C, humidity 52%, wind 15 km/h
β€’ 15:00 β€” 30Β°C, humidity 52%, wind 15 km/h
β€’ 16:00 β€” 29Β°C, humidity 54%, wind 14 km/h
...

More examples:

What's the weather in Jerusalem?
ΧžΧ” Χ”ΧͺΧ—Χ–Χ™Χͺ ΧœΧ—Χ™Χ€Χ”?
How's the weather in Tel Aviv today?
What are the weather alerts in California?  (uses USA tools)

οΏ½ How It Works β€” Step by Step

  1. User asks a question β†’ "What's the weather in Tel Aviv?"

  2. Gemini analyzes the query and identifies the required tools

  3. Tool 1 β†’ Playwright opens a headless Chromium browser and navigates to the weather site

  4. Tool 2 β†’ Playwright types the city name into the search field (character by character to trigger autocomplete)

  5. Tool 3 β†’ Playwright clicks the first matching result in the dropdown

  6. Tool 4 β†’ Playwright extracts all visible text from the forecast page

  7. Gemini receives the raw page content and formulates a clean, structured answer

  8. User gets a natural language response with temperature, wind, humidity, and hourly forecast


🧠 Key Design Decisions

  • Keyboard simulation (keyboard.type()) instead of fill() β€” triggers the website's JavaScript autocomplete

  • Direct REST API calls to Gemini with httpx(verify=False) β€” bypasses SSL issues in restricted network environments

  • Global browser state β€” shared between tool calls so the same page instance persists across the multi-step workflow

  • Graceful error handling β€” each tool validates state and returns clear error messages


πŸ› Troubleshooting

Issue

Solution

uv: command not found

Use python -m uv instead of uv

GEMINI_API_KEY not found

Create .env file with your API key

429 Too Many Requests

Rate limit β€” wait 1 minute or use a different API key

Browser doesn't open

Run uv run playwright install chromium

SSL errors

The code already disables SSL verification for restricted networks


πŸ“š Resources


πŸ“„ License

This project is open source and available for educational purposes.


Built with Playwright 🎭 and the Model Context Protocol πŸ€–

Available Tools

4 tools
enter_weather_forecast_city_israelB

Enters a city name into the search input field on the weather forecast page.

Args: city: The name of the city to search for

Returns: A message indicating success or failure

Inputs: city (required). Returns: result

get_weather_page_contentA

Extracts the weather forecast data from the currently loaded page.

Returns: The weather forecast text content from the page, or an error message

Inputs: no named parameters. Returns: result

open_weather_forecast_israelA

Opens a Chromium browser and navigates to the Israeli weather forecast website.

Returns: A message indicating success or failure

Inputs: no named parameters. Returns: result

select_weather_forecast_city_israelC

Clicks/selects the first item in the dropdown list of cities.

Returns: A message indicating success or failure

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

    TDQS

    B3.4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool performs a distinct step in the weather forecast workflow: opening the site, entering a city, selecting from a dropdown, and extracting the content. No two tools have overlapping purposes.

    Naming Consistency3/5

    Most tools follow a 'verb_weather_forecast_city_israel' pattern, but 'get_weather_page_content' deviates by omitting 'israel' and using 'page_content' instead of 'forecast', causing inconsistency.

    Tool Count4/5

    Four tools is a reasonable number for a focused weather query server, covering the essential steps without unnecessary complexity.

    Completeness3/5

    The tools cover the basic flow of opening the page, searching, selecting, and retrieving content, but lack support for error recovery, multiple cities, or closing the browser, leaving minor gaps.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers