MCP server for querying HEC-RAS project information
Project description
HEC-RAS MCP Server
The RAS Commander MCP (Model Context Protocol) server provides tools for querying HEC-RAS project information using the ras-commander library. This allows Claude Desktop to interact with HEC-RAS hydraulic modeling projects.
Key Features
- Stateful Context: Initialize a project once, then query it multiple times without repeating the project path
- Comprehensive Project Summary: Get all project info including plans, geometries, flows, and projection data
- Flexible Plan Queries: Get all plans or specific plan details
- Infiltration Analysis: Extract and analyze soil infiltration data
- Results Summary: Access unsteady flow results, volume accounting, and runtime statistics
- Smart Path Handling: Automatic HDF file detection for projection info
- Error Handling: Helpful diagnostics for common issues
Prerequisites
- HEC-RAS Installation: HEC-RAS must be installed on your system (default expects version 6.6)
- Python: Python 3.8+ with Anaconda recommended
- Claude Desktop: For MCP integration
Installation
For Claude Desktop Users (Recommended)
-
Install uv (one-time setup):
- Windows:
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
- macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Windows:
-
Configure Claude Desktop: Add the following to your Claude Desktop configuration file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:~/.config/Claude/claude_desktop_config.json{ "mcpServers": { "hecras": { "command": "uvx", "args": ["ras-commander-mcp"], "env": { "HECRAS_VERSION": "6.6" } } } }
-
Restart Claude Desktop
That's it! The MCP server will be automatically downloaded and run when needed.
For Developers
To install for development:
# Clone the repository
git clone <repository-url>
cd ras-commander-mcp
# Install in development mode with uv
uv pip install -e .
# Or with standard pip
pip install -e .
Legacy Installation (Alternative)
If you prefer the traditional approach:
- Clone this repository:
git clone <repository-url>
cd ras-commander-mcp
- Install dependencies using the Anaconda environment:
# Create and activate conda environment
conda create -n hecras-mcp python=3.9
conda activate hecras-mcp
pip install -r requirements.txt
Configuration
Configuration Options
You can configure the server through environment variables in the Claude Desktop config:
{
"mcpServers": {
"hecras": {
"command": "uvx",
"args": ["ras-commander-mcp"],
"env": {
"HECRAS_VERSION": "6.5", // HEC-RAS version (default: 6.6)
"HECRAS_PATH": "C:\\Custom\\Path\\To\\HEC-RAS.exe" // Custom HEC-RAS path
}
}
}
}
Legacy Configuration (for manual installation)
If you're using the legacy installation method:
{
"mcpServers": {
"hecras": {
"command": "python",
"args": ["path/to/your/ras-commander-mcp/server.py"],
"env": {
"HECRAS_VERSION": "6.5"
}
}
}
}
Troubleshooting
If you encounter issues:
- Verify uv installation: Run
uv --versionin a terminal - Check HEC-RAS installation: Ensure HEC-RAS is installed in the default location or set
HECRAS_PATH - Test the server: Run
uvx ras-commander-mcpin a terminal to see any error messages - Clear uv cache: If you have issues with updates, run
uv cache clean
Available Tools
1. get_ras_projectsummary
Get comprehensive project information including plans, geometries, flows, boundaries, and projection info. This tool initializes the project context for subsequent calls.
Parameters:
project_path(optional): Full path to HEC-RAS project folderinclude_boundaries(optional): Include boundary conditions data (default: false)
2. get_ras_planinfo
Get plan information from the project. Can return all plans or a specific plan.
Parameters:
project_path(optional): Full path to HEC-RAS project folderplan_number(optional): Specific plan number (e.g., "01", "02")
3. get_ras_infiltration
Get infiltration layer data and soil statistics from the project.
Parameters:
project_path(optional): Full path to HEC-RAS project foldersignificant_threshold(optional): Minimum percentage threshold for significant mukeys (default: 1.0)
4. get_ras_resultssummary
Get comprehensive results from a specific plan including unsteady info, volume accounting, and runtime data.
Parameters:
plan_name(required): Name or number of the planproject_path(optional): Full path to HEC-RAS project folder
5. get_projection_info
Get spatial projection information (WKT string) from HDF files.
Parameters:
hdf_path(optional): Full path to HDF file (auto-detects if not provided)
6. get_1d_profile_results
Get maximum water surface elevation and velocity for 1D cross sections in a river/reach.
Parameters:
plan_name(required): Name or number of the planriver_name(optional): River name (if not specified, returns all rivers)reach_name(optional): Reach name (only used if river_name is specified)project_path(optional): Full path to HEC-RAS project folder
Returns: Formatted table with station, max WSEL, and max velocity for each cross section.
7. compare_1d_profiles
Compare maximum water surface elevations between two plans for 1D cross sections.
Parameters:
plan1_name(required): Name or number of the first plan (baseline)plan2_name(required): Name or number of the second plan (comparison)river_name(optional): River name (if not specified, returns all rivers)reach_name(optional): Reach name (only used if river_name is specified)project_path(optional): Full path to HEC-RAS project folder
Returns: Comparison table with differences and comprehensive statistics including stations unique to each plan.
8. plot_1d_profile
Plot 1D profile results showing water surface elevation vs station.
Parameters:
plan_name(required): Name or number of the plan to plotriver_name(optional): River name (if not specified, shows all rivers)reach_name(optional): Reach name (only used if river_name is specified)project_path(optional): Full path to HEC-RAS project folder
Returns: Embedded PNG plot as base64 image in markdown format.
9. plot_1d_profile_comparison
Plot comparison of 1D profiles between two plans.
Parameters:
plan1_name(required): Name or number of the first plan (baseline)plan2_name(required): Name or number of the second plan (comparison)river_name(optional): River name (if not specified, shows all rivers)reach_name(optional): Reach name (only used if river_name is specified)project_path(optional): Full path to HEC-RAS project folder
Returns: Embedded PNG comparison plot with thalweg data, annotations, and detailed statistics.
10. get_1d_xsec_timeseries
Get detailed time series results for a specific 1D cross section including water surface elevation, velocity, flow, and other hydraulic variables.
Parameters:
plan_name(required): Name or number of the planriver_name(required): River namereach_name(required): Reach namestation(required): River station (e.g., '27857.47')project_path(optional): Full path to HEC-RAS project folder
Returns: Time series data with summary statistics (max, min, mean, time of max) for each variable.
Usage Examples
In Claude Desktop
Once configured, you can ask Claude:
"Get the project summary for C:/Projects/MyRiverModel"
"Show me plan 04 details" (no path needed after initialization!)
"Get infiltration data with 5% threshold"
"Show results summary for plan 04"
"What's the projection info?"
Key Feature: Stateful Context
The server maintains project context between calls:
-
First call - Initialize with project path:
"Get project summary for C:/Projects/MyRiverModel" -
Subsequent calls - No path needed:
"Show me plan 02" "Get infiltration data" "Show results for plan 04" -
Switch projects - Just provide a new path:
"Get project summary for C:/Projects/AnotherModel"
Testing
Run the example client to test the server:
# Using the activated conda environment
python example_client.py
Or test directly without MCP protocol:
python test_server.py
Test Data
The testdata/Muncie/ folder contains a complete HEC-RAS project for testing, including:
- Multiple plan configurations
- HDF5 result files
- Terrain and infiltration data
- Geometry files
- Boundary conditions
Troubleshooting
- ImportError for ras-commander: Ensure ras-commander is installed and HEC-RAS is properly installed
- Project not found: Verify the project path exists and contains .prj files
- Version errors: Check that the specified HEC-RAS version matches your installation
- No context available: Make sure to initialize a project first with
get_ras_projectsummary
Development
To modify or extend the server:
- Edit
server.pyto add new tools or modify existing ones - Test changes with
test_server.py(direct testing) - Test MCP integration with
example_client.py - Update Claude Desktop configuration if needed
What's New in v0.3.0
- Enhanced 1D Profile Comparison: Properly handles mismatched stations between plans
- Improved Statistics: Separate statistics for matching vs non-matching stations
- Better Plotting: Enhanced plots with thalweg data, annotations, and visual markers
- New Tool:
get_1d_xsec_timeseriesfor detailed cross-section time series analysis - Outer Join Logic: Shows stations that exist in only one plan during comparisons
- Thalweg Integration: Automatic thalweg plotting from geometry data where available
- Enhanced Annotations: Plot annotations show maximum differences and locations
- Better Error Handling: More robust data extraction and error reporting
What's New in v0.2.0
- Stateful Context: Project persistence between tool calls
- Improved Tool Names: More consistent
get_ras_*naming convention - Consolidated Tools: Geometry info now included in project summary
- Smart Defaults: Auto-detection of HDF files for projection info
- Enhanced Plan Queries: Support for querying by plan number
- Better Error Messages: More helpful context-aware error handling
License
This project is licensed under the MIT License - see the LICENSE file for details.
Trademarks
See TRADEMARKS.md for trademark information and compliance policies.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ras_commander_mcp-0.3.0.tar.gz.
File metadata
- Download URL: ras_commander_mcp-0.3.0.tar.gz
- Upload date:
- Size: 109.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fafdd878a4d26cfc249bbc13f85706ff5108b156b79cc1316f3edd2dfdbefd63
|
|
| MD5 |
64a8b4d565e517dece3fa9d1e74018be
|
|
| BLAKE2b-256 |
ebd36e5f0ead3f3af26aac20d31b0081fc755c0b92ba0fa4539c30481f5bee5e
|
File details
Details for the file ras_commander_mcp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: ras_commander_mcp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fd8a58fa6c1c8324279096a8f841e82898a01faa881c89e1024c1fc4eee683d
|
|
| MD5 |
339939c8c848754d8cb71f5295b5d158
|
|
| BLAKE2b-256 |
cbe7237694e48e5991fe1b2102a5a57f55fe971b391928399cf761247d66595b
|