mcp-weather-israel-playwright
MCP with Playwright - 天気 (イスラエル)
このプロジェクトは、Malka Baruch のコース「MCP with Playwright」の MCP (Model Context Protocol) 課題です。
プロジェクトの目的
MCP サーバーは、Playwright を使用して実際のブラウザを操作し、https://www.weather2day.co.il/forecast からデータをスクレイピングすることで、イスラエルの都市の天気予報を提供します。目的は、LLM(Claude)が公開された Tools を通じてブラウザを制御し、従来の API なしでライブの Web データを取得できるようにすることです。
Related MCP server: MCP Playwright Weather Israel
実装した内容
Tools(MCP サーバー - weather_Israel.py):
open_weather_forecast_israel()Chromium ブラウザを(headless=False で)起動し、天気予報サイトに移動します。ブラウザと Page インスタンスをグローバルコンテキストに保持し、Tool 呼び出し間で永続化します。
enter_weather_search_israel(city: str)指定された都市名をサイトの検索フィールドに入力し、オートコンプリートリストが表示されるのを待ちます。
select_weather_forecast_city_israel()最初のオートコンプリート結果を選択(または Enter キーを押下)し、予報ページが読み込まれるのを待ちます。
extract_weather_data_israel()読み込まれたページから表示されている予報テキストを抽出し、広告や UI ノイズを除去してクリーンアップします。これにより、LLM は有用な天気データのみを受け取ります。
実行方法
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ホスト(ターミナルチャットインターフェース)を起動:
uv run host.pyホストのチャットプロンプトで、次のような質問をします:
「מה התחזית בתל אביב היום?」
「תן חיזוי גשם בתל אביב מחר」
ホストはリクエストを weather-Israel MCP にルーティングし、LLM が Tools を順番に(開く→入力→選択→抽出)呼び出して予報を取得し、返します。
提出手順
リポジトリを公開の GitHub リポジトリとしてプッシュしてください。
この
README.mdに目的と実行手順を記載してください。.envには実際の API キーをコミットしないでください。.env.exampleをプレースホルダーとともに使用してください。
注意事項とトラブルシューティング
Anthropic SDK(Claude)で実行する場合は、環境変数
ANTHROPIC_API_KEYが設定されていることを確認してください。Playwright のセレクターが機能しなくなった場合(サイト変更)、
weather_Israel.py内のセレクターをサイトの HTML(DevTools で検査)に合わせて更新してください。
この README は、コースの提出ガイドライン(目的、実行手順、サンプルクエリ)に従っています。
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.
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-