MCP Scenario Engine
OfficialThis server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP Scenario Engine
An MCP Server for Deterministic Simulation and Scenario Planning
Overview
The MCP Scenario Engine is a Model Context Protocol (MCP) server that provides a simulation space where AI agents can query system states, execute actions, and simulate impacts in a traceable manner.
With complex formula support, you can now model sophisticated systems including game theory, economics, health tracking, and scientific simulationsโall through JSON-defined rules.
Use Cases
๐ฏ Project Planning: Resource allocation, timeline simulation
๐๏ธ Infrastructure: Capacity planning, load testing
๐ฌ Scientific Modeling: Physics, chemistry, biology simulations
๐ Economics & Finance: Market dynamics, auctions, investments
๐ฎ Game Theory: Strategic interactions, Nash equilibrium, evolutionary dynamics
๐๏ธ Health & Fitness: Body composition, nutrition, training optimization
๐ณ What-If Analysis: Timeline forking for alternative scenarios
Related MCP server: simengine-mcp
Core Features
โ State Management
Versioned state schema (JSON Schema)
Complete state snapshots
Slicing and partial queries
Time-stepped simulation
โ Action System
10 implemented actions:
step- Advance time forwardset_resource- Set resource valueadjust_resource- Adjust resource by deltaset_metric- Set metric valueadjust_metric- Adjust metric by delta (deltaoramountparameter)initialize- Batch-initialize resources, metrics, flags, entities in one callset_flag- Set boolean flagadd_entity- Add/update entityremove_entity- Remove entitysimulate_load- Simulate load scenario (with randomness)
โ World Rules (Dynamic)
JSON-defined rules via MCP
Automatic application on
stepactionsFlexible conditions (comparison, and, or, not, always)
Value sources (resource, metric, flag, metadata, time, value)
Multiple action types (set_resource, set_metric, set_flag, set_metadata)
Complex formulas with arithmetic operations:
Addition:
{"type": "add", "values": [...]}Subtraction:
{"type": "subtract", "left": ..., "right": ...}Multiplication:
{"type": "multiply", "values": [...]}Division:
{"type": "divide", "numerator": ..., "denominator": ...}Nested operations for complex calculations
Priority system for rule execution order
Full rule management (CRUD operations)
โ Constraint Engine
Server-side validation
Automatic state rollback on violations
3+ predefined constraints:
NonNegativeResourceConstraintMaxResourceConstraintTimeMonotonicConstraint
Clear error messages with context
โ Determinism & Reproducibility
Seed-based random number generation
Same seed โ Same results
Fully reproducible simulations
โ Audit & Explainability
Complete event history
State deltas for every change
Constraint checks logged
Structured logging (JSON)
โ Timeline Forking
Branch simulations
Parallel "what-if" scenarios
Immutable original timeline
โ Persistence
Save state + rules + history
Manage multiple simulations
Survive server restarts
Set checkpoints and resume
CRUD operations (Save, Load, List, Delete)
Metadata inspection without loading
Storage in
~/.mcp-scenario-engine/simulations/
What's New
New Actions
adjust_metric- Adjust a metric by delta (deltaoramountparameter)initialize- Batch-initialize resources, metrics, flags, entities in one call
New Tools
get_timeseries- Query time-series snapshots with variable and time filtersbatch_apply_actions- Apply multiple actions in a single MCP call
World Rules Enhancements
adjust_resource,adjust_metric,adjust_metadataaction types in rulesclamp_resource,clamp_metricโ keep values within boundsmin,max,clampvalue types in_compute_valuepriorityanddescriptionfields exposed inadd_world_rule
Engine Improvements
stepwithsteps: Nnow fires world rules N times (one per sub-step)Per-step timeseries snapshots for multi-step calls
Manual action snapshots in timeseries (non-step actions that change state)
reset_simulationgainskeep_rulesparameterfork_timelinegainsactivateparameter (makes fork the active simulation)
Persistence Fixes
Timeseries snapshots are saved and restored
Constraints (NonNegative + Max) are saved and restored
Installation
Prerequisites
Python 3.11+
pip or uv
Local Installation
# Clone repository
git clone https://github.com/schimmmi/mcp-scenario-engine.git
cd mcp-scenario-engine
# Install dependencies
make install
# Or manually
pip install -e ".[dev]"Docker
Prebuilt image (GHCR) โ no clone needed
Every release is published as a container image:
docker pull ghcr.io/schimmilab/mcp-scenario-engine:latestAdd it to your MCP client config (Claude Code .mcp.json, Claude Desktop claude_desktop_config.json):
{
"mcpServers": {
"scenario-engine": {
"command": "docker",
"args": ["run", "-i", "--rm",
"-v", "scenario-engine-data:/root/.mcp-scenario-engine",
"ghcr.io/schimmilab/mcp-scenario-engine:latest"]
}
}
}The named volume keeps saved simulations between sessions; drop the -v line if you don't need persistence.
Pin a version instead of latest (e.g. :1.2.1) for reproducible runs.
Build locally
Build and Run Demos
# Build Docker image
docker compose build
# Run all demo scenarios
docker compose --profile demo run demo
# Run specific demo
docker compose run demo python examples/demo_scenario_a.py
docker compose run demo python examples/demo_weight_loss.py
docker compose run demo python examples/demo_prisoners_dilemma.pyStart MCP Server
Option 1: Standalone Server
# Start server in background
docker compose up -d mcp-scenario-engine
# View logs
docker compose logs -f mcp-scenario-engine
# Stop server
docker compose downOption 2: Use with Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"scenario-engine": {
"command": "docker",
"args": [
"compose",
"-f",
"/path/to/mcp-scenario-engine/docker-compose.yml",
"run",
"--rm",
"mcp-scenario-engine"
]
}
}
}Important Notes:
Replace
/path/to/mcp-scenario-enginewith actual pathDocker must be running before starting Claude Desktop
Simulations are saved inside the container (mount a volume to persist)
Mount Volume for Persistence:
# Add to docker-compose.yml under mcp-scenario-engine service:
volumes:
- ~/.mcp-scenario-engine:/root/.mcp-scenario-engineThis saves simulations to your home directory instead of the container.
๐ For complete Docker documentation, see DOCKER.md
Quick Start
1. Run Demo
# Both demo scenarios
make demo
# Or individually
python examples/demo_scenario_a.py
python examples/demo_scenario_b.py2. Use as Python Library
from mcp_scenario_engine import SimulationEngine
from mcp_scenario_engine.constraints import NonNegativeResourceConstraint
# Create simulation
sim = SimulationEngine(seed=42)
# Set initial state
sim.state.resources = {"budget": 10000.0, "capacity": 100.0}
# Add constraint
sim.constraint_engine.add_constraint(
NonNegativeResourceConstraint("budget")
)
# Execute actions
result = sim.apply_action(
"adjust_resource",
{"resource": "budget", "delta": -2000.0}
)
if result.success:
print(f"New budget: {sim.state.resources['budget']}")
print(f"Delta: {result.delta}")
else:
print(f"Error: {result.message}")
for v in result.constraints_violated:
print(f" - {v.constraint_id}: {v.message}")3. Use as MCP Server
# Start server
python -m mcp_scenario_engine.server
# Configure in Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"scenario-engine": {
"command": "python",
"args": ["-m", "mcp_scenario_engine.server"],
"cwd": "/path/to/mcp-scenario-engine"
}
}
}MCP Tools
The server provides 20 tools:
State Management
get_state
Get current simulation state.
{}get_schema
Get state schema definition.
{}Action Execution
apply_action
Execute an action.
{
"action": "adjust_resource",
"params": {
"resource": "budget",
"delta": -500.0
}
}Simulation Control
reset_simulation
Reset simulation to initial state.
{
"seed": 42,
"keep_rules": true
}fork_timeline
Fork timeline for "what-if" scenarios.
{
"name": "optimistic_scenario",
"activate": true
}get_history
Get event history.
{
"limit": 10
}World Rules (Dynamic)
add_world_rule
Add dynamic rule that automatically applies on step actions.
{
"rule_id": "cpu_overload",
"condition": {
"type": "comparison",
"left": {"type": "resource", "name": "cpu"},
"operator": ">",
"right": {"type": "value", "value": 80}
},
"actions": [{
"type": "set_metric",
"metric": "error_rate",
"value": {"type": "increment", "amount": 0.05}
}],
"priority": 10,
"description": "Increase error rate on CPU overload"
}list_world_rules
List all active rules.
{}get_world_rule
Get details of a specific rule.
{
"rule_id": "cpu_overload"
}update_world_rule
Update existing rule (partial update).
{
"rule_id": "cpu_overload",
"priority": 20,
"description": "Updated description"
}remove_world_rule
Remove a rule.
{
"rule_id": "cpu_overload"
}clear_world_rules
Remove all rules.
{}Persistence
save_simulation
Save simulation persistently (State + Rules + History).
{
"name": "devops_scenario_1",
"description": "High CPU scenario with 3 steps"
}load_simulation
Load saved simulation (replaces current simulation).
{
"name": "devops_scenario_1"
}list_simulations
List all saved simulations.
{}get_simulation_info
Get simulation metadata without loading it.
{
"name": "devops_scenario_1"
}delete_simulation
Delete a saved simulation.
{
"name": "devops_scenario_1"
}Extended Actions
adjust_metric
Adjust a metric by delta.
{"action": "adjust_metric", "params": {"metric": "score", "delta": 5.0}}initialize
Batch-initialize multiple state fields in one call.
{
"action": "initialize",
"params": {
"resources": {"budget": 10000, "energy": 100},
"metrics": {"output": 0, "efficiency": 1.0},
"flags": {"active": true}
}
}Batch & Timeseries
batch_apply_actions
Apply multiple actions in a single MCP call.
{
"actions": [
{"action": "initialize", "params": {"resources": {"budget": 1000}}},
{"action": "step", "params": {"steps": 5}}
],
"stop_on_failure": true
}get_timeseries
Query time-series snapshots recorded at each step.
{"variables": ["budget", "output"], "from_time": 0, "to_time": 10}State Schema (v1)
{
"schema_version": "v1",
"simulation_id": "uuid",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:35:00Z",
"seed": 42,
"time": 0,
"entities": {},
"metrics": {},
"resources": {},
"flags": {},
"metadata": {}
}Demo Scenarios
Scenario A: Normal Simulation Run
Demonstrates:
State initialization
Multiple action types
Resource management
Entity lifecycle
Metrics tracking
Reproducibility
python examples/demo_scenario_a.pyOutput:
============================================================
DEMO SCENARIO A: Normal Simulation Run
============================================================
1. Creating simulation with seed=42...
2. Adding constraints...
- Budget must be non-negative
- Team capacity must be non-negative
3. Executing simulation steps...
...
โ Advanced to time step 3
6. Testing Reproducibility:
โ Reproducibility verified - identical results with same seedScenario B: Constraint Violations
Demonstrates:
Constraint validation
State rollback on violations
Clear error messages
Event history
Timeline forking
python examples/demo_scenario_b.pyOutput:
============================================================
DEMO SCENARIO B: Constraint Violation Handling
============================================================
5. Testing constraint violations...
Violation Attempt 1: Exceed maximum server load
โ REJECTED as expected: Action rejected due to constraint violations
Violations detected:
- max_resource_server_load: Resource 'server_load' exceeds maximum 100.0 (got 130.0)
State unchanged - Server load still: 80.00Demo: World Rules (DevOps)
Demonstrates dynamic rules:
JSON-based rule definition
Automatic causality
Deterministic world model simulation
python examples/demo_devops_world.pyDemo: Persistence
Demonstrates persistence features:
Save/load simulations
Multiple simulation management
Continue from checkpoint
Delete and list operations
python examples/demo_persistence.pyOutput:
โ
Persistence Demo Complete!
๐ก Key Features:
โข Save simulations with state + rules + history
โข Load simulations and continue from checkpoint
โข List all saved simulations
โข Get metadata without loading
โข Delete simulations
โข Overwrite existing savesDemo: Weight Loss Simulation (Complex Formulas)
Demonstrates complex formula support:
Division:
(calorie_deficit / 7700) * 7 * complianceMultiplication of multiple variables
Addition and subtraction
Nested operations
Real-world body composition modeling
python examples/demo_weight_loss.pyOutput:
Week Weight Change Fat Muscle Fat%
----------------------------------------------------------------------
Start 92.47kg - 18.55kg 70.16kg 20.1%
1 88.53kg -3.94kg 18.24kg 70.29kg 20.6%
2 88.35kg -0.18kg 17.93kg 70.41kg 20.3%
...
8 87.26kg -0.18kg 16.08kg 71.18kg 18.4%
Results: -5.21kg weight, -2.47kg fat, +1.02kg muscle, body fat: 20.1% โ 18.4%Demo: Game Theory Simulations
Demonstrates game-theoretic models with complex strategic interactions:
Prisoner's Dilemma (Iterated Game)
python examples/demo_prisoners_dilemma.pyFeatures:
Iterated prisoner's dilemma with payoff matrices
Tit-for-Tat vs Tit-for-Tat (mutual cooperation)
Tit-for-Tat vs Always Defect (retaliation)
Strategic formulas calculating payoffs from action combinations
Output:
Round P1 Move P2 Move P1 Score P2 Score
----------------------------------------------------------------------
1 Cooperate Cooperate 3 3
...
10 Cooperate Cooperate 30 30
Tit-for-Tat vs Always Defect:
1 Cooperate Defect 0 5
2 Defect Defect 1 6
...Evolutionary Game Theory (Hawk-Dove)
python examples/demo_evolutionary_game.pyFeatures:
Population dynamics with Hawks and Doves
Frequency-dependent fitness calculations
Replicator dynamics:
hawks_new = hawks * (hawk_fitness / avg_fitness)Evolutionary Stable Strategy (ESS) emergence
Complex nested formulas for payoffs
Output:
Gen Hawks Doves H_Fit D_Fit Avg_Fit
----------------------------------------------------------------------
1 50.0 50.0 12.5 12.5 12.5
...
20 50.0 50.0 12.5 12.5 12.5
Equilibrium: 50% Hawks (matches theoretical ESS!)Auction Theory (Vickrey Second-Price)
python examples/demo_auction_theory.pyFeatures:
Sealed-bid second-price auction
Truth-telling incentive demonstration
Winner's surplus calculation:
valuation - paymentDominant strategy analysis
Compares truthful vs strategic bidding
Output:
Winner: Bidder 3
Payment: $95.00 (second-highest bid)
Winner's Surplus: $25.00
Truth-telling test:
โข Underbidding โ Lost auction, $25 regret
โข Overbidding โ Same surplus ($25), no benefitClaude Code Workspace
This repository includes a ready-to-use Claude Code workspace with simulation skills and templates.
Quick Setup
Use this repository directory as your Claude Code workspace, or
Copy the
workspace/folder and.claude/folder to your own project
Available Skills (Slash Commands)
Skill | Trigger | Description |
| Game theory | Nash equilibrium, Prisoner's Dilemma, Tit-for-Tat |
| Risk/probability | Risk estimation, uncertainty quantification via forks |
| System dynamics | Stocks & Flows, SIR models, Lotka-Volterra |
| State transitions | Churn, health states, project phases, credit risk |
| Agent-based models | Markets, opinion dynamics, emergence |
| Optimization | Grid search, portfolio, resource allocation |
| Multi-agent | Orchestrator + Sub-agents for coupled simulations |
Workspace Structure
workspace/
โโโ CLAUDE.md # Engine reference & project context
โโโ templates/ # Simulation templates (health, project, system)
โโโ designs/ # Pre-simulation design documents
โโโ results/ # Saved simulation results (examples included)
โโโ analysis/ # Analysis & insights
โโโ data/ # Input data & reference values
โโโ scripts/ # Helper scriptsExample Results
See workspace/results/ for three worked examples:
example_spieltheorie.mdโ Tit-for-Tat vs Always Defect game theory simulationexample_sir_epidemie.mdโ SIR epidemic model with Rโ=6example_volkswirtschaft.mdโ 3-agent Keynesian economy simulation
Testing
# Run all tests
make test
# With coverage
pytest --cov=src --cov-report=html
# Unit tests only
pytest tests/test_*.py -v
# Integration tests only
pytest tests/test_integration.py -vTest Coverage: 80%+ (requirement met)
Development
Code Quality
# Linting
make lint
# Formatting
make format
# Type checking
mypy srcStructure
mcp-scenario-engine/
โโโ src/mcp_scenario_engine/
โ โโโ __init__.py
โ โโโ models.py # Pydantic Models (State, Events)
โ โโโ constraints.py # Constraint Engine
โ โโโ actions.py # Action Implementations
โ โโโ simulation.py # Core Simulation Engine
โ โโโ dynamic_rules.py # Dynamic Rule System
โ โโโ world_rules.py # World Rule Engine
โ โโโ persistence.py # Persistence Layer
โ โโโ server.py # MCP Server (20 Tools)
โโโ tests/
โ โโโ test_simulation.py # Unit Tests
โ โโโ test_constraints.py # Constraint Tests
โ โโโ test_actions.py # Action Tests
โ โโโ test_integration.py # Integration Tests
โโโ examples/
โ โโโ demo_scenario_a.py # Demo: Normal Simulation
โ โโโ demo_scenario_b.py # Demo: Constraint Violations
โ โโโ demo_devops_world.py # Demo: World Rules
โ โโโ demo_persistence.py # Demo: Persistence
โโโ .simulations/ # Saved Simulations
โโโ Dockerfile
โโโ docker-compose.yml
โโโ pyproject.toml
โโโ Makefile
โโโ README.mdObservability
Structured Logging
All logs are output as JSON:
{
"event": "action_applied",
"simulation_id": "123e4567-e89b-12d3-a456-426614174000",
"action": "adjust_resource",
"event_id": "456e7890-e89b-12d3-a456-426614174111",
"timestamp": "2025-01-15T10:30:00.123456Z"
}Event Types
simulation_created- Simulation createdsimulation_reset- Simulation resetaction_applied- Action successfulconstraint_violated- Constraint violationtimeline_forked- Timeline forked
Acceptance Criteria
โ
Read state: get_state returns valid schema
โ
Execute action: apply_action returns before/after/delta/event_id
โ
Constraint enforcement: Violations prevent state changes
โ
Determinism: Same seed โ Same results
โ
Fork/Branch: Immutable original, diverging fork
Definition of Done
Implementation โ
MCP server operational (Docker + venv)
State schema v1 documented
8 actions implemented
Constraint engine with 3+ rules
Determinism via seed
Quality โ
Unit tests (80%+ coverage)
Integration tests (end-to-end)
Linting/Formatting (ruff/black)
Type checking (mypy)
Observability โ
Structured logging (JSON)
No secrets in logs
Clear error messages
Documentation โ
README with setup & examples
Tool list & schema
4 demo scenarios
Example outputs
Demo โ
make demoworksScenario A: Normal run
Scenario B: Constraint handling
Demo: World rules
Demo: Persistence
License
MIT
Contact
For questions or issues, please open an issue on GitHub.
Maintainer
Schimmi โ https://schimmilab.de Issues und Pull Requests willkommen.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
Deterministic reasoning stack for AI agents: simulate, decide & compute, plus cross-domain tools.
Plan, run and inspect AI-agent drills with synthetic users, hosted tools and cloud worlds.
Deterministic what-if & scenario simulation for AI agents: projections, sensitivity & break-even.
Hosted runtime for persistent agent teams, durable workflows, memory, schedules, and goals.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables step-debugging, deterministic replay, and signed audit evidence for AI agents, compliant with EU AI Act.76 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceEnables running Monte Carlo simulations, safety constraint evaluation, and optimization from JSON domain configs. Provides AI agents with a tool to simulate uncertain futures and obtain structured results.Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables LLM agents to inhabit a shared simulated world where they can move, communicate, trade, leave signs, and try to survive under deterministic, data-driven rules that can be changed at runtime while spectators observe events and state.MIT

SimArch MCP Serverofficial
AlicenseBqualityBmaintenanceEnables AI tools and agents to form contract-bound organizations, execute persistent task DAGs with independent audits, score decisions with counterfactual trees, run time-compressed world simulations, and control an on-demand localhost dashboard via stdio tools.61Apache 2.0