MCP Weather Assistant

MCP Weather Assistant

Enables weather queries for US forecasts and alerts via the National Weather Service API, and Israeli weather forecasts through a Playwright-controlled browser, all through an interactive chat interface using OpenRouter and MCP.

Category
Visit Server

README

MCP Weather Assistant

An interactive weather assistant built with the Model Context Protocol (MCP). The host connects to two local MCP servers, publishes their tools to an OpenRouter-compatible language model, and lets the model decide when to retrieve weather information.

Features

  • Weather forecasts for locations in the United States through the National Weather Service API.
  • Active weather alerts for a United States state.
  • Israeli weather forecasts through the weather2day.co.il website and a visible Chromium browser controlled by Playwright.
  • One interactive terminal chat interface.
  • Multiple MCP servers connected over stdio.
  • Automatic tool discovery and namespacing to avoid collisions between servers.

Project Structure

File Purpose
host.py Main application. Connects to MCP servers, calls OpenRouter, routes tool calls, and runs the chat loop.
client.py Reusable MCP stdio client wrapper. Starts a server with the current Python interpreter and lists its tools.
weather_USA.py MCP server backed by the National Weather Service API.
weather_Israel.py MCP server backed by weather2day.co.il and Playwright.
pyproject.toml Python project metadata and declared dependencies.
uv.lock Locked dependency versions for uv-based environments.
.env Local environment variables. This file is ignored by Git.

Requirements

  • Windows, macOS, or Linux.
  • Python 3.13 or newer.
  • An OpenRouter API key.
  • Internet access to OpenRouter, api.weather.gov, and weather2day.co.il.
  • Chromium, installed through Playwright, for Israeli weather queries.
  • A virtual environment is recommended.

Installation

Using uv

From the project directory:

uv sync
uv run playwright install chromium

The project currently imports httpx directly. If it is not already present in the locked environment, install it with:

uv add httpx

Using standard Python tooling

py -3.13 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install anthropic mcp python-dotenv playwright openai google-genai httpx
python -m playwright install chromium

On macOS or Linux, activate the environment with:

source .venv/bin/activate

The declared dependencies include several provider SDKs that are not currently used by host.py; they remain part of the project metadata for compatibility with the template.

Configuration

Create a .env file in the project root:

OPENROUTER_API_KEY=your_openrouter_api_key

host.py loads this file with python-dotenv and sends the key as a Bearer token to OpenRouter. Do not commit .env or expose the key in source control, logs, screenshots, or error reports.

The current model is configured in host.py:

MODEL = "nvidia/nemotron-3-super-120b-a12b:free"

Change this constant if you want to use another OpenRouter model that supports tool calling.

Running the Assistant

With uv:

uv run python host.py

With an activated virtual environment:

python host.py

You should see a startup message followed by a Query: prompt. Type a question and press Enter. Type quit to stop the application.

Example questions:

What is the forecast for 34.05, -118.25?
Are there any active weather alerts in California?
What is the weather forecast in Tel Aviv?

The host prints tool calls as they occur, followed by the model's final response.

MCP Servers and Tools

United States server

weather_USA.py starts an MCP server named weather-USA and provides:

  • get_alerts_in_USA(state)
    • state: two-letter state code such as CA or NY.
    • Uses the NWS active-alerts endpoint.
  • get_forecast_in_USA(latitude, longitude)
    • latitude: decimal latitude.
    • longitude: decimal longitude.
    • Resolves the location through the NWS points endpoint, then returns the first five forecast periods.

The NWS API request uses Accept: application/geo+json and a custom User-Agent.

Israel server

weather_Israel.py starts an MCP server named weather-Israel and provides:

  1. open_weather_forecast_israel()
    • Opens a non-headless Chromium browser and navigates to the Israeli forecast website.
  2. enter_weather_forecast_city_israel(city)
    • Enters a city name and waits for autocomplete suggestions.
  3. select_weather_forecast_city_israel()
    • Selects the first autocomplete suggestion and waits for the forecast page.
  4. get_forecast_content_israel()
    • Extracts visible text from the loaded page, cleans empty lines, and limits the result to 4,000 characters.

The Israeli tools are stateful and must be called in order. The browser must be opened before entering a city, and a city must be selected before extracting the forecast.

Architecture

User terminal
    |
    v
host.py (ChatHost)
    |-- OpenRouter chat-completions API
    |
    |-- client.py -> weather_USA.py -> api.weather.gov
    |
    `-- client.py -> weather_Israel.py -> Playwright -> weather2day.co.il

At startup, ChatHost creates one MCPClient for each weather server. Each client launches its server as a child process using the same Python interpreter as the host. The host discovers all MCP tools and exposes them to OpenRouter using function-calling schemas.

To prevent duplicate names, tools are exposed to the model as:

<server_script_name>__<tool_name>

For example, the USA alert tool is exposed as weather_USA__get_alerts_in_USA. When OpenRouter requests a tool, the host maps that public name back to the owning MCP client and original tool name, executes it, and sends the result back into the model conversation.

Running an Individual MCP Server

Each server can be started directly for MCP-compatible clients or for basic smoke testing:

python weather_USA.py
python weather_Israel.py

These programs use MCP stdio transport, so they are intended to communicate with an MCP client rather than display a normal web page or command prompt.

Troubleshooting

ModuleNotFoundError: No module named 'httpx'

Install the missing dependency:

uv add httpx

or:

python -m pip install httpx

Chromium does not start

Install the Playwright browser binary:

python -m playwright install chromium

The Israeli server intentionally launches Chromium with headless=False, so a desktop session is required for that provider.

OpenRouter authentication fails

Check that .env is in the same directory as host.py, that the variable is named exactly OPENROUTER_API_KEY, and that the key is active. Restart the host after changing the file.

No tools are available

Confirm that both server scripts exist in the project root and that the host is started from that directory. The host currently uses the relative paths ./weather_USA.py and ./weather_Israel.py.

A weather request fails

The application depends on external services. Check internet access, the NWS response for the requested coordinates or state, and whether the Israeli website's HTML selectors have changed.

Security and Operational Notes

  • host.py and the NWS client disable TLS certificate verification with verify=False. This may be necessary in the current network environment, but it reduces transport security and should be replaced with normal certificate verification in production.
  • OpenRouter receives the user's query and the results returned by weather tools.
  • The Israeli provider opens a visible browser and scrapes the page's body text. Website layout changes can break the selectors or alter the extracted content.
  • The application has no persistent conversation history; each terminal query starts a new model message list.
  • Errors are printed to the terminal and are not written to a logging service.

Development Notes

The MCP server scripts expose tools through FastMCP decorators and use async functions for network and browser operations. Keep the stdio channel reserved for MCP protocol traffic when modifying a server; diagnostic output should be handled carefully so it does not corrupt protocol communication.

There are currently no automated tests in the repository. A useful next test layer would mock the NWS responses, OpenRouter tool-call responses, and Playwright page interactions so the orchestration can be verified without network access or a browser.

License

No license file is currently included in this repository.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured