Skip to main content

MCP server for EPANET water distribution network simulation via ePyT

Project description

EPANET MCP Server

Linter Pytest

A Model Context Protocol (MCP) server that exposes EPANET water-distribution network modelling capabilities through ePyT - the EPANET Python Toolkit.

Any MCP-compatible LLM can load water network models, run simulations, modify parameters, and generate complex what-if scenarios through natural language.


Features

Category Tools
Load & Inspect load_network, unload_network, list_networks, list_bundled_networks, get_network_summary, get_nodes, get_links, get_patterns, get_controls, get_curves, get_options
Simulate run_hydraulic_simulation, run_quality_simulation, run_full_simulation, get_pressure_at_time, get_flow_at_time
Modify set_node_base_demand, set_pattern, add_pattern, set_pipe_diameter, set_pipe_roughness, set_pipe_status, set_pipe_length, set_pump_status, set_pump_speed, set_pump_head_curve, set_valve_setting, set_valve_status, set_tank_parameters, set_reservoir_head, set_simulation_duration, set_hydraulic_timestep, set_quality_timestep, set_quality_type, add_control, delete_control, save_network
Scenarios create_demand_perturbation, create_leakage_event, create_contamination_event, create_pressure_change_scenario, create_pump_control_scenario, create_valve_control_scenario, create_multi_failure_scenario

Requirements

  • Python ≥ 3.10
  • ePyT ≥ 2.0
  • mcp ≥ 1.0
pip install epyt mcp

Installation

git clone https://github.com/Applied-Artificial-Intelligence-Eurecat/epanet-mcp-server.git
cd epanet-mcp-server
pip install -e .

Running the server

stdio (for Claude Desktop / Claude Code)

epanet-mcp-server
# or
python -m epanet_mcp.server

SSE / HTTP

epanet-mcp-server --transport sse --port 8000

Claude Desktop configuration

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or the equivalent on your platform:

{
  "mcpServers": {
    "epanet": {
      "command": "epanet-mcp-server",
      "args": []
    }
  }
}

If not on PATH:

{
  "mcpServers": {
    "epanet": {
      "command": "python",
      "args": ["-m", "epanet_mcp.server"],
      "cwd": "/path/to/epanet-mcp-server/src"
    }
  }
}

Claude Code (.mcp.json)

Place this in the root of your project or ~/.claude/:

{
  "mcpServers": {
    "epanet": {
      "command": "epanet-mcp-server",
      "args": []
    }
  }
}

Example interactions

Once the server is connected, you can ask things like:

"Load Net1.inp and show me a summary of the network."

"Run a hydraulic simulation and tell me which node has the lowest pressure at hour 12."

"Double the base demand at junction 11 and re-run the simulation. How does pressure change?"

"Simulate a burst on pipe 10 with a 20% leakage fraction."

"Inject 10 mg/L of chlorine at node 11 between hours 1 and 3 and show me the contamination spread."

"What happens to pressures if the reservoir head drops from 150 m to 120 m?"

"Schedule Pump 9 to start at 06:00 and stop at 22:00."

"Close pipes 10 and 11 and the pump simultaneously. Where are service disruptions?"


Architecture

src/epanet_mcp/
├── server.py          # FastMCP server – tool registration + entry point
├── session.py         # Thread-safe registry of open ePyT sessions
├── utils.py           # numpy → Python serialisation helpers
└── tools/
    ├── inspection.py  # load / inspect network models
    ├── simulation.py  # run hydraulic & quality simulations
    ├── modification.py# in-memory parameter changes
    └── scenarios.py   # what-if scenario generators (clone + modify + run)

Session model: Each loaded network lives in a named session. Scenario tools automatically clone the source session into a new independent session so the baseline network is never mutated.


Running the tests

pip install pytest
pytest tests/ -v

Bundled networks

ePyT ships with many standard benchmark networks including Net1, Net2, L-TOWN, Hanoi, Anytown, Balerma and others. Use list_bundled_networks to discover them all.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epanet_mcp_server-0.1.1.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

epanet_mcp_server-0.1.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file epanet_mcp_server-0.1.1.tar.gz.

File metadata

  • Download URL: epanet_mcp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for epanet_mcp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7b9550c6703d5ee7015c8807a5a2ae74e3ae618521e5c2c330ca3f7ef8d16918
MD5 c987192f9cf4c1665542c2356e3f68e1
BLAKE2b-256 7e80e45b9cd098391b307613e45546a9b8304b7c81f42c29a3974e7b2612c01a

See more details on using hashes here.

File details

Details for the file epanet_mcp_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for epanet_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c0f941577e7f1fe582fb4928636e15e399fee27ea83192ecbd85a9650304414
MD5 fcecd42c8d71dc969b3acc4c8c884918
BLAKE2b-256 520f844b1e92a8fa9c1d1239852a0dabc2793b72a7828d1385c58c94c7250d0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page