mcp-weather-israel-playwright
MCP con Playwright - Clima (Israel)
Este proyecto es la tarea de MCP (Model Context Protocol) del curso de Malka Baruch: "MCP con Playwright".
Propósito del proyecto
El servidor MCP proporciona pronósticos meteorológicos para ciudades israelíes utilizando Playwright para manejar un navegador real y extraer datos de https://www.weather2day.co.il/forecast. El objetivo es permitir que un LLM (Claude) controle un navegador a través de Herramientas expuestas para que pueda recuperar datos web en vivo sin una API tradicional.
Related MCP server: MCP Playwright Weather Israel
Lo que implementé
Herramientas (servidor MCP - weather_Israel.py):
open_weather_forecast_israel()Abre un navegador Chromium (headless=False) y navega al sitio de pronóstico. Mantiene el navegador y las instancias de Page en un contexto global para persistir entre llamadas de Herramientas.
enter_weather_search_israel(city: str)Escribe el nombre de la ciudad indicada en el campo de búsqueda del sitio y espera a que aparezca la lista de autocompletado.
select_weather_forecast_city_israel()Selecciona el primer resultado de autocompletado (o presiona Enter) y espera a que se cargue la página de pronóstico.
extract_weather_data_israel()Extrae el texto visible del pronóstico de la página cargada y realiza una limpieza para eliminar anuncios y ruido de la interfaz, de modo que el LLM reciba solo datos meteorológicos útiles.
Cómo ejecutar
Desde la carpeta
project-template:
cd C:\Users\user1\Downloads\dovrot-ai-projects-master\dovrot-ai-projects-master\8-mcp\project-template
uv sync
uv run playwright install chromiumInicia el host (interfaz de chat en terminal):
uv run host.pyEn el prompt de chat del host, haz una pregunta como:
"מה התחזית בתל אביב היום?"
"תן חיזוי גשם בתל אביב מחר"
El host debe enrutar la solicitud al MCP weather-Israel y el LLM llamará a las Herramientas en secuencia (abrir → ingresar → seleccionar → extraer) para obtener y devolver el pronóstico.
Instrucciones de entrega
Sube el repositorio a GitHub como un repositorio público.
Incluye este
README.mdque describe el propósito y las instrucciones de ejecución.Asegúrate de que
.envno se suba con claves API reales. Usa.env.examplecon marcadores de posición.
Notas y solución de problemas
Asegúrate de que
ANTHROPIC_API_KEYesté configurada en tu entorno si ejecutas con el SDK de Anthropic (Claude).Si los selectores de Playwright se rompen (el sitio cambió), actualiza los selectores en
weather_Israel.pysegún el HTML del sitio (inspecciona con DevTools).
Este README sigue las pautas de entrega del curso: propósito, pasos de ejecución y consultas de ejemplo.
Available Tools
4 toolsenter_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
Scored across 4 tools
Each tool has a distinct step in a clear workflow: open site, search, select city, extract data. No overlapping responsibilities.
All tools follow a consistent verb_weather_forecast_city_israel snake_case pattern, making the purpose of each clear.
With 4 tools, the set is well-scoped for the specific task of fetching a weather forecast for an Israeli city. No unnecessary tools or omissions.
The tools cover the primary workflow, but lack error recovery or reset capabilities (e.g., no tool to handle failed city lookup or restart from scratch). Still sufficient for the intended use case.
Maintenance
Related MCP Connectors
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Hosted browser for agents: open pages, search the web, extract data, read PDFs and take screenshots.
A real browser for your agent: screenshots, page checks, Markdown and PDFs.
Web search, browser automation, scraping, crawling and CAPTCHA solving for AI agents.
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables LLMs to query real-time weather data in Israel by automating a browser to scrape weather2day.co.il.4-
- FlicenseAqualityDmaintenanceEnables an LLM to retrieve Israeli weather forecasts by controlling a real Chromium browser to search and scrape a weather site.5-
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to retrieve Israeli weather forecasts by controlling a browser via Playwright and scraping data from an Israeli weather website.-
- FlicenseAqualityDmaintenanceEnables LLMs to fetch Israeli weather forecasts by automating a browser to navigate Weather2Day, providing tools for city search and content extraction.4-