Skip to main content

MCP server for creating and manipulating Stella system dynamics models (.stmx files)

Project description

Stella MCP Server

A Model Context Protocol (MCP) server for creating and manipulating Stella system dynamics models. This enables AI assistants like Claude to programmatically build, read, validate, and save .stmx files in the XMILE format.

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-mcp

From source

git clone https://github.com/bradleylab/stella-mcp.git
cd stella-mcp
pip install -e .

Requirements

  • Python 3.10+
  • mcp>=1.0.0

Configuration

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"
    }
  }
}

Available Tools

Model Creation & I/O

Tool Description
create_model Create a new model with name and time settings (start, stop, dt, method)
read_model Load an existing .stmx file
save_model Save model to a .stmx file

Model Building

Tool Description
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)
add_connector Add a dependency connector between variables

Model Inspection

Tool Description
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

Example Usage

Creating a simple population model

User: Create a simple exponential growth model with a population starting at 100
      and a growth rate of 0.1 per year

Claude: [Uses create_model, add_stock, add_aux, add_flow, add_connector, save_model]
        Creates population_growth.stmx with:
        - Stock: Population (initial=100)
        - Aux: growth_rate (0.1)
        - Flow: growth (Population * growth_rate) into Population

Reading and analyzing an existing model

User: Read the carbon cycle model and explain what it does

Claude: [Uses read_model, list_variables]
        This model has 3 stocks (Atmosphere, Land Biota, Soil) and 6 flows
        representing carbon exchange through photosynthesis, respiration...

Building a biogeochemical model

User: Create a two-box ocean model with surface and deep nutrients

Claude: [Uses create_model, add_stock (x4), add_aux (x8), add_flow (x6), save_model]
        Creates a model with nutrient cycling between surface and deep ocean
        including upwelling, downwelling, biological uptake, and remineralization

Validation

The validate_model tool checks for:

  • Undefined variables - References to variables that don't exist
  • Mass balance issues - Stocks without flows, flows referencing non-existent stocks
  • Missing connections - Equations using variables without connectors (warning)
  • Orphan flows - Flows not connected to any stock
  • Circular dependencies - Infinite loops in auxiliary calculations

XMILE Compatibility

  • Output files use the XMILE standard
  • Compatible with Stella Professional 1.9+ and Stella Architect
  • Auto-layout positions elements reasonably; adjust manually in Stella if needed
  • Variable names with spaces are converted to underscores internally

Project Structure

stella-mcp/
├── README.md
├── LICENSE
├── pyproject.toml
└── stella_mcp/
    ├── __init__.py
    ├── server.py      # MCP server implementation
    ├── xmile.py       # XMILE XML generation and parsing
    └── validator.py   # Model validation logic

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT License - see LICENSE for details.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stella_mcp-0.4.0.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stella_mcp-0.4.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file stella_mcp-0.4.0.tar.gz.

File metadata

  • Download URL: stella_mcp-0.4.0.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stella_mcp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 03b42d5b61dbe5216ae546928dd9ab8cc14a1a9cadff190403aec8d79cf21107
MD5 9b259bebad8333b463d1eeda57a964fc
BLAKE2b-256 4be5ed4d801ac8fbdf8b3510c42381449ffb8669bc74cc6e27ca37624cebb03a

See more details on using hashes here.

Provenance

The following attestation bundles were made for stella_mcp-0.4.0.tar.gz:

Publisher: publish.yml on bradleylab/stella-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stella_mcp-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: stella_mcp-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stella_mcp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2e1c0b0e57834d2aad120e26ce5310b65b9eaeff72437c075135b4c3e6518c4
MD5 f8cdabac68439eac27102a7b6367a6d7
BLAKE2b-256 a0c786585606761b958e3e6b452fc4abc87e13c1073f916aa184159c9bb58bfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for stella_mcp-0.4.0-py3-none-any.whl:

Publisher: publish.yml on bradleylab/stella-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page