DEV Community

Cover image for How I Built a Water Utility Risk Intelligence Tool With Python and MCP
Oaida Adrian
Oaida Adrian

Posted on

How I Built a Water Utility Risk Intelligence Tool With Python and MCP

Water utilities fail slowly: aging pipes, drought pressure, unaffordable rates, crumbling infrastructure. The data to assess all of it is public — you just need to pull nine different government APIs and score what comes back. That's the tool I built.

The gap

The niche's reference actor is MCP-standby-only: its batch runs emit zero dataset items. It's an MCP server you call by hand — fine for a demo, useless for monitoring a portfolio of utilities. Our build fixes that: batch mode returns a full assessment item per utility, and the engine is also exposed as eight fastmcp MCP tools for interactive use.

The scoring engine

Four transparent models, one composite score, five verdicts:

  • Water Vulnerability — contamination and source risk
  • Infrastructure — pipe age and condition signals
  • Drought/Climate — precipitation and heat trends
  • Affordability — rate and income pressure

Composite weights: vulnerability 0.30, infrastructure 0.25, drought 0.25, affordability 0.20. Verdicts: CRITICAL ≥80, HIGH_RISK ≥60, ELEVATED ≥40, MANAGEABLE ≥20, LOW_RISK <20. Every signal that moved a score is returned in the output — no black-box scoring.

Nine keyless upstreams

USGS earthquakes, FEMA disaster declarations (v2 — the v1 endpoint 404s), NOAA weather alerts (custom UA required), Federal Register water-scoped notices, CFPB complaints (default UA only — a custom UA gets 403, a lovely asymmetry), BLS unemployment + CPI, World Bank precipitation/GINI indicators, and Open-Meteo geocoding. OpenAQ v3 needs a key, so it's an optional input that degrades gracefully.

The smoke test

Local engine: NYC → 26 MANAGEABLE, Flint → 21 MANAGEABLE, Sacramento → 26 MANAGEABLE with an aging-infrastructure signal. Cloud: NYC full assessment → composite 26 with all four dimensions populated; Phoenix drought → LOW_RISK 8 with a real NOAA heat signal. The MCP server boots via fastmcp, lists all eight tools, and executes end-to-end.

The honest bits

  • It's a screening tool, not an engineering audit — a composite score won't tell you which valve is rusting
  • OpenAQ is keyed and optional; the other eight sources are keyless by design
  • Some upstreams rate-limit aggressively; the batch mode paces requests

Try it

👉 Water Utility Risk Intelligence on Apify Store

More from me

While you're here, these might be worth a read:

Top comments (0)