MCP server: the rain as tools¶
dpc-radar mcp gives an assistant (Claude, or any client of the
Model Context Protocol) eight tools on
the rain over Italy. Someone asks "how much has it rained on Messina in the
last three hours?" and the answer is computed from a frame, with the name of
the product and the time of the frame: the model words it, it does not
compute it.
pip install "dpc-radar[mcp]"
dpc-radar mcp # speaks MCP on standard input and output
# Claude Code, with nothing to install first:
claude mcp add dpc-radar -- uvx --from "dpc-radar[mcp]" dpc-radar mcp
For Claude Desktop, in claude_desktop_config.json:
{
"mcpServers": {
"dpc-radar": { "command": "uvx", "args": ["--from", "dpc-radar[mcp]", "dpc-radar", "mcp"] }
}
}
No key: the data are open.
| Tool | What it answers |
|---|---|
latest() |
the newest frame of every product, and how often a new one comes |
rain_at(lon, lat, hours=1) |
the rain of the last 1, 3, 6, 12 or 24 hours at a point: the median of 3×3 pixels, with the reliability of the radar there |
area_summary(west, south, east, north, hours=1) |
over a box: maximum and where, mean, median, 95th percentile, km² over 1, 5, 10, 20, 50 and 100 mm |
storm_now(west, south, east, north) |
the storms on the newest intensity frame (patches at 10 mm/h or more), with their motion; all of Italy without a box |
rain_ahead(lon, lat, minutes=60, mm=20) |
the nowcast at a point, labelled as a forecast, with the chance of at least mm |
official_alert(lon, lat, place) |
the level of the criticality bulletin: the zone of a point, the zones of a municipality or with a name, or every zone on alert |
rarity(lon, lat, hours, mm) |
the return period of an amount of radar rain at a place |
radar_status(lon, lat) |
which radars the DPC viewer reports as on: those in range of a point, or all of them. A hint from an undocumented file, null when not known |
This is the answer of rain_at(15.78, 37.92, hours=3):
{
"lon": 15.78, "lat": 37.92, "hours": 3,
"mm": 0.0, "measured": true,
"method": "median of the 3x3 pixels around the point",
"frame": {
"product": "CUM3", "time": "2026-11-17T10:30Z", "unit": "mm", "hours": 3,
"source": "radar and rain gauges («Merging»)"
},
"quality": {
"verdict": "consistent", "trusted_share": 1.0, "masked_pixels": 0,
"reasons": {"jump": 0, "beyond_record": 0, "outlier": 0, "gauge_only": 0},
"newest_frame_rejected": null
},
"reliability": {
"score": 0.9, "reliable": true, "beam_height_m": 1100.0,
"nearest_radar": "Catania Fontanarossa", "distance_km": 81.7
},
"note": "radar data, not an alert: the official alert is the DPC bulletin"
}
What keeps the numbers honest.
- Every answer carries its
frame: product and time. One hour is the radar alone (SRT1), three hours and more are the «Merging»; the answer says which. - Each frame goes through
qualityagainst the frame before it. If the newest frame is rejected, the answer is read from the one before and says so (newest_frame_rejected). Pixels that fail a rule are masked. - Not measured is
null, with a note, never zero. rain_aheadanswers"kind": "forecast", with its limits in words.- What the library refuses (a window that does not exist, half a box)
reaches the model as an error it can read:
the DPC publishes the rain of [1, 3, 6, 12, 24] hours, not of 2. radar_statusexplains a hole in the data; it never says the data are good. A radar reported on may be missing from the mosaic.- The server's instructions tell the model not to add up or estimate numbers itself, and that nothing here is an alert.
A model can still word a number badly: the server gives it the facts and the rules, it cannot read its answer. For a text that must be right, see the event reports, where the text is checked.
official_alert and regions. The bulletin names alert zones ("Versante
Jonico Meridionale") and their municipalities, not regions. place matches
a municipality (in Italian, the whole name) or part of a zone name; for a
region, ask by point or read the list of zones on alert.
The tools are the methods of Facts, which you can use from Python without
the server:
from dpc_radar import RadarClient
from dpc_radar.facts import Facts
async with RadarClient() as radar:
facts = Facts(radar)
print(await facts.rain_at(15.78, 37.92, hours=3))
print(await facts.area_summary(15.5, 37.85, 16.2, 38.3, hours=24))
dpc_radar.mcp_server ¶
The MCP server: the rain over Italy as tools an assistant can call.
dpc-radar mcp speaks the Model Context Protocol on standard input and
output. It needs the mcp extra (pip install "dpc-radar[mcp]") and no
key: the data are open. To add it to Claude Code::
claude mcp add dpc-radar -- uvx --from "dpc-radar[mcp]" dpc-radar mcp
The tools are the methods of :class:dpc_radar.facts.Facts:
latest: the newest frame of every product.rain_at: the rain of the last 1, 3, 6, 12 or 24 hours at a point.area_summary: the same over a box: maximum, mean, km² over thresholds.storm_now: the storms on the newest intensity frame, and where they go.rain_ahead: the nowcast at a point, labelled as a forecast.official_alert: the level of the DPC criticality bulletin.rarity: how rare an amount of rain is at a place.radar_status: which radars the DPC reports on and off.
Every answer names the product and the time of the frame it was read from: the model words the answer, it does not compute it. What the library refuses (a box outside Italy, a window the DPC does not publish) reaches the model as an error it can read and act on.
create_server ¶
create_server(radar: Callable[[], Source] | None = None, *, bulletin: Callable[[], Awaitable[Bulletin]] | None = None) -> MCPServer[Any]
The MCP server, its tools bound to one :class:dpc_radar.facts.Facts.
radar builds the client on the first call (default: a
:class:dpc_radar.RadarClient); bulletin fetches the newest bulletin
(default: :func:dpc_radar.bulletins.latest).
dpc_radar.facts ¶
The numbers an assistant may quote, each with the frame it came from.
A language model that is asked "how much did it rain in Florence?" will answer
with a number, whether it has one or not. :class:Facts gives it the number:
every answer is a plain dictionary, ready for JSON, that names the product and
the time of the frame it was computed from, how the value was read and how far
the radar can be trusted there. The model words the answer; it does not compute
it. This is what the MCP server (:mod:dpc_radar.mcp_server) serves, and it
can be used as it is from Python::
async with RadarClient() as radar:
facts = Facts(radar)
await facts.rain_at(11.25, 43.77, hours=3)
- :meth:
Facts.latest: the newest frame of every product. - :meth:
Facts.rain_at: the rain of the last 1, 3, 6, 12 or 24 hours at a point. - :meth:
Facts.area_summary: the same over a box: maximum, mean, km² over thresholds. - :meth:
Facts.storm_now: the storms on the newest intensity frame, and where they go. - :meth:
Facts.rain_ahead: the nowcast at a point, always labelled as a forecast. - :meth:
Facts.official_alert: the level of the DPC criticality bulletin. - :meth:
Facts.rarity: how rare an amount of rain is at a place. - :meth:
Facts.radar_status: which radars the DPC reports on and off.
The rules every answer follows:
- a point is read as the median of the 3x3 pixels around it, never as one pixel;
- the newest frame goes through :meth:
dpc_radar.RainGrid.qualityagainst the one before it; if it is rejected the answer comes from the frame before, and says so; Nonemeans not measured, which is not the same as dry;- millimetres are rounded to 0.1: the radar does not know more than that.
Frames are kept in memory (cache_frames of them), so a conversation that
asks about ten places downloads each frame once.
Source ¶
Bases: Protocol
Where the frames come from: a :class:dpc_radar.RadarClient, or anything like it.
Facts ¶
Answers about the rain over Italy, as dictionaries that name their frames.
latest
async
¶
latest() -> dict[str, Any]
The newest frame of every product: its time, and how often a new one comes.
rain_at
async
¶
rain_at(lon: float, lat: float, hours: int = 1) -> dict[str, Any]
The rain of the last hours (1, 3, 6, 12 or 24) at a point, in mm.
area_summary
async
¶
area_summary(west: float, south: float, east: float, north: float, hours: int = 1) -> dict[str, Any]
The rain of the last hours over a box in degrees: maximum, mean, km².
storm_now
async
¶
storm_now(west: float | None = None, south: float | None = None, east: float | None = None, north: float | None = None) -> dict[str, Any]
The storms on the newest SRI frame (patches at 10 mm/h or more), heaviest first.
With a box, only those that touch it. moving is the motion of the
rain around the storm over the last half hour: km/h, and the degrees
from north of where it goes (90: east).
rain_ahead
async
¶
rain_ahead(lon: float, lat: float, minutes: int = 60, mm: float = 20.0) -> dict[str, Any]
A forecast: the rain of the next minutes (5 to 120) at a point.
The newest SRI frame moved along the motion of the last half hour
(:mod:dpc_radar.nowcast), and the chance of at least mm.
official_alert
async
¶
official_alert(lon: float | None = None, lat: float | None = None, place: str | None = None) -> dict[str, Any]
The level of the newest DPC criticality bulletin, for today and tomorrow.
With lon and lat: the zone of that point. With place: the
zones whose name contains it, or that hold a municipality of that
name. With neither: every zone on alert (yellow or more).
rarity ¶
rarity(lon: float, lat: float, hours: int, mm: float) -> dict[str, Any]
How rare mm of rain in hours (1, 3, 6 or 24) are at a point.
radar_status
async
¶
radar_status(lon: float | None = None, lat: float | None = None) -> dict[str, Any]
Which radars the DPC reports on and off now (:mod:dpc_radar.status).
With lon and lat: the radars whose range holds the point, the
nearest first. Without: every radar of the status file. known
false means there is no status to read, which is not "all on".
lonlat ¶
lonlat(grid: RainGrid, row: int, col: int) -> tuple[float, float]
The centre of a pixel, in degrees.
describe ¶
describe(part: RainGrid, thresholds: tuple[int, ...] = THRESHOLDS) -> dict[str, Any]
The rain of a frame, or of a piece of one, as numbers.
The mean, the median and the 95th percentile are of the pixels with data,
each weighted by its area. measured_share is the share of the area that
has data: a mean over half a box is the mean of that half.
trust ¶
trust(lon: float, lat: float) -> dict[str, Any]
How far the radar can be trusted at a point (:func:dpc_radar.reliability).
rarity_of ¶
rarity_of(lon: float, lat: float, hours: int, mm: float) -> dict[str, Any]
How rare mm in hours are at a point (:func:dpc_radar.rarity).