Skip to main content
Glama

Agentic HEC-RAS

A headless, natural-language-driven, automated modelling workflow for HEC-RAS. Skills + an MCP server for Claude Code, Codex, Hermes, or OpenClaw: describe a goal in plain language and the agent inspects, edits, runs, reads, compares and plots a HEC-RAS model — 1D, 2D or 1D/2D — without ever opening the GUI.

Experimental / pre-release. One MCP server (10 tools) + 5 skills, a thin layer over ras-commander (MIT) and h5py. Verified end to end on HEC's official Muncie 2D example with HEC-RAS 7.0.1. Sibling of agentic-swmm-workflow (urban drainage) and Agentic-MIKE-Plus (MIKE+): together they cover sewer network → river / 2D flood hydraulics under one agentic pattern.

Install: just tell your agent

Paste this to your AI coding agent (Claude Code, Codex, Hermes, OpenClaw):

Install "Agentic HEC-RAS" for me: an MCP server + skills to drive HEC-RAS headless.

1. Clone https://github.com/Zhonghao1995/Agentic-HEC-RAS and skim its README.
2. With Python 3.10+:
     python -m venv .venv
     .venv\Scripts\python.exe -m pip install -e .
3. Register with me (Claude Code):
     claude mcp add hec-ras -- "<abs-repo>\.venv\Scripts\python.exe" -m hecras_mcp.server
   (Codex / Hermes / OpenClaw: copy config/mcp.sample.json)
4. Copy skills/* into ~/.claude/skills/, then run scripts/smoke_test.py (should list 10 tools).
5. Tell me which tools need HEC-RAS installed (only ras_run does) and where Ras.exe was found
   (set HECRAS_EXE if it was not).

Two install profiles:

  • Read / compare / plot / edit files. Cross-platform, no HEC-RAS: pip install -e . — everything except ras_run works on any machine that has the .p##.hdf results (or the project text files).

  • Run too. Windows + HEC-RAS 6.x / 7.0.1 installed (free download, no license). Ras.exe is auto-detected in the default install folder, or set HECRAS_EXE.

Related MCP server: ras-commander-mcp

Why it matters

  • Natural-language-driven. "Run the 2D plan with 20 % more inflow and tell me how much the downstream stage rises" — the agent copies the project, edits the .u##, runs Ras.exe -c, reads the HDF, compares, plots, and writes a manifest.

  • Fully headless. No GUI, no COM controller: HEC-RAS's own command line (Ras.exe -c project.prj plan.p##) inside a copied project folder.

  • MCP-native and portable. One server speaks the Model Context Protocol; works with Claude Code, Codex, Hermes or OpenClaw via a single config line.

  • HEC-RAS optional for reading. Results (.p##.hdf), comparison and figures need only Python — teammates without HEC-RAS can still analyse.

  • Verification-first. ras_run returns a QA status (max WSEL error, volume error %, ERROR / WARNING lines) the skills must gate on; every case ends with a sha256 manifest.

  • Small and testable. Pure-Python contracts (boundary-table rewriting, QA classification, comparison, manifest) with a HEC-RAS-free unit-test suite in CI; add a tool or skill by dropping in a file.

How it works

Skills (markdown playbooks) tell the agent when and how; the agent calls MCP tools; the tools call ras-commander (project parsing, .p## edits, Ras.exe -c) and h5py (results). The server never imports HEC-RAS itself, so it starts anywhere.

agent  ->  reads skills/ras-*/SKILL.md  ->  calls MCP tools  ->  ras-commander / h5py  ->  Ras.exe -c  /  .p##.hdf

Tools (one server, hec-ras)

Tool

Does

HEC-RAS

ras_project_info

plans (title, g##/u##, sim window, intervals, cores, results present?), geometries, flow files, boundary conditions (river/reach/RS or 2D BC line, kind, interval, n, peak)

no

ras_project_copy

copy the whole project folder (terrain / DSS refs stay valid) before any edit or run

no

ras_plan_set

simulation window, computation / output / mapping interval, cores, short id, title, description, geometry, flow file

no

ras_flow_set_hydrograph

replace or scale one boundary table (flow / stage / lateral / precipitation / gate), set QMult, change interval

no

ras_run

Ras.exe -c headless run + QA: status, max WSEL error, volume error %, log tail, runtime, HDF path

yes

ras_results_summary

run QA, volume accounting, cross-section peaks, 2D wet cells / max depth, reference lines, units

no

ras_results_timeseries

one series (cross section, reference line / point, boundary, 2D cell) with peak and timing

no

ras_results_compare

baseline vs scenario: delta peak / timing / RMSE / NSE / volume, or every cross section ranked by change

no

ras_plot

hydrograph overlay, max-WSE profile, 2D max-depth map (PNG)

no

ras_manifest_write

provenance manifest: project, plan, inputs, results, figures with sha256, run QA, edits, tool calls

no

Five skills orchestrate them: ras-end-to-end (the SOP: modes, run directory, hard rules, stop rules, QA gates), ras-model, ras-runner, ras-results, ras-audit.

Install the skills into any skills-aware agent (Claude Code, Codex, OpenCode, …) in one command, no clone needed:

npx skills add Zhonghao1995/Agentic-HEC-RAS      # all 5; add --list to preview, or --skill <name> for one

Demo: Muncie (official 2D example, HEC-RAS 7.0.1)

Baseline vs +20 % upstream inflow, entirely through the tools (scripts/e2e_muncie.py): two 24-hour 1D/2D runs of ~65 s each on 4 cores, downstream peak flow 21,000 → 25,200 cfs (+20.0 %), downstream max stage 938.7 → 940.7 ft (+2.0 ft), 2D area 4,905 → 4,997 wet cells, max depth 20.3 → 20.4 ft.

Full evidence (commands, tool returns, and the honest scope boundary) is in docs/verification.md.

Scope (v0.1) and honest boundaries

  • Operates on existing HEC-RAS projects: inspect, edit boundaries / plan settings, run, read, compare, plot, audit.

  • Building a new model (terrain, 2D mesh, cross sections, infiltration layers, structures) still needs RAS Mapper / the GUI.

  • Runs need Windows + HEC-RAS. HEC-RAS 7.0.1 ships Linux compute engines (RasUnsteady, run via WSL) but they need Windows-side preprocessing; they are not wired into ras_run yet.

  • HEC-RAS may show its Terms and Conditions for Use form on headless launches; ras_run accepts it for you (accept_tcu, default true — read the terms at hec.usace.army.mil/software/hec-ras) and kills runs after timeout_s.

  • Gridded (DSS) precipitation and steady-flow (.f##) profiles are read but not edited.

Development

pip install -e ".[dev]"
pytest                          # ~3 s, no HEC-RAS needed
python scripts/smoke_test.py    # tool discovery + real stdio MCP round-trip
python scripts/call_tool.py --list
python scripts/call_tool.py ras_results_summary "{\"hdf\": \"C:/models/Muncie/Muncie.p03.hdf\"}"

The tests pin the .u## boundary-table writer (fixed-width, touching fields, count line, CRLF), the QA classifier, the comparison metrics, the manifest, tool discovery and the server's failure shape. Add a tool or skill by dropping a file under hecras_mcp/tools/ or skills/ (auto-discovered), and ship a test with it.

License

MIT © 2026 Zhonghao Zhang, University of Victoria. Built on ras-commander (MIT), h5py, pandas, matplotlib and the Model Context Protocol. HEC-RAS is developed and distributed free of charge by the U.S. Army Corps of Engineers Hydrologic Engineering Center; it is not open source and is not redistributed here.

Available Tools

10 tools
ras_flow_set_hydrographA

Edit ONE boundary condition table in an unsteady flow file (.u##): replace the hydrograph 'values' (any length; count line rewritten), or scale the existing values by 'multiplier', or set the HEC-RAS flow multiplier 'qmult' (Flow Hydrograph QMult, applied at run time), and/or change the 'interval' ('1HOUR','15MIN'). Select the boundary by boundary_index (from ras_project_info plan detail) or river/reach/rs, or area/bc_line for 2D BC lines. Works for Flow, Stage, Lateral Inflow, Uniform Lateral Inflow, Precipitation hydrographs and Gate Openings. Edit a COPY of the project. Returns the boundary before/after summary (n, peak).

Inputs: project (required), rs, area, flow, +11 more.

ras_manifest_writeA

Write a provenance manifest (JSON) for one modelling step: the project .prj + input + result (.p##.hdf) + figure files each with a sha256, the ras_run QA status, the edits made (ras_plan_set / ras_flow_set_hydrograph returns), the tool calls, and free notes. Call it at the end of a run so the run can be audited or re-compared later. Reports any referenced file that is missing. No HEC-RAS needed.

Inputs: out_json (required), run, case, plan, +7 more.

ras_plan_setA

Change settings of one plan (.p##) in place: simulation window, computation / output / mapping interval, number of cores, short id, title, description, and which geometry (g##) or unsteady flow file (u##) the plan uses. Returns before/after values. Edit a COPY of the project (ras_project_copy) — this rewrites the plan file. Intervals use HEC-RAS strings ('10SEC','1MIN','15MIN','1HOUR'); dates accept '02JAN1900 0000' or ISO '1900-01-02T00:00'.

Inputs: plan (required), project (required), flow, geom, +10 more.

ras_plotA

Make a PNG figure from results HDF(s). plot='hydrograph': one time series (kind/location/variable/mesh as in ras_results_timeseries) for 1-4 runs overlaid (hdfs + labels), peaks annotated. plot='profile': maximum water surface (or flow / velocity) along the river stations of a reach ('reach'='River/Reach', default all) for 1-4 runs. plot='mesh_max': map of the 2D cells coloured by maximum water surface (single hdf, optional 'mesh'). Returns the PNG path.

Inputs: out_png (required), hdf, hdfs, kind, +7 more.

ras_project_copyA

Copy a whole HEC-RAS project folder to a new folder (all .prj/.g##/.p##/.u##/.f##/terrain/DSS files, relative references stay valid). Use it BEFORE editing or running so the original model is never modified. Results HDFs and logs are excluded unless include_results=true.

Inputs: dest (required), project (required), overwrite, include_results.

ras_project_infoA

Inspect a HEC-RAS project: plans (title, geometry, flow file, simulation window, intervals, cores, whether a results .p##.hdf exists), geometries, unsteady/steady flow files with their boundary conditions, current plan, and which Ras.exe would be used. Pass 'plan' to also get that plan's boundary conditions in detail (river/reach/RS or 2D area/BC line, kind, interval, n values, peak; include_values=true for the full hydrograph). No HEC-RAS install needed.

Inputs: project (required), plan, ras_exe, include_values.

ras_results_compareA

Compare two runs (baseline HDF vs scenario HDF) at one location: delta peak (value and %), peak timing shift, RMSE, NSE, and for flows the delta volume; time bases are aligned ('exact' or 'interpolated'). kind/location/variable/mesh as in ras_results_timeseries. For kind 'xsec' with NO location, ranks every shared cross section by change of peak (n increased / decreased / unchanged, top-N) and details the largest change.

Inputs: hdf_a (required), hdf_b (required), kind, mesh, +5 more.

ras_results_summaryA

One-screen summary of a HEC-RAS results HDF (.p##.hdf): plan info, run QA status, unsteady summary (max WSEL error, solution text), volume accounting (error %), runtime, cross sections (count, reaches, upstream/downstream, top-N by max flow with max WSE / velocity and time), 2D mesh areas (cells, max WSE stats + where/when), reference lines / points and boundary conditions with their peaks. Units follow the project (US customary or SI). No HEC-RAS needed.

Inputs: hdf (required), top_n.

ras_results_timeseriesA

One time series from a results HDF with peak / time of peak / min / mean, downsampled to at most max_points. kind: 'xsec' (location 'River/Reach/Station' or just the station; variable flow | water_surface | velocity | velocity_channel | flow_lateral), 'ref_line' / 'ref_point' / 'boundary' (location = name; variable e.g. 'Flow' or 'Water Surface'), 'mesh_cell' (mesh = 2D area name, location = cell id, variable 'Water Surface'). Omit location to get the first one.

Inputs: hdf (required), kind, mesh, location, +2 more.

ras_runA

Run one HEC-RAS plan headless (Ras.exe -c project.prj plan.p##; geometry preprocessing, unsteady/steady computation and post-processing) and QA the result. If run_dir is given the whole project is first copied there and run inside it (safe); otherwise the plan runs in place (use on a copy!). Blocks until the run finishes. Returns status ('completed', 'completed_with_warnings', 'unstable', 'failed', 'no_results'), usable (bool), reasons, metrics (max WSEL error, volume error %, ERROR/WARNING line counts), the results HDF path, runtime and the log tail. Gate on 'status'/'usable', not on 'ok'. A watchdog accepts HEC-RAS's 'Terms and Conditions for Use' dialog if it appears (accept_tcu, default true) and kills the run after timeout_s (default 4 h). Needs HEC-RAS installed (Windows).

Inputs: plan (required), project (required), ras_exe, run_dir, +5 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: inspecting, copying, editing plan settings, editing boundary conditions, running, summarizing results, extracting timeseries, comparing results, plotting, and writing manifests. No two tools could be confused for one another.

    Naming Consistency4/5

    All tools share the 'ras_' prefix, and most follow a noun_verb pattern (e.g., project_info, results_compare). Minor deviations like 'ras_plot' and 'ras_run' being verb-only are acceptable, and the naming is generally predictable.

    Tool Count5/5

    With 10 tools, the server is well-scoped for a HEC-RAS modeling workflow. Each tool addresses a necessary step in the pipeline without redundancy or bloat.

    Completeness5/5

    The tool set covers the full lifecycle: project inspection, copying, editing plans and flow hydrographs, running simulations, extracting and summarizing results, comparing scenarios, plotting, and recording provenance. No critical gaps are apparent for the stated domain.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      An MCP server that provides a toolbox for interacting with EPA SWMM stormwater models, enabling users to analyze model data and interpret results through LLM-driven tools. It assists stormwater modelers in understanding hydraulic systems and modeling behavior using natural language interfaces.
      18
      8
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables querying HEC-RAS project information, geometry elements, plan results, and compute messages through natural language, allowing interaction with hydraulic modeling projects.
      36 PyPI
      18
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      MCP server that exposes Siemens Simcenter Amesim's Circuit API as tools, enabling circuit creation, wiring, parameter setting, simulation, and result retrieval via natural language.
      17
      -