run_systems_model
Execute systems model simulations with specified parameters to generate JSON output containing results as a list of dictionaries. Define model specifications and set rounds for iterative analysis.
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 |
|---|---|---|---|
| rounds | No | ||
| spec | Yes |
Implementation Reference
- main.py:20-39 (handler)The main handler function for the 'run_systems_model' tool. It parses the provided spec using systems.parse, runs the model for the specified number of rounds, and returns the results as a formatted JSON string. Includes error handling.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:19-19 (registration)Registers the run_systems_model function as an MCP tool using the FastMCP decorator.@mcp.tool()
- main.py:20-26 (schema)Type hints and docstring defining the input schema (spec: str, rounds: int=100) and output (str: JSON). Describes the tool's purpose and parameters.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) """