validate_model
Check your Stella model for errors and warnings to ensure it is valid and ready for export or simulation.
Instructions
Validate the current model for errors and warnings
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- stella_mcp/server.py:336-346 (handler)Handler for the 'validate_model' tool. Calls validate_model() and formats the results as TextContent with error/warning prefixes.
elif name == "validate_model": model = get_model() errors = validate_model(model) if not errors: return [TextContent(type="text", text="Model validation passed with no errors or warnings.")] result_lines = ["Model validation results:"] for err in errors: prefix = "ERROR" if err.severity == "error" else "WARNING" result_lines.append(f" [{prefix}] {err.category}: {err.message}") return [TextContent(type="text", text="\n".join(result_lines))] - stella_mcp/server.py:194-201 (schema)Registration of the 'validate_model' tool with its inputSchema (empty object, no parameters required).
Tool( name="validate_model", description="Validate the current model for errors and warnings", inputSchema={ "type": "object", "properties": {}, }, ), - stella_mcp/server.py:194-201 (registration)Tool registration in the list_tools() function under @server.list_tools() decorator.
Tool( name="validate_model", description="Validate the current model for errors and warnings", inputSchema={ "type": "object", "properties": {}, }, ), - stella_mcp/validator.py:274-277 (helper)Convenience function validate_model() that creates a ModelValidator instance and runs validation.
def validate_model(model: StellaModel) -> list[ValidationError]: """Convenience function to validate a model.""" validator = ModelValidator(model) return validator.validate() - stella_mcp/validator.py:19-37 (helper)ModelValidator class with all validation logic: undefined variables, mass balance, missing connections, orphan flows, stock-flow consistency, and circular dependencies.
class ModelValidator: """Validates Stella models for common errors.""" def __init__(self, model: StellaModel): self.model = model self.errors: list[ValidationError] = [] def validate(self) -> list[ValidationError]: """Run all validation checks and return errors/warnings.""" self.errors = [] self._check_undefined_variables() self._check_mass_balance() self._check_missing_connections() self._check_orphan_flows() self._check_stock_inflow_outflow_consistency() self._check_circular_dependencies() return self.errors