Stella MCP Server
A vendor-neutral Model Context Protocol (MCP)
server for creating and manipulating Stella
system dynamics models. Any compliant MCP client can build, read, validate, and
save .stmx files in the XMILE format; optional host features still vary.
What is this for?
Stella is a system dynamics modeling tool used for simulating complex systems in fields like ecology, biogeochemistry, economics, and engineering. This MCP server allows AI assistants to:
- Create models from scratch - Build stock-and-flow diagrams programmatically
- Read existing models - Parse and understand .stmx files
- Validate models - Check for errors like undefined variables or missing connections
- Modify models - Add stocks, flows, auxiliaries, and connectors
- Save models - Export valid XMILE files that open in Stella Professional
This is particularly useful for:
- Teaching system dynamics modeling
- Rapid prototyping of models through natural language
- Batch creation or modification of models
- Documenting and explaining existing models
Installation
From PyPI
pip install stella-mcpFrom source
git clone https://github.com/bradleylab/stella-mcp.git
cd stella-mcp
pip install -e .Requirements
- Python 3.10+
mcp>=2.0.0,<3
Configuration
Via uvx (no install required)
If you have uv installed, the lowest-friction configuration runs the published package directly:
{
"mcpServers": {
"stella": {
"command": "uvx",
"args": ["stella-mcp"]
}
}
}Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"stella": {
"command": "stella-mcp"
}
}
}Claude Code
Add to your .claude/settings.json:
{
"mcpServers": {
"stella": {
"command": "stella-mcp"
}
}
}Development mode
If running from source:
{
"mcpServers": {
"stella": {
"command": "python",
"args": ["-m", "stella_mcp.server"],
"cwd": "/path/to/stella-mcp"
}
}
}Recommended Agent Workflow
For a new model:
- On MCP 2026-07-28, call
create_workspaceand carry the returnedworkspace_idthrough stateful calls. Legacy stdio clients may omit it. build_modelwith a stablemodel_idand the full set of stocks, auxiliaries, and flows in one call (connector sync and validation run by default, so the response doubles as an inspection).- Fix validation errors with
update_*,rename_variable, ordelete_variable. - Extend incrementally with
add_variables(batch) or the single-add tools. simulateto sanity-check behavior (requires thesimextra).- Save with
save_model.
For imported models:
read_modelwithcompat_mode="permissive"to inspect warnings.- Run
inspect_modelto understand model structure. - Use
compat_mode="strict"before final save when round-trip fidelity matters.
Available Tools
Model Creation & I/O
| Tool | Description |
|---|---|
create_model | Create a new model with name and time settings (start, stop, dt, method) |
set_sim_specs | Update simulation time settings on an existing model |
read_model | Load an existing .stmx file |
save_model | Save model to a .stmx file |
delete_model | Remove a model from the workspace (saved files untouched) |
Templates
| Tool | Description |
|---|---|
list_templates | List built-in and user-defined templates (supports source/query/tag filters) |
get_template_info | Get detailed metadata for one template |
load_template | Load a template as a model in the current workspace |
save_as_template | Save the current model as a reusable user template (optional description/tags) |
Model Building
| Tool | Description |
|---|---|
build_model | Create and populate a model in one call (atomic batch) |
add_variables | Add multiple variables/connectors/modules to an existing model (atomic batch) |
add_stock | Add a stock (reservoir) with initial value and units |
add_flow | Add a flow between stocks with an equation |
add_aux | Add an auxiliary variable (parameter or calculation) |
update_stock | Update stock fields while preserving relationships |
update_flow | Update flow fields while preserving stock links |
update_aux | Update auxiliary variable fields |
add_connector | Add a dependency connector between variables |
sync_connectors_from_equations | Add missing dependency connectors inferred from equations |
set_connector_routing | Set connector angle and explicit waypoint routing metadata |
rename_variable | Rename a stock/flow/aux and update references in equations/connectors/modules |
delete_variable | Delete a stock/flow/aux with consistency checks and cleanup |
create_module | Create a logical module/group of variables |
add_to_module | Add variables to an existing module/group |
remove_from_module | Remove variables from a module/group |
rename_module | Rename a module/group |
delete_module | Delete a module/group |
set_module_view | Set explicit module box position/size on the diagram |
set_module_style | Set module box style (border/background/font/label side) on the diagram |
auto_place_module_boxes | Auto-place module boxes around their members |
Notes:
- MCP 2026-07-28 clients call
create_workspaceonce and include its returnedworkspace_idin stateful calls. Modern tool discovery marks that field as required on stateful tools. The ID routes application state; it is not an authorization credential. - Supported legacy stdio clients may omit
workspace_idand use one process-local compatibility workspace; legacy discovery keeps the field optional. - Tools accept optional
model_idso one workspace can manage multiple models safely. create_modelandread_modelset the workspace's currentmodel_idand return it.add_flowandadd_auxsupport optionalgraphical_functionpayloads (yptsplus exactly one ofxscaleorxpts).add_stock/add_flow/add_auxreject duplicate variable names across variable types;add_connectorrequires both variables to exist.set_connector_routingcan target a connector byconnector_uidor byfrom_var+to_var.save_modelandget_model_xmlacceptauto_layout(defaulttrue) andresolve_layout_violations(defaultfalse).save_model,get_model_xml, andrender_diagramreturn the latest layout viewport, metrics, and warnings in structured content. Their text result names any non-clean layout warning codes.read_model,save_model, andget_model_xmlacceptcompat_mode:permissive(default): continue with warningsstrict: fail on compatibility issues
set_module_styleupdates module view styling and persists those attributes in XMILE view<group .../>elements.save_as_templatewrites user templates to~/.stella-mcp/templatesby default (override viaSTELLA_MCP_TEMPLATE_DIR) and stores metadata in a.meta.jsonsidecar.- Tool failures return structured MCP errors with
error.code,error.category, anderror.message. - Every successful tool result retains readable text and supplies schema-validated
structuredContentdescribed by its JSON Schema 2020-12outputSchema.
Workspace Lifecycle
| Tool | Description |
|---|---|
create_workspace | Create an isolated workspace, optionally with a caller-selected lifetime |
revoke_workspace | Revoke a workspace and discard its in-memory models |
Model Inspection
| Tool | Description |
|---|---|
list_models | List available workspace model IDs and indicate the current model |
inspect_model | Return a structured model summary for agent inspection |
list_modules | List modules/groups in the current model |
list_connectors | List connector IDs, endpoints, angles, and routing metadata |
list_variables | List all stocks, flows, and auxiliaries |
validate_model | Check for errors (undefined variables, missing connections, etc.) |
get_model_xml | Preview the XMILE XML output |
render_diagram | Render the model as an SVG stock-and-flow diagram |
simulate | Run the model via PySD and return time series + summaries (sim extra) |
compare_scenarios | Run named what-if override sets against a baseline and report deltas (sim extra) |
sensitivity_analysis | Sweep parameters one-at-a-time and rank their effect on an output metric (sim extra) |
calibrate | Fit constant parameters to an observed time-series (inverse of simulate) (sim extra) |
Batch Building
build_model creates and populates a model in one call. Items apply in the
order stocks → auxs → flows → connectors → modules; the whole batch is
all-or-nothing, and on failure the error names the failing item
(error.stage + error.index). The same item arrays work on an existing
model via add_variables.
{
"name": "build_model",
"arguments": {
"name": "SIR",
"model_id": "sir",
"sim_specs": {"start": 0, "stop": 100, "dt": 0.125, "time_units": "Days"},
"stocks": [
{"name": "Susceptible", "initial_value": "9999", "units": "people"},
{"name": "Infected", "initial_value": "1", "units": "people"},
{"name": "Recovered", "initial_value": "0", "units": "people"}
],
"auxs": [
{"name": "contact_rate", "equation": "6"},
{"name": "infectivity", "equation": "0.25"},
{"name": "recovery_time", "equation": "2", "units": "days"},
{"name": "total_population", "equation": "Susceptible + Infected + Recovered"}
],
"flows": [
{"name": "infection", "equation": "Susceptible * contact_rate * infectivity * Infected / total_population", "from_stock": "Susceptible", "to_stock": "Infected"},
{"name": "recovery", "equation": "Infected / recovery_time", "from_stock": "Infected", "to_stock": "Recovered"}
],
"modules": [
{"name": "Disease Dynamics", "members": ["Susceptible", "Infected", "Recovered"]}
]
}
}Connector sync and validation run by default (disable with
"sync_connectors": false / "validate": false); the response includes the
full structured model summary, so no follow-up inspect_model call is needed.
Tool Payload Examples
Create and switch between workspace models:
{"name":"create_model","arguments":{"name":"Population","model_id":"pop_v1"}}{"name":"create_model","arguments":{"name":"Carbon","model_id":"carbon_v1"}}{"name":"list_models","arguments":{}}{"name":"delete_model","arguments":{"model_id":"pop_v1"}}{"name":"inspect_model","arguments":{"model_id":"sir_baseline","include_validation":true}}List and load templates:
{"name":"list_templates","arguments":{}}{"name":"list_templates","arguments":{"source":"builtin","query":"epidem","tags":["epidemiology"]}}{"name":"get_template_info","arguments":{"template_name":"sir"}}{"name":"load_template","arguments":{"template_name":"sir","model_id":"sir_baseline"}}Save current model as a user template:
{"name":"save_as_template","arguments":{"model_id":"pop_v1","template_name":"my_population_template","description":"Baseline single-stock growth starter","tags":["intro","population"]}}Create and manage modules:
{"name":"create_module","arguments":{"model_id":"sir_baseline","name":"Disease Dynamics","members":["Susceptible","Infected","Recovered"]}}{"name":"add_to_module","arguments":{"model_id":"sir_baseline","module_name":"Disease Dynamics","members":["infection","recovery"]}}{"name":"list_modules","arguments":{"model_id":"
…