Skip to main content
Glama

create_model

Create a new system dynamics model by specifying simulation time range, step size, integration method, and time units.

Instructions

Create a new Stella model with specified time settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesModel name
startNoSimulation start time
stopNoSimulation stop time
dtNoTime step
methodNoIntegration method (Euler or RK4)Euler
time_unitsNoTime unitsYears

Implementation Reference

  • The handler function for the 'create_model' tool. It creates a new StellaModel instance with the given name and simulation settings (start, stop, dt, method, time_units), stores it in the global _current_model variable, and returns a confirmation message.
    if name == "create_model":
        _current_model = StellaModel(name=arguments["name"])
        _current_model.sim_specs.start = arguments.get("start", 0)
        _current_model.sim_specs.stop = arguments.get("stop", 100)
        _current_model.sim_specs.dt = arguments.get("dt", 0.25)
        _current_model.sim_specs.method = arguments.get("method", "Euler")
        _current_model.sim_specs.time_units = arguments.get("time_units", "Years")
        return [TextContent(
            type="text",
            text=f"Created model '{arguments['name']}' with time range {_current_model.sim_specs.start}-{_current_model.sim_specs.stop}, dt={_current_model.sim_specs.dt}"
        )]
  • The tool registration with input schema for 'create_model'. Defines the input parameters: name (required), start, stop, dt, method, and time_units (all with defaults).
    name="create_model",
    description="Create a new Stella model with specified time settings",
    inputSchema={
        "type": "object",
        "properties": {
            "name": {"type": "string", "description": "Model name"},
            "start": {"type": "number", "description": "Simulation start time", "default": 0},
            "stop": {"type": "number", "description": "Simulation stop time", "default": 100},
            "dt": {"type": "number", "description": "Time step", "default": 0.25},
            "method": {"type": "string", "description": "Integration method (Euler or RK4)", "default": "Euler"},
            "time_units": {"type": "string", "description": "Time units", "default": "Years"},
        },
        "required": ["name"],
    },
  • The StellaModel class that is instantiated by the create_model handler. The __init__ method creates a new model with given name, generates a UUID, initializes empty collections for stocks/flows/auxs/connectors, and creates default SimSpecs.
    class StellaModel:
        """Represents a complete Stella system dynamics model."""
    
        def __init__(self, name: str = "Untitled"):
            self.name = name
            self.uuid = str(uuid.uuid4())
            self.sim_specs = SimSpecs()
            self.stocks: dict[str, Stock] = {}
            self.flows: dict[str, Flow] = {}
            self.auxs: dict[str, Aux] = {}
            self.connectors: list[Connector] = []
            self._connector_uid = 0
  • The SimSpecs dataclass used to store simulation settings (start, stop, dt, method, time_units) that are set by the create_model handler.
    @dataclass
    class SimSpecs:
        """Simulation specifications."""
        start: float = 0
        stop: float = 100
        dt: float = 0.25
        method: str = "Euler"
        time_units: str = "Years"
  • The list_tools function that registers 'create_model' (and all other tools) with the MCP server via the @server.list_tools() decorator.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        """List available tools."""
        graphical_function_schema = {
            "type": "object",
            "description": "Graphical function (lookup table) definition",
            "properties": {
                "ypts": {
                    "type": "array",
                    "items": {"type": "number"},
                    "description": "Y values for the lookup table",
                },
                "xscale": {
                    "type": "object",
                    "description": "X scale when x points are evenly spaced",
                    "properties": {
                        "min": {"type": "number"},
                        "max": {"type": "number"},
                    },
                    "required": ["min", "max"],
                },
                "xpts": {
                    "type": "array",
                    "items": {"type": "number"},
                    "description": "Explicit X values (same length as ypts)",
                },
                "yscale": {
                    "type": "object",
                    "description": "Optional Y scale for display",
                    "properties": {
                        "min": {"type": "number"},
                        "max": {"type": "number"},
                    },
                    "required": ["min", "max"],
                },
                "type": {
                    "type": "string",
                    "description": "Graphical function type (e.g., continuous or discrete)",
                },
            },
            "required": ["ypts"],
        }
        return [
            Tool(
                name="create_model",
                description="Create a new Stella model with specified time settings",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "name": {"type": "string", "description": "Model name"},
                        "start": {"type": "number", "description": "Simulation start time", "default": 0},
                        "stop": {"type": "number", "description": "Simulation stop time", "default": 100},
                        "dt": {"type": "number", "description": "Time step", "default": 0.25},
                        "method": {"type": "string", "description": "Integration method (Euler or RK4)", "default": "Euler"},
                        "time_units": {"type": "string", "description": "Time units", "default": "Years"},
                    },
                    "required": ["name"],
                },
            ),
            Tool(
                name="add_stock",
                description="Add a stock (reservoir) to the current model",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "name": {"type": "string", "description": "Stock name"},
                        "initial_value": {"type": "string", "description": "Initial value (number or equation)"},
                        "units": {"type": "string", "description": "Units", "default": ""},
                        "non_negative": {"type": "boolean", "description": "Prevent negative values", "default": True},
                        "x": {"type": "number", "description": "X position (optional, auto-positioned if not specified)"},
                        "y": {"type": "number", "description": "Y position (optional, auto-positioned if not specified)"},
                    },
                    "required": ["name", "initial_value"],
                },
            ),
            Tool(
                name="add_flow",
                description="Add a flow between stocks in the current model",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "name": {"type": "string", "description": "Flow name"},
                        "equation": {"type": "string", "description": "Flow rate equation"},
                        "units": {"type": "string", "description": "Units", "default": ""},
                        "from_stock": {"type": "string", "description": "Source stock (null for external source)"},
                        "to_stock": {"type": "string", "description": "Destination stock (null for external sink)"},
                        "non_negative": {"type": "boolean", "description": "Prevent negative values", "default": True},
                        "x": {"type": "number", "description": "X position (optional, auto-positioned if not specified)"},
                        "y": {"type": "number", "description": "Y position (optional, auto-positioned if not specified)"},
                        "graphical_function": graphical_function_schema,
                    },
                    "required": ["name", "equation"],
                },
            ),
            Tool(
                name="add_aux",
                description="Add an auxiliary variable (parameter or intermediate calculation) to the current model",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "name": {"type": "string", "description": "Variable name"},
                        "equation": {"type": "string", "description": "Equation or constant value"},
                        "units": {"type": "string", "description": "Units", "default": ""},
                        "x": {"type": "number", "description": "X position (optional, auto-positioned if not specified)"},
                        "y": {"type": "number", "description": "Y position (optional, auto-positioned if not specified)"},
                        "graphical_function": graphical_function_schema,
                    },
                    "required": ["name", "equation"],
                },
            ),
            Tool(
                name="add_connector",
                description="Add a connector (dependency arrow) between variables",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "from_var": {"type": "string", "description": "Source variable name"},
                        "to_var": {"type": "string", "description": "Target variable name (the one using from_var)"},
                    },
                    "required": ["from_var", "to_var"],
                },
            ),
            Tool(
                name="save_model",
                description="Save the current model to a .stmx file",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "filepath": {"type": "string", "description": "Output file path (.stmx)"},
                    },
                    "required": ["filepath"],
                },
            ),
            Tool(
                name="read_model",
                description="Read an existing .stmx file and load it as the current model",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "filepath": {"type": "string", "description": "Path to .stmx file"},
                    },
                    "required": ["filepath"],
                },
            ),
            Tool(
                name="validate_model",
                description="Validate the current model for errors and warnings",
                inputSchema={
                    "type": "object",
                    "properties": {},
                },
            ),
            Tool(
                name="list_variables",
                description="List all variables (stocks, flows, auxiliaries) in the current model",
                inputSchema={
                    "type": "object",
                    "properties": {},
                },
            ),
            Tool(
                name="get_model_xml",
                description="Get the XMILE XML representation of the current model (for preview)",
                inputSchema={
                    "type": "object",
                    "properties": {},
                },
            ),
        ]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must carry the full burden. It only states 'create' and 'time settings', without disclosing side effects (e.g., file creation, overwriting), required permissions, or how the model is stored.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one concise sentence with no filler. It is appropriately front-loaded, but could include slightly more context without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description omits critical context such as what the tool returns (e.g., model ID, success message), whether it auto-loads the model, or how it fits into the workflow. This is insufficient for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% parameter description coverage. The description adds a summary of 'time settings' but no new semantic details beyond what the schema provides. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'Create a new Stella model' and the resource, but does not explicitly differentiate from sibling creation tools like 'add_aux' or 'add_stock'. However, the name 'create_model' is distinct enough to indicate a top-level creation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. Prerequisites or context (e.g., whether a workspace needs to be open, if model is saved automatically) are absent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bradleylab/stella-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server