Skip to main content
Glama
mcp-weather-israel-playwright

mcp-weather-israel-playwright

by esty783

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):

  1. 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.

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

  3. 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.

  4. 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

  1. 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 chromium
  1. Inicia el host (interfaz de chat en terminal):

uv run host.py
  1. En 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.md que describe el propósito y las instrucciones de ejecución.

  • Asegúrate de que .env no se suba con claves API reales. Usa .env.example con marcadores de posición.

Notas y solución de problemas

  • Asegúrate de que ANTHROPIC_API_KEY esté 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.py segú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 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 has a distinct step in a clear workflow: open site, search, select city, extract data. No overlapping responsibilities.

    Naming Consistency5/5

    All tools follow a consistent verb_weather_forecast_city_israel snake_case pattern, making the purpose of each clear.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers