Skip to content

Tools

Once connected, the server exposes these tools, grouped by what they do.

Class-Management — Modelica source authoring and loading:

Tool Description
listClasses Lists the Modelica class names visible in the current session (loaded libraries plus classes authored in this session).
readClassSource Returns the Modelica source text of a named class.
writeClassSource Creates or updates a Modelica class’s source text.
createClass Creates a new, empty Modelica class of a given specialization (model, class, package, record, connector, block, function, or type), optionally extending a base class.
loadFile Loads a .mo file from disk, making its classes available to other tools.
loadModel Loads/imports a Modelica library by class name (e.g. Modelica, Buildings), optionally pinned to a specific version.
getTotalModel Returns a named class’s full flattened source, with all dependencies resolved, optionally stripped of annotations and/or comments.

Simulation — model checking and simulation:

Tool Description
checkModel Runs checkModel against a named class and returns the check report (structural balance, errors, warnings).
simulate Simulates a named class and returns success, a result ID such as sim_3 as resultFile, omc’s messages, and unmatchedOverrides. Optional overrides (parameter name to value) apply to this run only, without changing the class. Optional reportVariables also return those variables’ final values.
simulateGrid Runs one simulation for every combination of the values in paramGrid (parameter name to a list of values), and returns one row per run with its parameters, success, values of reportVariables and resultFile.
simulateCombinations Runs one simulation for each entry of combinations, a list of parameter-name-to-value maps, in the order given, and returns one row per run like simulateGrid.

A sweep is limited to 20 runs. A larger design is refused before anything runs. Each row’s resultFile is an ID the Results tools read, like one from simulate. A run that fails doesn’t stop the sweep: its row records the failure. After each run, the server reports progress as run k of N to an AI client that asks for it.

A simulation may take up to an hour to compile and run. After that, the server gives up and restarts the omc session. Claude Code may stop waiting for a tool call sooner than that. To let it wait longer, set the MCP_TOOL_TIMEOUT environment variable (in milliseconds).

Results — reading a completed simulation. Pass a resultFile ID that simulate or a sweep returned. Each ID keeps its own copy of its run’s results, so simulating the same class again never changes what an earlier ID reads.

Tool Description
listSimulationResultVariables Lists the variables available in a simulation’s results, as a JSON array of names.
readSimulationResultValues Reads one variable’s full simulated series, as a JSON array of numbers.
getFinalValues Reads one or more variables’ values at the end of the simulation.
getValueAtTime Reads one or more variables’ values at a given time.
getResultStats Summarises one or more variables as min, max, mean and final value, without returning the full series.

Variable names may include integer array subscripts, e.g. x[1], body.I[1,2], r[1].b[2] or der(body.w_a[1]). Write subscripts without spaces. A malformed name is rejected before it reaches omc, with an error showing the accepted form.

Ungrouped:

Tool Description
getOmcVersion Reports the OpenModelica compiler (omc)’s version string.