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.
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.ilwebsite 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, andweather2day.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 asCAorNY.- 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:
open_weather_forecast_israel()- Opens a non-headless Chromium browser and navigates to the Israeli forecast website.
enter_weather_forecast_city_israel(city)- Enters a city name and waits for autocomplete suggestions.
select_weather_forecast_city_israel()- Selects the first autocomplete suggestion and waits for the forecast page.
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.pyand the NWS client disable TLS certificate verification withverify=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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。