run_systems_model
Execute systems models to simulate complex scenarios and generate structured JSON output for analysis and decision-making.
Instructions
Run a systems model and return output of list of dictionaries in JSON.
Args: spec: The systems model specification rounds: Number of rounds to run (default: 100)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spec | Yes | ||
| rounds | No |
Implementation Reference
- main.py:19-19 (registration)The @mcp.tool() decorator registers the 'run_systems_model' function as an MCP tool.@mcp.tool()
- main.py:20-39 (handler)The handler function that implements the tool logic: imports and uses systems.parse.parse to parse the spec, runs the model for the given rounds, returns JSON results or an HTML error message.async def run_systems_model(spec: str, rounds: int = 100) -> str: """Run a systems model and return output of list of dictionaries in JSON. Args: spec: The systems model specification rounds: Number of rounds to run (default: 100) """ try: # Import here to avoid import errors if module is missing from systems.parse import parse debug_print(f"Running systems model for {rounds} rounds") # Parse the model and run it model = parse(spec) results = model.run(rounds=rounds) return json.dumps(results, indent=2, default=str) except Exception as e: debug_print(f"Error running systems model: {e}") return f"<div class='error'>Error running systems model: {str(e)}</div>"
- main.py:20-26 (schema)Type hints and docstring define the input schema (spec: str, rounds: int=100) and output (str JSON or error HTML).async def run_systems_model(spec: str, rounds: int = 100) -> str: """Run a systems model and return output of list of dictionaries in JSON. Args: spec: The systems model specification rounds: Number of rounds to run (default: 100) """