dualsphysics-mcp
This server lets an AI agent design, run, post-process, and validate DualSPHysics SPH simulations end-to-end without hand-writing XML or using a GUI.
Inspect the local DualSPHysics toolchain (GenCase, solver, PartVTK, MeasureTool) and get install hints if tools are missing.
Create and edit 2D dam-break case definitions from plain parameters, and get particle-count estimates.
Read back case summaries (domain, timing, gauges, particle counts).
Run GenCase to discretise cases into solver-ready XML + binary files and preview VTK.
Launch background CPU solver jobs, returning a job ID immediately.
Poll job progress with simulated time, percent, throughput, ETA, and Run.out tail.
Convert solver output to ParaView-ready VTK particle files with filters and variable selection.
Probe solutions at custom points to generate CSV time series with forced comma separators.
Validate 2D dam-break results against the Koshizuka & Oka (1996) experiment with per-time errors, MAE/RMSE/max, and wall-impact detection.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@dualsphysics-mcp Run a dam-break validation and show the error metrics"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
DualSPHysics MCP
Language: English | 中文
Design, run, and verify DualSPHysics simulations from an AI agent — not just stare at them.
Ten Model Context Protocol tools wrap a local DualSPHysics SPH toolchain end to end: design cases as structured parameters (no hand-written XML, no solver needed to iterate), run them as background CPU jobs with progress, throughput and the solver's own ETA on tap, post-process into ParaView-ready VTK and CSV time series, and verify a 2D dam-break against the Koshizuka & Oka (1996) experiment with per-time errors and MAE / RMSE / max.
The server only launches the DualSPHysics command-line tools as subprocesses; DualSPHysics itself is not distributed here — it is free LGPL-2.1-or-later software, this package neither links nor redistributes its code or binaries, so the MIT licence carries no extra obligations. If you publish work using DualSPHysics, cite Dominguez et al. (2022), Computational Particle Mechanics 9:867–895, doi:10.1007/s40571-021-00404-2.
Tools
Tool | What it does |
| Find the four DualSPHysics tools on this machine: resolved path, provenance (env var, PATH, scan), version, solver feature flags; install hints when one is missing. |
| Describe a 2D dam-break experiment in plain parameters and get a GenCase |
| Change parameters of an existing case (in place or to a |
| Read a case file back as a summary: dp, domain, column/tank/obstacle, timing, gauges, particle estimate. |
| Discretise the case into |
| Start the CPU solver in the background (jobs/ directory, |
| Poll a job: state, |
| Turn |
| Probe the solution at points and get CSV time series back (comma separator enforced for deterministic parsing). |
| Reconstruct the dam-tip surge front from the CSV and score it against the embedded Koshizuka & Oka (1996) series: per-time errors + MAE/RMSE/max. |
Working chain: check_environment → create_case → describe_case →
gencase → run_case → poll job_status → partvtk + measure_tool →
validate_dambreak. Vocabulary, three guards and particle-estimate
arithmetic: docs/case-generation.md.
Related MCP server: MCP-Server-for-CFD
Domain contracts
Behaviours of the wrapped tools that their -h output does not tell you:
Geometry outside the domain box is silently clipped by GenCase (exit 0, no warning) —
create_casecontainment-checks every domain.DualSPHysics CSVs default to semicolon separators;
measure_toolforces commas unless the caller passes their own-csvsep.MeasureTool points files reject leading
#comment lines; MeasureTool errors print on stdout, not stderr.Time/SecinRun.outis wall-clock seconds per simulated second — not steps/second; the row tail is the solver's projected finish.Run.outrow formats differ between solver v5.0/v5.2 and v5.4; the parser handles both.
All fourteen contracts (formats, exit codes): docs/domain-contracts.md.
Install
Python 3.10+. The binaries are discovered from DSPH_* environment
variables, PATH, or conventional install roots (/opt, /usr/local, ~/softwares, ~, cwd → <root>/DualSPHysics*/bin/linux).
uv sync # or: python -m venv .venv && .venv/bin/pip install -e .Getting the solver (the GitHub repository ships GenCase / PartVTK / MeasureTool prebuilt but not the solver):
Full package from https://dual.sphysics.org/downloads/, or
git clone https://github.com/DualSPHysics/DualSPHysicsand build the CPU solver withmake -f Makefile_cpu(g++ only, no CUDA needed), then copy the prebuilt tools frombin/linux/.
Configure through environment variables (no .env parsing; see .env.example
— the same paths appear in examples/mcp_config.example.json):
DSPH_GENCASE=/home/<user>/softwares/DualSPHysics/bin/linux/GenCase_linux64
DSPH_SOLVER=/home/<user>/softwares/DualSPHysics/bin/linux/DualSPHysics5.4CPU_linux64
DSPH_PARTVTK=/home/<user>/softwares/DualSPHysics/bin/linux/PartVTK_linux64
DSPH_MEASURETOOL=/home/<user>/softwares/DualSPHysics/bin/linux/MeasureTool_linux64
DSPH_JOBS_DIR=/abs/path/to/jobs # optional, default ./jobs
DSPH_OMP_THREADS=8 # optional, default all coresRun
.venv/bin/python mcp_server.py # hub-style entry point (stdio)
.venv/bin/dualsphysics-mcp # console script
uvx dualsphysics-mcp # published on PyPIClient registration templates: examples/mcp_config.example.json:
{ "mcpServers": { "dualsphysics-mcp": { "command": "uvx", "args": ["dualsphysics-mcp"] } } }claude mcp add dualsphysics-mcp -- /abs/repo/path/.venv/bin/python /abs/repo/path/mcp_server.pyExample: 2D dam-break validation (Koshizuka & Oka 1996)
examples/dambreak_val2d/ holds the showcase: the official validation layout
(dp = 0.01 m; 1 m × 2 m water column in a 4 m × 3 m tank; TimeMax = 2 s,
TimeOut = 0.01 s; Verlet / Wendland / artificial viscosity 0.02 / Fourtakas
DDT 0.1), regenerated by gen_dambreak_val2d.py (MIT), a surge-front
MeasureTool points file (401 points along z = 0.03 m), and the digitised
experiment.
Measured on this case (GenCase v5.4.354 / solver v5.4.355, 8 CPU threads, i5-10210U):
Quantity | Value |
Total particles | 21,001 (fluid 20,000 + bound 1,001) |
Part files | 201 ( |
Solver wall time (TimeMax = 2 s) | ≈ 14 min |
Dam-tip MAE vs experiment (0.09–0.75 s) | 0.220 m (22.0 % of the column); RMSE 0.240 m |
Dam-tip error, early collapse (t ≤ 0.2 s) | within ±0.01–0.16 m |
Wall impact | front pins at 3.98 m at t ≈ 0.67 s |

The residual is SPH physics, not a measurement artefact: the front extraction
tracks the solver's own SWL gauge (mean deviation 8 mm < 10 mm point spacing),
and the experiment ends at X/a ≈ 4.13 — beyond the 4 m tank — so the
comparison saturates after wall impact (validate_dambreak notes impact_time_s).
Agent transcript:
check_environment() # all four tools found
gencase("examples/dambreak_val2d/CaseDambreakVal2D_Def.xml")
-> particle_counts: total=21001 fluid=20000 bound=1001
run_case("<out>/CaseDambreakVal2D") # returns job_id
job_status(job_id) # poll until percent=100
partvtk(job_id=job_id) # 201 fluid VTK files
measure_tool(job_id=job_id, points_file="examples/dambreak_val2d/points_damtip.txt")
validate_dambreak(csv_path="<measure csv>", points_file="examples/dambreak_val2d/points_damtip.txt")validate_dambreak reports per-time errors plus MAE / RMSE / max in metres
and as % of the 1 m column. The figure comes from
examples/make_validation_figure.py; examples/render_dambreak.py turns the
same run's Part_*.vtk into an MP4 animation (dev dependencies).
Tests
uv run pytest -q # or: .venv/bin/python -m pytest
uv run ruff check .The suite is green without any solver installed (discovery, command
construction, log-fixture parsing, validation math, case generation, stdio
end-to-end). Tests marked solver exercise a real local toolchain and
auto-skip otherwise.
Contents
src/dualsphysics_mcp/— MCP server, tool discovery and config, error codes, the ten tools intools/.examples/— validation case,create_case_demo.py, figure + animation scripts, client template.tests/— pytest suite (solver tests auto-skip).
Repository rules
Committed: source, tests, examples, documentation, templates.
Not committed: DualSPHysics binaries or sources (LGPL work stays out), virtual environments,
.env, job outputs and generated results.Experiment values in
examples/dambreak_val2d/are digitised facts cited to Koshizuka & Oka (1996) as shipped with the DualSPHysics examples; the generated case XML and all code here are original MIT content — details in CONTRIBUTING.md.
Available Tools
7 toolscheck_environmentA
Probe the DualSPHysics toolchain: paths, versions, solver features.
Reports for GenCase / CPU solver / PartVTK / MeasureTool whether each binary was found (env var, PATH or conventional install dirs), its version, and the solver's feature flags (a build without WaveGen cannot run wave cases). Call this first; missing tools come with install hints.
Inputs: no named parameters. Returns: hint, ready, tools, missing, +4 more
gencaseA
Run GenCase: case XML -> Case.xml + Case.bi4 (+ preview VTK files).
Args: xml_path: Path to the *_Def.xml case definition (with or without .xml). output_dir: Output directory (default: _out next to the XML). out_name: Output case name (default: XML stem minus _Def). save_modes: GenCase -save value (default "all" = bi4 + preview VTKs). extra_args: Extra GenCase flags (e.g. ["-dp:0.02"]).
Inputs: xml_path (required), out_name, extra_args, output_dir, +1 more. Returns: command, out_bi4, out_xml, next_step, +7 more
job_statusA
Poll a background solver job: state + Run.out progress digest.
Returns the running state (plus pid/returncode), simulated time vs tmax, percent, step counters, the solver's Time/Sec throughput (wall-clock seconds per simulated second), the solver's own projected finish time, particle counts and the Run.out tail.
Inputs: job_id (required). Returns: eta, pid, tmax, state, +19 more
measure_toolA
MeasureTool: interpolate SPH values at points -> CSV time series.
For the dam-break validation use a horizontal line of points just above the bottom (examples/dambreak_val2d/points_damtip.txt) with density (default -vars:-all,rhop): points beyond the surge front read 0, so the furthest wet point is the front position that validate_dambreak compares against the experiment.
Args: job_id: Job whose data/ directory holds the Part_*.bi4 files. dirdata: Explicit particle data directory (alternative to job_id). points_file: MeasureTool points file (POINTS/POINTSLIST/POINTSENDLIST). pointsdef: Inline points definition, e.g. "ptels[x=0:0.01:4,z=0.03]". variables: Variables to interpolate (default density only). onlytype: Particle filter (default fluid only). savecsv: CSV output prefix (default measure/damtip inside the job). savevtk: Optional VTK prefix for the measuring points. extra_args: Extra MeasureTool flags (a -csvsep here overrides ours).
Inputs: job_id, dirdata, savecsv, savevtk, +5 more. Returns: command, csv_files, next_step, vtk_files, +6 more
partvtkA
PartVTK: convert Part_*.bi4 particle files to VTK for visualisation.
Args: job_id: Job whose data/ directory holds the Part_*.bi4 files. dirdata: Explicit particle data directory (alternative to job_id). savevtk: Output prefix (default particles/PartFluid inside the job). onlytype: Particle filter (default fluid only). variables: Variables to store, e.g. "+idp,+vel,+rhop,+press". first/last: Part index range. extra_args: Extra PartVTK flags.
Inputs: last, first, job_id, dirdata, +4 more. Returns: command, csv_files, next_step, vtk_files, +6 more
run_caseA
Start the CPU solver in the BACKGROUND and return a job_id.
The case must have been processed by gencase first (Case.xml + Case.bi4). Progress is tracked with job_status; outputs land in the job directory (Run.out, data/Part_*.bi4). Restart/cancel are not implemented; solver flags such as -partbegin: can be passed via extra_args.
Args: case_path: Processed case base (gencase out_xml, with/without .xml). dirout: Output directory (default: jobs/<job_id>). omp_threads: OpenMP threads (default: DSPH_OMP_THREADS or all cores). tmax: Override TimeMax (seconds of simulated time). tout: Override TimeOut (seconds between Part files). extra_args: Extra solver flags (e.g. ["-svres"]).
Inputs: case_path (required), tmax, tout, dirout, +2 more. Returns: pid, case, state, dirout, +13 more
validate_dambreakA
Validate a 2D dam-break run: dam-tip front vs Koshizuka & Oka (1996).
Reads the CSV produced by measure_tool with the SAME points definition (columns map to points by order), reconstructs the front position per output time (furthest point above the wetness threshold) and reports per-time errors plus MAE / RMSE / max error in metres and as % of the column length.
Args: csv_path: MeasureTool time-history CSV. points: Points [[x, y, z], ...] in CSV column order. points_file: The points file used for the measurement. threshold: Wetness threshold (500 kg/m^3 for rhop; ~0.05 for vel). column_length: Water column length a in metres (normalisation). experiment: Embedded experiment (koshizuka1996). max_time: Ignore simulated samples beyond this time (s).
Inputs: csv_path (required), points, max_time, threshold, +3 more. Returns: mae_m, notes, rmse_m, n_samples, +8 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct stage of the DualSPHysics workflow (environment check, case generation, execution, polling, conversion, measurement, validation). No overlap in purpose; even validate_dambreak and measure_tool are clearly separated (measure produces CSV, validate analyzes it).
Mostly consistent snake_case with verb_noun pattern (validate_dambreak, check_environment, run_case, measure_tool). Minor deviations: partvtk and gencase lack underscores, and job_status is noun_verb rather than verb_noun, but overall the pattern is predictable and readable.
Seven tools cover the entire simulation lifecycle for a focused domain (dam-break validation). The count is well-scoped and each tool clearly earns its place; no bloat or deficiency.
The core workflow is covered end-to-end: generate case, run solver, monitor status, measure quantities, validate against experiment, and visualize results. Minor gaps include lack of job restart/cancel and no handling of wave generation, but these are acknowledged limitations rather than missing essential steps for the stated dam-break use case.
Related MCP Connectors
Physics-based validation of simulation results: receipts with per-check verdicts, via MCP.
20 engineering MCP tools: 3D STL/G-code, ELF/WASM, Verilog/VCD, systemd/seccomp, PDF repair.
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Global CAD/BIM, industrial engineering (FEM, CFD) and property tools via one MCP endpoint.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAutomates Ansys Fluent simulation workflows, enabling environment checks, case execution, UDF management, and result export through MCP tools.7MIT
- FlicenseAqualityDmaintenanceProvides aerodynamic analysis tools through MCP, enabling geometry generation, meshing, CFD solving, and visualization for 2D airfoils.7-
- AlicenseNot gradedqualityAmaintenanceAutomates OpenFOAM CFD simulations via MCP, enabling AI agents to mesh, run, and post-process cases from natural language prompts without any API keys.MIT

Ansys CFX-MCPofficial
AlicenseAqualityBmaintenanceAn MCP server that enables AI assistants to interact with Ansys CFX through PyCFX, supporting natural-language-assisted CFX-Pre, CFX Solver, and CFD-Post workflows for setup, execution, and postprocessing.7848 PyPI5Apache 2.0