MCP Weather Agent
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Weather AgentWhat's the weather forecast for Jerusalem today?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ค๏ธ MCP Weather Agent
An intelligent, multi-region weather assistant powered by OpenAI and the Model Context Protocol (MCP).
Get real-time weather forecasts and alerts for Israel and the United States through a natural language chat interface. The agent intelligently routes questions to the appropriate data source and compiles answers from live web data and official weather APIs.
โจ Features
๐ค AI-Powered Chat: Conversational weather queries using GPT-4o-mini
๐ Dual Data Sources:
๐ฎ๐ฑ Israel: Live web scraping from Weather2day via Playwright
๐บ๐ธ USA: Official National Weather Service API
๐ Smart Tool Routing: The agent automatically selects the right tool based on your question
๐ฌ Natural Language: Ask questions in plain English; the agent understands context and intent
๐ Secure: API keys stored in
.envand excluded from version control๐ฏ Interactive: Real-time chat loop with visible browser automation for Israel queries
Related MCP server: MCP Weather Assistant
๐ Table of Contents
๐ Quick Start
Get up and running in 3 minutes:
# 1. Install dependencies
uv sync
uv run playwright install chromium
# 2. Create .env file with your OpenAI API key
copy .env.example .env
# Edit .env and add: OPENAI_API_KEY=sk-...
# 3. Run the agent
uv run .\host.py
# 4. Ask a weather question!
# Example: "What is the weather forecast for Jerusalem?"๐ฆ Requirements
Component | Version | Purpose |
Python | 3.13+ | Runtime environment |
OpenAI API Key | โ | GPT-4o-mini model access |
uv | Latest | Fast Python package manager |
Chromium | Latest | Browser automation (Playwright) |
Internet | โ | API access and web scraping |
๐ง Setup
1. Install Dependencies
Open a terminal in the project directory and run:
# Install Python dependencies
uv sync
# Download Chromium browser for Playwright (required for Israel weather)
uv run playwright install chromiumFirst time taking a while? YesโPlaywright downloads Chromium (~300 MB). This is a one-time operation.
2. Configure OpenAI API Key
Create a .env file in the project root:
# Option A: Copy the template
copy .env.example .env
# Option B: Create manually
echo OPENAI_API_KEY=your_openai_api_key > .envReplace your_openai_api_key with your actual OpenAI API key from platform.openai.com/account/api-keys.
โ ๏ธ Important: Never commit .env or share your API key. The .gitignore already excludes it.
3. Verify Installation
Test the setup:
uv run .\host.pyYou should see:
Connected to server with tools: [...]
MCP Client Started!
Type your queries or 'quit' to exit.
Query:Press Ctrl+C or type quit to exit.
โถ๏ธ Running the Agent
Start the interactive chat:
uv run .\host.pyThe agent launches in interactive mode. Type a weather question and press Enter. The agent will:
โ Parse your question
๐ Route to the appropriate weather tool (Israel or USA)
๐ Fetch real-time data (may open a browser window for Israel)
๐ Process and format the response
๐ฌ Return the answer
Type quit to exit.
For Israel queries: A Chromium browser window opens automatically. This is normalโthe agent is using Playwright to interact with Weather2day. The window closes when the query completes.
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ OpenAI (GPT-4o-mini) โ
โ (Tool Selection & Reasoning) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโดโโโโโโโโโโโโโ
โ โ
โโโโโโโโโผโโโโโโโโโ โโโโโโโโโผโโโโโโโโโ
โ MCP Host โ โ MCP Host โ
โ (client.py) โ โ (client.py) โ
โโโโโโโโโฌโโโโโโโโโ โโโโโโโโโฌโโโโโโโโโ
โ โ
โโโโโโโโโผโโโโโโโโโโโโโโโ โโโโโโโโผโโโโโโโโโโโโโโ
โ weather_Israel.py โ โ weather_USA.py โ
โ (Playwright + Web) โ โ (NWS API) โ
โโโโโโโโโฌโโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโผโโโโโโโโโโโโโโโ โโโโโโโโผโโโโโโโโโโโโโโ
โ Weather2day.co.il โ โ api.weather.govโ
โ (Live Web Browser) โ โ (REST API) โ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโData Flow:
You ask a question in the chat
The host sends it to OpenAI with available tools
OpenAI selects which tool to call based on the question
The appropriate MCP server executes and returns data
The host formats and returns the answer
๐ฌ Example Queries
๐ฎ๐ฑ Israel Weather
What is the weather forecast for Jerusalem?
Give me the forecast for Tel Aviv.
What is the weather like in Haifa today?
Show me the forecast for Eilat.
What is the weather in Beer Sheva?
Is it going to rain in Kfar Saba tomorrow?
Tell me about the weather in Nazareth.
What's the forecast for Tiberias?Supported Cities: Jerusalem, Tel Aviv, Haifa, Eilat, Beer Sheva, Kfar Saba, Tiberias, Nazareth, and most major Israeli cities recognized by Weather2day.
๐บ๐ธ USA Weather
What is the weather forecast for New York City? (40.7128, -74.0060)
What's the weather at latitude 34.0522, longitude -118.2437? (Los Angeles)
Are there any active weather alerts in California?
What weather alerts are in effect in New York?
Give me the forecast for Chicago coordinates. (41.8781, -87.6298)
Are there any severe weather warnings in Texas?Format:
Forecasts: Use latitude/longitude coordinates
Alerts: Use two-letter state codes (
CA,NY,TX, etc.)
๐ฏ Smart Agent Behavior
The agent understands context:
โ "What's the weather in Jerusalem?" โ Uses Israel tool
โ "I'm visiting New York, what's the forecast?" โ Uses USA tool (40.71, -74.01)
โ "Tell me about weather in Tel Aviv and Los Angeles" โ Calls both tools
โ "Is it raining in Chicago right now?" โ Routes to USA tool
๐ Project Structure
MCP Weather/
โโโ host.py # Main chat host (OpenAI + tool orchestration)
โโโ client.py # MCP client connector
โโโ weather_Israel.py # Israel MCP server (Playwright + Web)
โโโ weather_USA.py # USA MCP server (NWS API)
โโโ pyproject.toml # Dependencies and project metadata
โโโ uv.lock # Locked dependency versions
โโโ .env.example # Template for environment variables
โโโ .env # Your API keys (git-ignored)
โโโ README.md # This file
โโโ .gitignore # Git exclusion rules๐ Troubleshooting
โ OPENAI_API_KEY is missing
Problem: The agent can't find your API key.
Solution:
Verify
.envexists in the project root (same folder ashost.py)Check the file contains:
OPENAI_API_KEY=sk-your-actual-key-hereRestart the host:
uv run .\host.py
โ Chromium browser won't launch
Problem: "Failed to launch browser" error.
Solution:
uv run playwright install chromiumIf still failing, check disk space (Chromium needs ~500 MB).
โ Connection timeout or API errors
Problem: "net::ERR_CONNECTION_RESET" or request failures.
Solution:
Check your internet connection
Verify your OpenAI API key is valid at platform.openai.com
Check API usage and billing
โ Israel browser opens but search fails
Problem: City search doesn't return suggestions.
Explanation: The Weather2day autocomplete only works on the /forecast page. The tool automatically returns to that page before each search, but if it fails:
Solution:
Verify Chromium is up to date:
uv run playwright install --with-deps chromiumEnsure you have internet connectivity to
weather2day.co.ilCheck for browser pop-ups or cookie banners (the agent handles these, but very slow connections may timeout)
โ "A server fails to connect"
Problem: MCP server connection error.
Solution:
# Run from the project directory
Set-Location .\project-template
uv run .\host.pyโ FAQ
Q: How does the agent decide which tool to use?
A: OpenAI's GPT-4o-mini reads your question and selects the best tool based on the context (country/region mentioned, coordinates provided, etc.). It's not rule-basedโit uses language understanding.
Q: Can I ask about multiple regions in one query?
A: Yes! The agent can call multiple tools. Try: "What's the weather in Tel Aviv and New York?"
Q: Why does the Israel browser open visibly?
A: Playwright automates Weather2day by typing into the live search, selecting results, and reading the page. Headless mode (invisible) doesn't work with this site's JavaScript-heavy autocomplete, so the browser runs visibly.
Q: How much does this cost?
A: You're billed by OpenAI based on API calls. Each query costs ~$0.001โ$0.01 depending on response length. Israel web scraping is free; USA API is free (NWS is public).
Q: What if I want to add more regions?
A: Create a new MCP server (e.g., weather_Europe.py) and register it in host.py under self.mcp_clients. See the existing servers for the pattern.
Q: Is my API key safe?
A: Yes. Your .env is excluded from Git and stored locally only. Never paste your key in code or public chat.
Q: Can I use this in production?
A: This is a demo project. For production:
Use async request queuing
Add logging and error recovery
Cache forecasts (weather changes hourly, not per-query)
Set up monitoring and alerts
Use environment-based configuration
๐ Security
โ ๏ธ Do | โ Don't |
โ
Keep | โ Commit |
โ Rotate API keys regularly | โ Share your API key |
โ Use environment variables in production | โ Hardcode secrets in code |
โ Check API billing limits | โ Leave quota unlimited |
โ Use HTTPS for API calls | โ Use HTTP in production |
If your API key is exposed:
Revoke it immediately in OpenAI Dashboard
Generate a new key
Update
.env
๐ License
This project is provided as-is for educational purposes. See LICENSE for details.
๐ค Contributing
Have ideas to improve the agent? Contributions are welcome!
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
๐ Support
๐ Report bugs via GitHub Issues
๐ก Suggest features in Discussions
๐ง For security issues, email privately (do not open a public issue)
Happy forecasting! ๐ฆ๏ธโ๏ธ
Available Tools
4 toolsenter_weather_forecast_city_israelC
ืืงืื ืฉื ืขืืจ ืืืืื ืืืชื ืืฉืื ืืืืคืืฉ ืืืชืจ ืืื ืืืืืืจ.
:param city_name: ืฉื ืืขืืจ ืืืืคืืฉ (ืืืฉื: 'ืืจืืฉืืื', 'ืชื ืืืื')
| Name | Required | Description | Default |
|---|---|---|---|
| city_name | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral burden. It discloses only that it fills a search field; it does not say whether the search is submitted, what happens if the city is not found, whether the site must already be open, or what state the page is left in for the next sibling call.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short lines with the action stated first and the parameter documented in a conventional :param block; nothing is padded. It is efficient, though the colon-prefixed param line is stylistically thin for a tool with a workflow dependency.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need no explanation. However, for a browser-automation step in a four-tool sequence, the description omits the ordering/state assumptions an agent needs, leaving a real gap despite the adequate parameter hint.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% for the single parameter, so the description must compensate, and it partially does by explaining that city_name is the search string and giving examples ('ืืจืืฉืืื', 'ืชื ืืืื'). It adds useful illustrative meaning but no format or validation constraints beyond that.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a concrete verb and resource: it receives a city name and types it into the search field of the weather site. That is specific enough to distinguish a UI-entry step, though it never names or contrasts the sibling tools (select_weather_forecast_city_israel, open_weather_forecast_israel), so an agent must infer the ordering itself.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no explicit when-to-use guidance, no prerequisites, and no mention of the sibling steps that presumably follow. The workflow role (enter search text, then select the city, then read content) is only implied by the tool names, not stated in the description.
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
ืืืืงืฅ ืืช ืืืงืกื ืืืืื ืืชืื ืืฃ ืืชืืืืช ืื ืืืื ืฉื ืคืชื ืืืคืืคื, ืื ืงื ืจืืืืื ืืืืชืจืื ืืืืืืจ ืืช ืืชืืื ื-LLM ืืฆืืจื ืืชื ืชืฉืืื.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses the extraction behavior and whitespace cleanup, which is useful, but omits what happens when no page is open, failure/error behavior, and any permission considerations. Adequate but incomplete for a zero-annotation tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence stating the action, with no wasted preamble. The trailing clause about returning content 'to the LLM to provide an answer' is mildly redundant but not harmful.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need not be described, and there are no parameters to document. The main remaining gap is state-dependence (what it requires the browser to already be showing), which is only implied rather than guaranteed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has zero parameters, so the baseline of 4 applies. Nothing about parameters needs explaining and the description does not confuse the matter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a specific verb and resource: it extracts the visible text from the current forecast page open in the browser and returns a cleaned version. That is clear and distinguishable from open/enter/select siblings in the pipeline, though it never explicitly names how it differs from them.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is implied rather than stated: it works on the page 'opened in the browser', so the agent can infer it must run after opening and selecting a city. There is no explicit statement of prerequisites, exclusions, or what to do instead if the page is not ready.
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
ืคืืชื ืืช ืืคืืคื ืืืื ืืจื ื ืืื ืืื ืืืฃ ืืืืช ืฉื ืืชืจ ืืื ืืืืืืจ ืืืฉืจืืื.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It usefully discloses the side effect that a browser window is opened, which is meaningful for an agent. It does not mention state (new tab vs. existing), auth, or what the user sees next, leaving gaps for a no-annotation tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with no filler; the action and destination are stated immediately. Nothing needs trimming.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple (0 params, output schema present so return values need no explanation) and the description adequately covers the action. The remaining gap is routing context against the sibling tools, which is a moderate omission rather than a fatal one.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, and the schema coverage is 100%, so there is nothing for the description to disambiguate. Baseline 4 applies since no parameter semantics are needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a concrete verb+resource in Hebrew: it opens the browser and navigates to the Israeli weather site's homepage. An agent can tell what the tool does. However, it never distinguishes itself from the three sibling tools (enter/select/get_weather_forecast_*), so it stops at 4.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The mention of navigating to the 'homepage' implies this is the entry/starting step before the city-selection and content siblings, but there is no explicit statement of when to use it versus enter_weather_forecast_city_israel or get_weather_forecast_content_israel. Usage is only 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
ืืืืจ ืืช ืืชืืฆืื ืืจืืฉืื ื ืืจืฉืืืช ืืขืจืื ืฉื ืคืชืื ืืขืงืืืช ืืืืคืืฉ.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full disclosure burden. It usefully reveals that selection is deterministic ('first result'), meaning the agent cannot choose a specific city, but it omits what happens if the list is empty, whether it navigates to a new page, and any auth or error behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single, tight sentence with no padding, and the key constraint ('first result') is placed prominently. Appropriate length for a zero-argument UI step.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists so return values need not be explained, and there are no parameters. What remains unstated is the workflow contract (what must precede this call, what state follows it), which matters for a sequential UI-automation tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, so there is nothing for the description to disambiguate. The baseline for a parameterless tool is 4, and the description adds no misleading parameter claims.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific verb (selects) and a specific target (the first result in the city list opened by the search), which distinguishes it from siblings like enter_weather_forecast_city_israel or open_weather_forecast_israel. It stops short of explicitly naming the alternative tools, but the action and target are clear.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'the city list that was opened following the search' implies this step follows a search and a list-opening step, giving sequencing context. However, it never states when to use this versus entering a city directly, nor any preconditions or failure conditions.
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.
4 tool updates
v0.1.0- First observed
enter_weather_forecast_city_israel - First observed
get_weather_forecast_content_israel - First observed
open_weather_forecast_israel - First observed
select_weather_forecast_city_israel
TDQS
Scored across 4 tools
Each tool maps to a distinct browser-automation step (open site, enter city, select result, extract content), so they are separable in principle. However, they form a rigid ordered pipeline with no way to tell from the names alone that they must be chained, and enter vs. select could be momentarily confused by a hurried agent.
All names are snake_case and share a predictable verb_..._israel suffix (open/enter/select/get_weather_forecast_..._israel). Minor structural deviation: open_weather_forecast_israel omits the 'city' segment the other three include, but the pattern is still readable and consistent.
Four tools is a reasonable count for this narrow scraping workflow. It is slightly granular, since a single 'fetch forecast for city' operation is split into four browser steps, but each step is individually actionable and the set stays well-scoped.
The surface covers the happy path open -> search -> select -> extract, but has no tool to close/reset the browser session, no error or no-result handling, and despite the generic server name 'MCP Weather Agent' it only supports Israeli locations. Agents can complete the core task but will hit dead ends on edge cases.
Maintenance
Related MCP Connectors
US weather & geo for AI agents: forecasts, alerts, earthquakes, elevation, geocoding. No keys.
US weather & geo for AI agents: forecasts, alerts, earthquakes, elevation, geocoding. No keys.
Provide real-time and forecast weather information for locations in the United States using naturaโฆ
Get US weather forecasts, active alerts, and current observations.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables users to query real-time weather data for Israeli cities using natural language, automatically scraping a weather website via Playwright and returning AI-generated answers.-
- FlicenseAqualityCmaintenanceEnables users to query weather information for Israel via Playwright browser automation and for the USA via a weather API, allowing an LLM to access real-time weather data and alerts.4-
- FlicenseNot gradedqualityCmaintenanceEnables natural language weather queries for Israeli cities with real-time data extracted via Playwright, plus USA weather alerts and forecasts via NWS API, all orchestrated by Groq LLM.1-
- FlicenseNot gradedqualityBmaintenanceEnables natural language weather queries for cities in Israel and the United States, combining browser automation and official API retrieval.-