Skip to main content
Glama
esty783

mcp-weather-israel-playwright

by esty783

MCP with Playwright - Weather (Israel)

이 프로젝트는 Malka Baruch의 강의 "MCP with Playwright"에서 진행된 MCP(Model Context Protocol) 과제입니다.

프로젝트 목적

MCP 서버는 Playwright를 사용하여 실제 브라우저를 구동하고 https://www.weather2day.co.il/forecast에서 데이터를 스크래핑하여 이스라엘 도시의 날씨 예보를 제공합니다. 목표는 LLM(Claude)이 노출된 Tools를 통해 브라우저를 제어하여 전통적인 API 없이 실시간 웹 데이터를 가져올 수 있도록 하는 것입니다.

Related MCP server: MCP Playwright Weather Israel

내가 구현한 것

Tools (MCP 서버 - weather_Israel.py):

  1. open_weather_forecast_israel()

    • Chromium 브라우저를 열고(headless=False) 예보 사이트로 이동합니다. 브라우저와 Page 인스턴스를 전역 컨텍스트에 유지하여 Tool 호출 간에 지속성을 유지합니다.

  2. enter_weather_search_israel(city: str)

    • 사이트의 검색 필드에 주어진 도시 이름을 입력하고 자동 완성 목록이 나타날 때까지 기다립니다.

  3. select_weather_forecast_city_israel()

    • 첫 번째 자동 완성 결과를 선택하고(또는 Enter 키를 누르고) 예보 페이지가 로드될 때까지 기다립니다.

  4. extract_weather_data_israel()

    • 로드된 페이지에서 보이는 예보 텍스트를 추출하고 광고 및 UI 노이즈를 제거하여 LLM이 유용한 날씨 데이터만 받을 수 있도록 정리합니다.

실행 방법

  1. 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. 호스트(터미널 채팅 인터페이스)를 시작합니다:

uv run host.py
  1. 호스트 채팅 프롬프트에서 다음과 같은 질문을 합니다:

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

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

호스트는 요청을 weather-Israel MCP로 라우팅하고 LLM이 Tools를 순서대로(열기 → 입력 → 선택 → 추출) 호출하여 예보를 가져와 반환합니다.

제출 안내

  • 리포지토리를 GitHub에 공개 리포지토리로 푸시합니다.

  • 이 README.md를 포함하여 목적과 실행 방법을 설명합니다.

  • 실제 API 키가 포함된 .env가 커밋되지 않도록 합니다. 플레이스홀더가 포함된 .env.example을 사용하세요.

참고 사항 및 문제 해결

  • Anthropic SDK(Claude)로 실행하는 경우 환경에 ANTHROPIC_API_KEY가 설정되어 있는지 확인하세요.

  • Playwright 선택자가 깨지면(사이트가 변경된 경우) 사이트의 HTML(DevTools로 검사)에 따라 weather_Israel.py의 선택자를 업데이트하세요.


이 README는 강의 제출 가이드라인(목적, 실행 단계, 예시 질문)을 따릅니다.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
cityYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool uses the shared Page in `_PLAYWRIGHT_CONTEXT` and that it waits for autocomplete results, which are useful behavioral details. However, it does not mention potential side effects, error conditions, or what happens if the page is not open. The description provides some transparency but lacks depth for a UI automation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences with no fluff. The first sentence states the core action, and the second provides a crucial prerequisite. It is front-loaded and efficient, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with a clear prerequisite, the description is fairly complete. It covers what to do (enter city, wait), the shared context, and the required predecessor. It does not explain the next step (selecting from autocomplete) or error handling, but that is likely covered by sibling tools and the overall workflow. The description is sufficient for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It does add meaning by explicitly mentioning 'Enter the city name', linking the sole parameter 'city' to the action. However, it provides no additional constraints, formats, or examples. The description adds minimal semantic value beyond the schema's type and title, but enough to understand the parameter's role.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: 'Enter the city name into the search field and wait for autocomplete results.' It specifies the verb (enter), the resource (search field), and the outcome (wait for autocomplete). This distinguishes it from siblings like open_weather_forecast_israel (which likely opens the page) and select_weather_forecast_city_israel (which likely selects from results). The purpose is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly mentions a prerequisite: 'open_weather_forecast_israel should be called first.' This gives the agent clear ordering context. It does not explicitly state when not to use this tool or name alternatives, but the prerequisite effectively routes the agent to the correct sequence. The usage guidance is sufficient for typical invocation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the transparency burden. It discloses that extraction targets the main forecast container and removes noise like ads, links, and UI strings. It does not explicitly state whether the operation is read-only or whether it could fail, but the described behavior is reasonably transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences. The first states the purpose directly; the second adds necessary precondition and behavioral detail. No fluff or redundant wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description fully covers what the tool does, when it should be used, and what behavior to expect. Since the output schema exists, return format details are not required. The precondition and cleaning behavior make it complete for an agent to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema is empty with zero parameters, so the baseline is 4. There are no parameters for the description to explain, and no additional parameter details are needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action ('extract and clean') and target ('visible forecast text from the current page'). It distinguishes itself from sibling tools by specifying that it operates after a forecast page is already loaded, complementing open/search/select actions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states the precondition: a forecast page must already be loaded, specifically after select_weather_forecast_city_israel. This gives clear when-to-use guidance, though it does not explicitly compare against alternatives beyond that contextual reference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

open_weather_forecast_israelA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

There are no annotations, so the description carries the full burden. It mentions the action of opening and keeping open, but does not disclose potential side effects like navigation, cookies, or session state. It is adequate but not exhaustive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no redundant information. It efficiently conveys the action and its purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the sibling tools, the description provides enough context that this is an initial step in a multi-step weather forecast flow. It mentions subsequent tools, which helps the agent understand the sequence. It could be slightly more explicit about the forecast site, but the overall context is sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters, so there is nothing to explain. The schema is complete with zero properties, and the description does not need to add parameter-level detail.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states that the tool opens the forecast site and specifies its role in keeping the browser/page open for subsequent steps. It distinguishes from sibling tools like search, select, and extract, though it does not name the specific site.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies it is a preparatory step by saying 'keep the browser/page open for subsequent tools', but it does not explicitly state when to choose this tool over siblings or provide prerequisites. The usage context is only partially inferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

select_weather_forecast_city_israelA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description mentions that the tool waits for the forecast page to load, which is a behavioral detail. However, since there are no annotations to provide safety or side-effect information, the description carries more responsibility, and it does not cover potential errors, timeouts, or other side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that directly states the action and the waiting behavior. Every word is meaningful, and there is no redundancy or unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (though not fully shown), the description need not elaborate on return values. It adequately covers the tool's action and expected outcome (waiting for page load), but it could be slightly more explicit about its role in the overall workflow with the sibling tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the schema coverage is effectively 100% and the baseline for parameter semantics is 4. The description adds no parameter-specific information, but none is needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action of selecting the first autocomplete result and waiting for the forecast page to load, making it distinct from siblings that open, search, or extract data. However, it does not explicitly name the sibling tools or contrast with them, so it earns a 4 rather than a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies a sequential step after entering a search query but does not explicitly state when to use this tool versus the alternatives (open, enter, extract). It gives no direct guidance on workflow order or conditions, so it falls short of clear usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 4 tool updatesv0.1.0
    • First observedenter_weather_search_israel
    • First observedextract_weather_data_israel
    • First observedopen_weather_forecast_israel
    • First observedselect_weather_forecast_city_israel

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 issues

Related MCP Connectors

Related MCP Servers