Skip to main content
Glama

MCP with Playwright - Weather (Israel)

This project is the MCP (Model Context Protocol) assignment from Malka Baruch's course: "MCP with Playwright".

Project purpose

The MCP server provides weather forecasts for Israeli cities using Playwright to drive a real browser and scrape data from https://www.weather2day.co.il/forecast. The goal is to enable an LLM (Claude) to control a browser through exposed Tools so it can retrieve live web data without a traditional API.

Related MCP server: Israel Weather MCP Server

What I implemented

Tools (MCP server - weather_Israel.py):

  1. open_weather_forecast_israel()

    • Opens a Chromium browser (headless=False) and navigates to the forecast site. Keeps the browser and Page instances in a global context to persist between Tool calls.

  2. enter_weather_search_israel(city: str)

    • Types the given city name into the site's search field and waits for the autocomplete list to appear.

  3. select_weather_forecast_city_israel()

    • Selects the first autocomplete result (or presses Enter) and waits for the forecast page to load.

  4. extract_weather_data_israel()

    • Extracts the visible forecast text from the loaded page and performs cleaning to remove advertisements and UI noise so the LLM receives only useful weather data.

How to run

  1. From the project-template folder:

cd C:\Users\user1\Downloads\dovrot-ai-projects-master\dovrot-ai-projects-master\8-mcp\project-template
uv sync
uv run playwright install chromium
  1. Start the host (terminal chat interface):

uv run host.py
  1. In the host chat prompt, ask a question such as:

  • "מה התחזית בתל אביב היום?"

  • "תן חיזוי גשם בתל אביב מחר"

The host should route the request to the weather-Israel MCP and the LLM will call the Tools in sequence (open → enter → select → extract) to fetch and return the forecast.

Submission instructions

  • Push the repository to GitHub as a public repo.

  • Include this README.md describing purpose and run instructions.

  • Make sure .env is not committed with real API keys. Use .env.example with placeholders.

Notes and troubleshooting

  • Ensure ANTHROPIC_API_KEY is set in your environment if running with the Anthropic SDK (Claude).

  • If Playwright selectors break (site changed), update the selectors in weather_Israel.py according to the site's HTML (inspect with DevTools).


This README follows the course submission guidelines: purpose, run steps, and example queries.

Available Tools

4 tools
enter_weather_search_israelA

Enter the city name into the search field and wait for autocomplete results.

This uses the shared Page in _PLAYWRIGHT_CONTEXT so open_weather_forecast_israel should be called first.

Inputs: city (required). Returns: result

extract_weather_data_israelA

Extract and clean the visible forecast text from the current page.

This expects that a forecast page is already loaded in the shared Page (i.e., after select_weather_forecast_city_israel). It will attempt to extract the main forecast container text and remove obvious noise like advertisements, links, and short UI strings.

Inputs: no named parameters. Returns: result

open_weather_forecast_israelA

Open the forecast site and keep the browser/page open for subsequent tools.

Inputs: no named parameters. Returns: result

select_weather_forecast_city_israelA

Select the first autocomplete result (or press Enter) and wait for forecast page to load.

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.2/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool performs a distinct step in a linear workflow: opening the site, entering a search query, selecting a result, and extracting data. No two tools overlap in purpose, making selection unambiguous.

    Naming Consistency5/5

    All tool names follow the same verb_noun_israel pattern with snake_case (open_weather_forecast_israel, enter_weather_search_israel, select_weather_forecast_city_israel, extract_weather_data_israel). The consistent suffix and verb-first structure make the set predictable.

    Tool Count5/5

    Four tools is well-scoped for a narrow weather-extraction workflow. Each tool represents an essential step in the pipeline, and the count is comfortably within the ideal range.

    Completeness5/5

    The tool surface covers the complete sequence from opening the site to extracting the final data, with clear dependencies between steps. There are no dead ends or missing operations needed to accomplish the server's stated purpose.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers