Anaerobic Design MCP Server
Enables anaerobic digester design from feedstock characterization to dynamic simulation using a complete mADM1 model with 63 components, including AI-powered state generation and thermodynamic pH solving.
README
Anaerobic Design MCP Server
⚠️ DEVELOPMENT STATUS: This project is under active development and is not yet production-ready. APIs, interfaces, and functionality may change without notice. Use at your own risk for evaluation and testing purposes only. Not recommended for production deployments.
MCP (Model Context Protocol) server for anaerobic digester design using the complete mADM1 (Modified ADM1) process model with 63 components (62 state variables + H2O).
Overview
This server provides an end-to-end workflow for designing anaerobic digesters treating high-strength wastewater, from feedstock characterization through dynamic simulation. It leverages QSDsan's mADM1 model with phosphorus/sulfur/iron extensions for nutrient recovery and biogas production modeling.
Status: In Development (Active)
Key Features
Core Process Model
-
Complete mADM1 Model (63 Components): Full Modified ADM1 with P/S/Fe extensions
- 27 core ADM1 components (sugars, amino acids, VFAs, biomass)
- 3 EBPR components (X_PHA, X_PP, X_PAO)
- 7 sulfur species (SO4, H2S, 4 SRB types, S0)
- 9 iron species (Fe3+, Fe2+, 7 HFO variants)
- 13 mineral precipitates (struvite, HAP, FeS, etc.)
- 4 additional cations (K, Mg, Ca, Al)
- 1 solvent (H2O as component index 62)
-
AI-Powered ADM1 State Generation: Codex MCP server converts feedstock descriptions into complete 63-component states
-
Thermodynamically Rigorous pH Solver: Production charge balance with all ionic species
-
Dynamic Simulation: QSDsan's AnaerobicCSTR reactor with 4-component biogas tracking (H2, CH4, CO2, H2S)
Enhanced Design Tools (Week 1-2 Implementation)
-
Mixing Module (
utils/mixing_calculations.py): Physics-based power calculations for mechanical and pumped mixing- Eductor/jet pump support with
fluids.jet_pumpintegration (prevents 5× pump oversizing) - Non-Newtonian rheology corrections (Metzner-Otto method)
- Multiple impeller types (pitched blade, Rushton, marine propeller)
- Eductor/jet pump support with
-
Rheology Module (
utils/rheology.py): TSS-dependent viscosity for accurate mixing power- WEF MOP-8 validated correlations
- Power-law parameters (Baudez et al. 2011)
- Temperature corrections
-
Substrate-Aware Biomass Yield (
utils/heuristic_sizing.py:80-267): Complete ADM1 pathway analysis- Accounts for multi-step metabolism (not just first-step yields)
- Cascading yields: substrate → intermediates → acetate/H₂ → CH₄
- Substrate-specific yields: carbs (0.116), proteins (0.106), lipids (0.073-0.078) kg TSS/kg COD
- Based on ADM1 stoichiometry and product split fractions
- Known Limitation: Does not account for SRT-dependent endogenous decay (under investigation)
-
Thermal Integration: Direct MCP access to heat-transfer-mcp server
- Feedstock heating load calculations
- Tank heat loss (insulated vessels, weather data integration)
- Heat exchanger sizing (plate, shell-tube, coil)
-
Complete Workflow: Parameters → ADM1 generation → Validation → Sizing + Mixing + Thermal → Simulation
Quick Start
Installation
# Clone repository
cd /path/to/mcp-servers/anaerobic-design-mcp
# Install dependencies (requires Python 3.10+)
pip install -r requirements.txt
# Install QSDsan
pip install qsdsan
# Add to Claude Desktop MCP configuration
# Edit: %APPDATA%/Claude/claude_desktop_config.json (Windows)
# or: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
MCP Configuration:
{
"mcpServers": {
"anaerobic-design": {
"command": "C:/path/to/venv/Scripts/python.exe",
"args": [
"-m",
"server"
],
"cwd": "C:/path/to/mcp-servers/anaerobic-design-mcp"
}
}
}
Basic Usage
Step 1: Reset and collect parameters
# Reset design state
mcp__anaerobic-design__reset_design()
# Collect basis of design parameters
mcp__anaerobic-design__elicit_basis_of_design(
parameter_group="all",
current_values={
"Q": 1000, # m3/d
"Temp": 35, # °C
"cod_mg_l": 50000, # mg/L
"tss_mg_l": 35000, # mg/L
"vss_mg_l": 28000, # mg/L
"tkn_mg_l": 2500, # mg-N/L
"tp_mg_l": 500, # mg-P/L
"pH": 7,
"alkalinity_meq_l": 50
}
)
Step 2: Generate ADM1 state using Codex (CRITICAL - Do not skip!)
# Call Codex MCP to generate complete 63-component mADM1 state
mcp__ADM1-State-Variable-Estimator__codex(
prompt="""
Generate complete mADM1 state variables for:
Feedstock: High-strength municipal wastewater sludge
COD: 50,000 mg/L | TSS: 35,000 mg/L | VSS: 28,000 mg/L
TKN: 2,500 mg-N/L | TP: 500 mg-P/L | pH: 7.0
Save to: ./adm1_state.json (all 63 components in kg/m³)
""",
cwd="/path/to/anaerobic-design-mcp"
)
# Load generated state
mcp__anaerobic-design__load_adm1_state(file_path="./adm1_state.json")
Step 3: Validate and size
# Validate ADM1 state against measured parameters
python utils/validate_cli.py validate \
--adm1-state adm1_state.json \
--user-params '{"cod_mg_l": 50000, "tss_mg_l": 35000}' \
--tolerance 0.15
# Run heuristic sizing
mcp__anaerobic-design__heuristic_sizing_ad(
use_current_basis=True,
target_srt_days=20
)
Step 4: Run QSDsan simulation
# Execute simulation (300-600 seconds to reach TRUE steady state)
python utils/simulate_cli.py --basis simulation_basis.json --adm1-state adm1_state.json --heuristic-config simulation_heuristic_config.json --hrt-variation 0.2
# Parse results (token-efficient: 7 KB vs 159 KB full file)
python utils/parse_simulation_results.py
Output: Three comprehensive tables showing:
- Performance metrics (COD removal, methane yield, biomass yields)
- Inhibition analysis (pH, ammonia, H2, H2S effects)
- Precipitation metrics (struvite, HAP, FeS, etc.)
Optional chemical dosing (if needed for pH control):
python utils/simulate_cli.py --basis simulation_basis.json --adm1-state adm1_state.json --heuristic-config simulation_heuristic_config.json --hrt-variation 0.2 --naoh-dose 2840 --fecl3-dose 100
Available MCP Tools
Core Workflow:
elicit_basis_of_design- Collect design parametersload_adm1_state- Load Codex-generated ADM1 statevalidate_adm1_state- Verify state matches targetsheuristic_sizing_ad- Size digester and MBRsimulate_ad_system_tool- Run QSDsan dynamic simulation
State Management:
get_design_state- Check workflow progressreset_design- Start new project
Optional Analysis:
compute_bulk_composites- Calculate COD/TSS/VSS/TKN/TP from statecheck_strong_ion_balance- Verify charge balanceanalyze_stream_details- Component-level analysisassess_process_health- Inhibition factorsevaluate_sulfur_balance- H2S pathways
Architecture
anaerobic-design-mcp/
├── server.py # FastMCP server (13 tools)
├── tools/ # MCP tool implementations
│ ├── basis_of_design.py # Parameter collection
│ ├── validation.py # ADM1 state validation
│ ├── sizing.py # Heuristic sizing
│ └── simulation.py # QSDsan integration
├── utils/
│ ├── qsdsan_madm1.py # 63-component mADM1 model
│ ├── qsdsan_reactor_madm1.py # Custom AnaerobicCSTR
│ ├── qsdsan_simulation_sulfur.py # Simulation engine
│ ├── inoculum_generator.py # Enhanced inoculum
│ ├── parse_simulation_results.py # Token-efficient result parser
│ ├── validate_cli.py # CLI validation tools
│ └── simulate_cli.py # CLI simulation wrapper
├── core/
│ └── state.py # Design state management
└── docs/ # Complete documentation
├── INDEX.md # Navigation hub
├── architecture/ # System design
├── bugs/ # Bug tracking
├── development/ # Refactoring history
└── diagnostics/ # Analysis guides
Current Capabilities
Implemented Features
- Thermodynamic Rigor: Production charge balance solver with all 63 components
- Biogas Tracking: 4-component biogas (H2, CH4, CO2, H2S) with Henry's law equilibrium
- Methane Yield: 97.4% match to theoretical (validation against COD mass balance)
- pH Accuracy: 6.5-7.5 range for typical digesters (fixed critical R units bug)
- Unit Consistency: Aligned with QSDsan conventions (fixed 1000× gas production bug)
Critical Fixes Applied
- Enhanced Inoculum (6× Methanogen Boost) (2025-10-29): CRITICAL FIX for pH collapse during startup
- Doubled methanogen boost factor from 3× → 6× in
utils/inoculum_generator.py - Prevents VFA accumulation and pH drop from 7.0 → 4.8
- Enables stable operation WITHOUT chemical supplementation (NaOH, Na2CO3)
- Validated through comparative simulations: 3× boost = FAILED, 6× boost = SUCCESS
- Doubled methanogen boost factor from 3× → 6× in
- pH Solver Bugs (2025-10-21): Fixed 10^29× error in Ka values, restored pH to 6.7-7.5 range
- Production PCM (2025-10-18): 9 fixes for complete charge balance with all ionic species
- 1000× Unit Error (2025-10-21): Fixed gas transfer units, restored methane production
- QSDsan Alignment (2025-10-22): Eliminated divergence from upstream conventions
See docs/bugs/CRITICAL_FIXES.md for details.
Known Limitations
- Non-deterministic regression tests: Catastrophic failure case shows variable TAN (10,000-77,000 mg-N/L)
- Reactor maintenance burden: Custom AnaerobicCSTR class requires manual sync with QSDsan updates
- Simplified precipitation: Unity activity coefficients (Davies equation not yet implemented)
Documentation
- CLAUDE.md - System prompt for Claude Code (workflow instructions)
Quick Links
Requirements
- Python: 3.10+
- QSDsan: 1.3+ (includes mADM1 process model)
- FastMCP: 0.1.0+
- NumPy: 1.24+
- Pandas: 2.0+
See pyproject.toml for complete dependencies.
License
MIT License (see LICENSE file)
Support
- Issues: Submit via GitHub Issues
- Documentation: See docs/architecture/ directory for technical references
Citation
If you use this server in research, please cite:
- QSDsan framework: https://github.com/QSD-Group/QSDsan
- ADM1 model: Batstone et al. (2002) "The IWA Anaerobic Digestion Model No. 1 (ADM1)"
Development Status
Current Version: 0.1.0-dev (In Development)
Recent Updates:
- 2025-11-22: Pre-release cleanup (removed obsolete docs and dead code)
- 2025-11-04: Background Job Pattern implementation (prevents STDIO blocking)
- 2025-10-29: Enhanced inoculum (6× methanogen boost) - CRITICAL FIX for startup stability
- 2025-10-29: Token-efficient result parser (95% reduction: 7 KB vs 159 KB)
- 2025-10-26: Comprehensive documentation consolidation
- 2025-10-22: QSDsan convention alignment
- 2025-10-21: Critical pH and unit conversion fixes
- 2025-10-18: Production PCM solver implementation
- 2025-10-18: Full mADM1 (63 components) integration
Last Updated: 2025-11-22
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。