mcp-weather-server
Provides live weather data (current conditions, forecasts) and city geocoding through Open-Meteo API, enabling AI assistants to answer weather queries without an API key.
README
mcp-weather-server
A Model Context Protocol server that gives Claude (or any MCP client) live weather tools, backed by Open-Meteo — which is free and needs no API key.
The Model Context Protocol (MCP) is an open standard that lets AI assistants call external tools and data sources through a common interface, instead of every app inventing its own plugin system. A client such as Claude Desktop launches an MCP server as a subprocess and talks to it over JSON-RPC, discovering and invoking whatever tools the server exposes.
Overview
I built this server to expose three weather tools:
| Tool | What it does |
|---|---|
geocode_city(name) |
Resolves a city name to coordinates, country, and timezone; lists alternative matches for ambiguous names like "Springfield" |
current_weather(city) |
Live conditions: temperature, feels-like, humidity, wind, and a readable sky description with the matching emoji |
forecast(city, days=3) |
Daily forecast for 1–16 days: min/max temperature, precipitation total and probability, peak wind |
Everything returns readable structured text, so the model can relay answers directly. Errors come back as plain-language messages ("No place called 'Atlantis' was found…") rather than tracebacks.
Architecture
Claude Desktop / any MCP client
│
│ JSON-RPC over stdio
▼
┌──────────────────────────────────────┐
│ weather_mcp.server (FastMCP) │ thin tool layer:
│ geocode_city · current_weather · │ docstrings, schemas,
│ forecast │ text formatting
└───────────────┬──────────────────────┘
│ typed dataclasses
▼
┌──────────────────────────────────────┐
│ weather_mcp.openmeteo (pure stdlib)│ all domain logic:
│ URL building · timeouts · JSON │ uses weather_mcp.codes
│ parsing · friendly error mapping │ for WMO code → text/emoji
└───────┬──────────────────────┬───────┘
│ HTTPS │ HTTPS
▼ ▼
geocoding-api.open-meteo.com api.open-meteo.com
(city search) (current + daily forecast)
Design decisions
- Standard-library HTTP instead of
requests/httpx. The only runtime dependency is themcpSDK itself. It also gives the tests a single seam to mock (urlopen), so the whole client is unit-testable offline. - All logic lives in
openmeteo.py;server.pystays thin. The client module never importsmcp, so the test suite runs on a bare Python install with nothing pip-installed. - Frozen, typed dataclasses at the API boundary. Tools work with
Location,CurrentWeather, andDailyForecastvalues instead of raw dicts, so a malformed API response fails loudly at parse time, not somewhere downstream. - Errors are phrased for end users. Network failures, timeouts, HTTP errors, and unknown cities all map to
WeatherErrorsubclasses whose messages the tools return verbatim — an LLM can relay "check the spelling" far more usefully than a stack trace. - Open-Meteo as the data source. No API key, no signup, generous free limits — anyone can clone this repo and have working weather tools in under a minute.
- Timeouts on every request (10 s default, overridable per call), so a hung network call can never wedge the server.
Quickstart
Requires Python 3.11+.
git clone https://github.com/srathish/mcp-weather-server.git
cd mcp-weather-server
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python -m weather_mcp # starts the server on stdio
Claude Desktop
Add the server to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json, Windows: %APPDATA%\Claude\claude_desktop_config.json), using the absolute path to your clone:
{
"mcpServers": {
"weather": {
"command": "/absolute/path/to/mcp-weather-server/.venv/bin/python",
"args": ["-m", "weather_mcp"],
"env": {
"PYTHONPATH": "/absolute/path/to/mcp-weather-server"
}
}
}
}
Restart Claude Desktop and ask something like "What's the weather in Berlin right now?" — Claude will call current_weather for you.
MCP Inspector
For interactive debugging, the official inspector works out of the box:
pip install "mcp[cli]"
mcp dev weather_mcp/server.py
This opens a web UI where you can invoke each tool by hand and inspect the requests and responses.
How I know it works
The test suite covers the parts that can actually break: geocoding parsing (including the no-results case), current-weather and forecast parsing, WMO code mapping (including the unknown-code fallback), the mapping of HTTP/network/timeout failures onto friendly messages, and URL construction (parameters and non-ASCII city names encoded correctly).
All HTTP is mocked at the urlopen seam, so the tests use only the standard library — no pip installs, no network:
python3 -m unittest discover -s tests -v
28 tests, all passing on Python 3.11+.
Limitations
- Geocoding trusts the top match.
current_weather("Springfield")picks Open-Meteo's best-ranked Springfield. Usegeocode_cityfirst when a name is ambiguous. - Metric units only. Temperatures are °C and wind speeds km/h; I have not added unit conversion.
- No caching or rate limiting. Every tool call is a fresh API request. Open-Meteo's free tier is generous, but a busy deployment would want a small TTL cache.
- Forecast only, no history. The server exposes current conditions and up to 16 days ahead; Open-Meteo's historical archive endpoints are not wired up.
- Output is text, not JSON. The tools return human-readable text for the model to relay. If a downstream program needed to parse results, structured output would be the better contract.
License
MIT — see LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。