Skip to main content
Glama
Weather-MCP

Weather-MCP

by Efrat-Fr

🌤️ — 以色列天气预报

一个关于开发 MCP(模型上下文协议) 的学习项目:一个基于 LLM 的智能体(Agent),能够获取以色列和美国城市的天气预报,并在终端聊天中以自由语言回答。


🎯 项目目标

构建一个专用的 MCP 服务器,用于“教会”LLM 完成它自己无法完成的任务——从没有 API 的以色列网站获取天气预报。

智能体通过两种方式完成此任务:

  1. 以色列服务器(weather-Israel) — 使用 Playwright 操作真实浏览器:打开 weather2day.co.il/forecast,搜索城市,选择城市,然后提取天气预报页面内容并将其提供给 LLM,以便它自行回答(RAG 方法)。

  2. 美国服务器(weather-USA) — 通过 NWS(美国国家气象局)的官方 API 获取天气预报和警报。

Host 将所有服务器连接到 LLM(Gemini,通过兼容 OpenAI 的 API),自动收集所有工具,并运行一个聊天循环,由 LLM 决定使用哪个工具并逐一调用它们,直到获得答案。


Related MCP server: Israeli Weather MCP

🏗️ 项目结构

project-template/
├── host.py            # צ'אט בטרמינל שמחבר את ה-LLM לכל שרתי ה-MCP
├── client.py          # MCP Client גנרי (מתחבר לשרת, מריץ Tools)
├── weather_USA.py     # שרת MCP לארה"ב — דרך NWS API
├── weather_Israel.py  # שרת MCP לישראל — דרך אטמוט דפדפן (Playwright)
├── pyproject.toml     # תלויות הפרויקט
└── README.md

以色列服务器的工具

#

工具

功能

1

open_weather_forecast_israel

打开 Chromium 浏览器并导航到天气预报网站

2

enter_weather_forecast_city_israel

在搜索框中输入城市名称

3

select_weather_forecast_city_israel

从建议列表中选择第一个城市

4

get_weather_forecast_content_israel

提取天气预报页面内容(包括 iframes)并将其返回给 LLM

💡 前三个工具通过全局状态(_page)共享同一个浏览器,因为它们都在同一个服务器进程中运行。第四个工具会遍历页面上的所有 frames,因为预报本身是加载在 <iframe> 中的,而主 body 中看不到。


⚙️ 安装与运行

前置要求

步骤

# 1. התקנת התלויות והקמת סביבת העבודה
uv sync

# 2. התקנת דפדפן Chromium עבור Playwright
uv run playwright install chromium

设置环境变量

在项目目录中创建 .env 文件:

GEMINI_API_KEY=your_api_key_here
GEMINI_MODEL=gemini-2.0-flash

运行

uv run host.py

启动后会出现 Query: 提示符——输入问题(或输入 quit 退出)。


💬 问题示例

以色列天气预报(Playwright)

会打开一个浏览器窗口,您可以看到天气预报页面,同时 LLM 也会在聊天中回答。

  • “特拉维夫的天气预报是什么?”

  • “耶路撒冷明天预计多少度?”

  • “今天海法的天气怎么样?”

  • “打开贝尔谢巴的天气预报给我看”

美国天气预报和警报(NWS API)

  • “旧金山的天气预报是什么?” (纬度/经度)

  • “加利福尼亚州有天气警报吗?”

  • “显示纽约的活跃警报”


🧩 工作原理(流程图)

משתמש → "מה התחזית בתל אביב?"
   │
   ▼
 Host  ──►  LLM (Gemini) בוחר Tools להפעיל
   │
   ▼  (שרת ישראל, בזה אחר זה)
 open → enter("תל אביב") → select → get_content
   │
   ▼
 תוכן התחזית חוזר ל-LLM (RAG)
   │
   ▼
 LLM כותב תשובה בשפה חופשית בצ'אט ✨

📝 备注

  • 是 LLM 决定调用哪些工具以及调用顺序——我们没有编写任何硬编码逻辑。

  • 两个服务器文件 = 两个独立进程,因此任何共享状态(如打开的浏览器页面)只能存在于单个服务器内部。

Available Tools

4 tools
enter_weather_forecast_city_israelB

Type a city name into the search field on the Israeli forecast page.

Args: city: The name of the city to search for (in Hebrew)

NameRequiredDescriptionDefault
cityYes

Output Schema

NameRequiredDescription
resultYes

TDQS

B3.4/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 transparently describes the action as typing into a search field, which is useful, but it does not say whether the field is cleared first, whether suggestions are expected to appear, or whether any submission occurs. There is no contradiction with annotations.

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 short and front-loaded, with a clear action sentence followed by an Args block. Every sentence contributes useful information with no filler.

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

Completeness3/5

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

The tool is low-complexity and has an output schema, so return value details are not needed. However, with no annotations and a UI-automation context, the description omits prerequisite page state and the surrounding workflow with sibling tools, leaving some ambiguity for an agent navigating the full flow.

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?

Schema description coverage is 0%, but the description fully documents the only parameter and adds the important constraint that the city name must be in Hebrew. This meaningfully supplements the bare schema definition.

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 states a concrete action ('Type a city name into the search field') and names the target resource ('the Israeli forecast page'). It makes the tool's role reasonably clear, though it does not explicitly distinguish it from the sibling select_weather_forecast_city_israel.

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

Usage Guidelines2/5

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

No guidance is given about when this tool should be used relative to open_weather_forecast_israel, select_weather_forecast_city_israel, or get_weather_forecast_content_israel. The likely workflow is only implied by the sibling names.

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

get_weather_forecast_content_israelA

Extract the weather forecast text from the currently open forecast page.

Returns the cleaned textual content so the LLM can answer the user directly.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
resultYes

TDQS

A4.2/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 burden. It discloses that the tool extracts and cleans text and returns it for direct answering, which is useful. However, it does not specify failure behavior (e.g., what happens if no forecast page is open) or what 'cleaned' means concretely, leaving some behavioral uncertainty.

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?

Two short sentences, no filler. The core purpose is front-loaded, and the second sentence explains why the output matters to the agent. Every word earns its place.

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 zero-parameter extraction tool with an output schema, the description is largely complete: it states the source, the output type, and the intended use. It could be slightly stronger by explicitly advising that it should follow open_weather_forecast_israel or similar navigation tools, but 'currently open forecast page' conveys this adequately.

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 and the schema is fully complete with an empty properties object. The description correctly relies on page state rather than parameters, and no additional parameter explanation is needed. The baseline of 4 for zero-parameter tools applies.

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?

Description states a specific verb (Extract) and resource (weather forecast text from the currently open forecast page), and clarifies the output is cleaned textual content for direct LLM answering. This clearly separates it from sibling tools that open or select forecast pages, since it operates on the already-open page.

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 phrase 'currently open forecast page' establishes the key precondition: this tool should be used after a forecast page has been opened, not before. It does not explicitly name alternatives or exclusion conditions, but the context of opening/selecting pages among siblings makes the intended usage inferable.

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 a browser and navigate to the Israeli weather forecast website.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description must carry the behavioral burden. It does disclose that the tool launches a browser and navigates to a website, which is the core behavior. However, it does not mention side effects like whether an existing browser session is reused, whether the page loads before returning, or what happens on navigation failure.

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 words. The action and target are front-loaded and immediately understandable.

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 zero-argument browser-navigation tool, the description is largely complete: it identifies the action and target. The exact URL is not specified, but the 'Israeli weather forecast website' is enough of a target, and an output schema is present so return-value details are not required. Minor lack of contextual guidance about when to call it is already captured in usage_guidelines.

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 has zero parameters, so there is no parameter semantics burden on the description. The baseline of 4 applies because there is nothing for the description to clarify about arguments.

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 ('Open a browser and navigate') and the resource ('Israeli weather forecast website'), making the tool's purpose obvious. It does not explicitly distinguish itself from sibling tools, but the naming and 'open browser' action imply a distinct initial navigation step.

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

Usage Guidelines2/5

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

The description gives no guidance on when to use this tool versus the siblings like enter_weather_forecast_city_israel or get_weather_forecast_content_israel. There is no mention of prerequisites, ordering, or contexts where this tool is the appropriate choice.

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_israelB

Select the first city from the autocomplete suggestion list.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
resultYes

TDQS

B3.4/5.0
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It only states the immediate action and does not explain what selecting the city does, whether it mutates state, or how it connects to the forecast workflow. The phrase 'autocomplete suggestion list' adds some context, but the effects and sequencing remain undisclosed.

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, front-loaded sentence with no redundancy or filler. Every word contributes to the meaning, and it is appropriately sized for a simple zero-argument selection action.

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

Completeness3/5

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

The tool is simple: no parameters and an output schema exists, so return-value documentation is not needed. However, the description lacks workflow context and behavioral detail, such as when this tool should be invoked relative to its siblings. This makes it minimally viable but incomplete for an agent that must reason about the overall weather-forecast interaction sequence.

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, and the schema description coverage is 100%. Per the baseline for zero-parameter tools, the description does not need to add parameter-level meaning, and it does not need to compensate for any schema gaps.

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 states a specific verb ('Select') and a specific resource ('the first city from the autocomplete suggestion list'). This clearly differentiates the tool from siblings like `enter_weather_forecast_city_israel` and `get_weather_forecast_content_israel`. It does not explicitly frame the action within the larger forecast flow, so it stops short of 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 implicitly tells the agent when to act: when an autocomplete suggestion list is presented and the first city should be chosen. However, it gives no explicit guidance about prerequisites, such as needing to call `enter_weather_forecast_city_israel` first, nor does it name alternatives or when not to use this tool.

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_forecast_city_israel
    • First observedget_weather_forecast_content_israel
    • First observedopen_weather_forecast_israel
    • First observedselect_weather_forecast_city_israel

TDQS

A3.8/5.0

Scored across 4 tools

Disambiguation4/5

Each tool covers a distinct workflow step: opening the page, typing a city, selecting an autocomplete result, and extracting content. The main ambiguity is between open_weather_forecast_israel and get_weather_forecast_content_israel, since both could sound like they return forecast data without reading the descriptions carefully.

Naming Consistency5/5

All tool names follow the same verb-first snake_case pattern and consistently include weather_forecast and israel context. This makes the order and purpose of the tools predictable.

Tool Count5/5

Four tools is appropriate for the narrow browser-automation workflow this server provides. Each tool contributes one essential step, and the set is neither bloated nor too thin.

Completeness4/5

The tool surface covers the full workflow from opening the forecast site to retrieving the forecast text for a chosen city. It lacks fallback or reset tools, but those are not essential for the core task.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    MCP server that lets users obtain current Israeli city weather forecasts. It uses Playwright to browse Weather2day, extract the forecast page, and feed the cleaned data back to the LLM for natural language responses.
    -
  • F
    license
    A
    quality
    C
    maintenance
    An MCP server that provides real-time weather data for Israel by automating browser searches via Playwright. It allows LLMs to get current forecasts for Israeli cities through natural language queries.
    4
    -
  • F
    license
    B
    quality
    C
    maintenance
    MCP server that enables LLMs to retrieve weather forecasts for Israeli cities by automating a browser with Playwright, and also provides US weather alerts and forecasts via NWS API.
    4
    -