QSDsan Engine MCP
Click on "Install 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., "@QSDsan Engine MCPBuild an MLE process with 4000 m3/d influent, simulate for 15 days"
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.
QSDsan Engine MCP
A universal wastewater treatment simulation engine exposing QSDsan capabilities through dual adapters for AI agent integration.
Motivation
Commercial wastewater simulation platforms offer sophisticated biological models but impose a significant bottleneck: GUI-driven workflows that limit iteration speed, parallelization, and reproducibility. Process engineers spend substantial time navigating interfaces rather than exploring designs.
QSDsan Engine MCP inverts this paradigm by making natural language the primary interface. Instead of clicking through dialogs, engineers describe what they want:
"Build an MLE process with 4000 m3/d influent, simulate for 15 days, and explain why ammonia removal is low"
This enables:
Collapsed iteration cycles: Build -> run -> diagnose -> patch -> rerun without GUI navigation
Massive scenario enumeration: DOE, Monte Carlo, and optimization workflows become natural since everything is code
Reproducible, diffable runs: Version-controlled session specs with deterministic metadata
Structured diagnostics: Validation warnings, model compatibility checks, and actionable error messages surfaced directly to agents
The goal is not to replace domain expertise, but to remove friction so engineers can focus on design decisions rather than tool mechanics.
Related MCP server: SWMM-MCP
Architecture: Dual Adapters
The engine exposes identical functionality through two adapters:
+-------------------------------------+
| QSDsan Engine Core |
| (Templates, Models, Converters) |
+-----------------+-------------------+
|
+-----------------------+---------------------+
| | |
v v v
+----------------+ +----------------+ +----------------+
| MCP Adapter | | CLI Adapter | | Python API |
| (server.py) | | (cli.py) | | (direct use) |
+----------------+ +----------------+ +----------------+
| |
v v
+----------------+ +----------------+
| MCP Clients | | Agent Skills |
| (Claude, etc) | | (Claude Code) |
+----------------+ +----------------+MCP Adapter (server.py)
For MCP-compatible clients (Claude Desktop, Cline, etc.):
python server.pyCLI Adapter (cli.py)
For CLI-based agent runtimes and Agent Skills:
python cli.py --helpTool Surface
Core Simulation Tools
Tool | MCP | CLI | Description |
|
|
| List available treatment templates |
|
|
| Validate influent state against model |
|
|
| Run template-based simulation |
|
|
| Convert between ASM2d and mADM1 |
Flowsheet Construction Tools
Build custom treatment trains dynamically:
Tool | MCP | CLI | Description |
|
|
| Create new flowsheet session |
|
|
| Add influent/recycle stream |
|
|
| Add unit operation |
|
|
| Wire units together |
|
|
| Compile to QSDsan System |
|
|
| Run simulation |
|
|
| List available unit types |
Session Management Tools
Modify flowsheets without starting over:
Tool | MCP | CLI | Description |
|
|
| Modify stream properties |
|
|
| Modify unit parameters |
|
|
| Remove stream |
|
|
| Remove unit and connections |
|
|
| Remove specific connection |
|
|
| Fork session for experimentation |
Discoverability Tools
Explore models and validate configurations before simulation:
Tool | MCP | CLI | Description |
|
|
| Get component IDs and metadata |
|
|
| Pre-compilation validation |
|
|
| Detect potential recycle streams |
Artifact Retrieval Tools
Access simulation outputs programmatically:
Tool | MCP | CLI | Description |
|
|
| Get diagram/report content |
|
|
| Get time-series trajectories |
Supported Models
Model | Components | Use Case |
ASM1 | 13 | Activated sludge (basic nitrification/denitrification) |
ASM2d | 19 | Activated sludge with biological phosphorus removal |
mADM1 | 63 | Anaerobic digestion with sulfur-reducing bacteria |
Pre-built Templates
Template | Model | Description |
| mADM1 | Anaerobic CSTR digester |
| ASM2d | MLE process with MBR |
| ASM2d | A/O process with MBR |
| ASM2d | A2O process with EBPR and MBR |
Advanced Simulation Features
SRT-Controlled Simulation (Phase 12)
For systems with MBR or clarifier that decouple HRT and SRT, the engine supports target SRT setpoints where sludge wasting is automatically controlled to achieve the desired SRT:
# CLI: Run MLE-MBR with target SRT of 15 days
python cli.py simulate \
--template mle_mbr_asm2d \
--influent influent.json \
--target-srt 15 \
--srt-tolerance 0.1How it works:
Uses
scipy.brentqroot-finding to find optimal Q_was (waste activated sludge flow)Enforces minimum simulation time of 2× target SRT for dynamics equilibration
Validates mass balance: Q_was ≤ Q_in (since Q_in = Q_was + Q_effluent)
Achieves target SRT within specified tolerance (e.g., 0.1 = 10%)
Test results: Target SRT 5.0 days → Achieved SRT 5.01 days (0.23% error)
Run-to-Convergence Simulation
For accurate steady-state simulation, use convergence-based stopping:
# CLI: Run until steady state (auto-detected)
python cli.py flowsheet simulate \
--session my_plant \
--run-to-convergence \
--convergence-atol 0.1 \
--max-duration 100Features:
Abs+rel tolerance:
|slope| < atol + rtol × max(|mean|, floor)Multi-stream tracking: effluent (nutrients) + WAS (biomass)
Auto-detection of effluent and sludge streams
Oscillation detection for non-converged systems
Quick Start
Using CLI
# List templates
python cli.py templates --json-out
# Create influent file
cat > influent.json << 'EOF'
{
"flow_m3_d": 4000,
"temperature_K": 293.15,
"concentrations": {"S_F": 75, "S_A": 20, "S_NH4": 35, "S_PO4": 9}
}
EOF
# Run MLE-MBR simulation (use file path for --influent, --duration-days not --duration)
python cli.py simulate \
--template mle_mbr_asm2d \
--influent influent.json \
--duration-days 15 \
--report
# Build custom flowsheet
python cli.py flowsheet new --model ASM2d --id my_plant
python cli.py flowsheet add-stream --session my_plant --id influent \
--flow 4000 --concentrations '{"S_F": 75, "S_A": 20, "S_NH4": 35}'
python cli.py flowsheet add-unit --session my_plant --type CSTR --id anoxic \
--params '{"V_max": 1000}' --inputs '["influent"]'
python cli.py flowsheet add-unit --session my_plant --type CSTR --id aerobic \
--params '{"V_max": 2000, "aeration": 2.0}' --inputs '["anoxic-0"]'
python cli.py flowsheet build --session my_plant
python cli.py flowsheet simulate --session my_plant --duration 15Using MCP
Configure in your MCP client (e.g., Claude Desktop config.json):
{
"mcpServers": {
"qsdsan-engine": {
"command": "python",
"args": ["/path/to/qsdsan-engine-mcp/server.py"]
}
}
}Then use natural language:
"Create an MLE process treating 4000 m3/d of municipal wastewater and simulate for 15 days"
Unit Registry
49 unit operations available across categories:
Reactors: CSTR, AnaerobicCSTR, PFR, ActivatedSludgeProcess, AnaerobicDigestion
Separators: CompletelyMixedMBR, AnMBR, PolishingFilter, MembraneDistillation
Clarifiers: FlatBottomCircularClarifier, PrimaryClarifier, IdealClarifier
Sludge: Thickener, Centrifuge, SludgeDigester, DryingBed
Junctions: ASM2dtoADM1, ADM1toASM2d, mADM1toASM2d (model converters)
Utilities: Splitter, Mixer, Tank, StorageTank, DynamicInfluent
# List all units
python cli.py flowsheet units --json-out
# Filter by model compatibility
python cli.py flowsheet units --model mADM1
# Filter by category
python cli.py flowsheet units --category reactorPipe Notation
Connect units using BioSTEAM pipe notation:
# Output notation: "A1-0" -> unit A1, output port 0
# Input notation: "1-M1" -> unit M1, input port 1
# Direct: "U1-U2" -> U1.outs[0] -> U2.ins[0]
# Explicit: "U1-0-1-U2" -> U1.outs[0] -> U2.ins[1]Output
Simulations produce:
JSON results with effluent quality, removal efficiencies, and deterministic metadata (solver settings, library versions, timestamps)
SVG flowsheet diagrams showing unit operations and streams
Quarto reports (optional) with comprehensive analysis
Time-series data for tracked streams
Installation
# Clone repository
git clone https://github.com/puran-water/qsdsan-engine-mcp.git
cd qsdsan-engine-mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
# Install dependencies (either method works)
pip install -r requirements.txt
# OR
pip install -e .Dependencies
Python packages (installed automatically):
Python 3.10+
QSDsan 1.3+
BioSTEAM 2.40+
FastMCP (for MCP adapter)
Typer + Rich (for CLI adapter)
Jinja2 (for report generation)
Matplotlib (for time-series plots)
External tools (install separately):
Graphviz: Required for flowsheet diagrams
Linux:
sudo apt install graphvizmacOS:
brew install graphvizWindows: https://graphviz.org/download/
Quarto CLI (optional): For rendering
.qmdreports to HTML/PDF
License
University of Illinois/NCSA Open Source License - see LICENSE.txt for details.
This is a derivative work based on QSDsan, licensed under the same terms.
Acknowledgments
Built on QSDsan by the Quantitative Sustainable Design Group.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/puran-water/qsdsan-engine-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server