Skip to content

Demo

This demo shows an agent optimising a model end to end with this server. It has three files, each a download:

File Purpose
CSTR.mo A steady-state continuous stirred-tank reactor, MultiParameterCSTRWithObjectives. It needs no library.
optimisation_prompt.md The prompt to give your agent.
cstr_report_template.html The HTML report the agent fills in.

The prompt asks the agent to maximise the reactor’s Yield while keeping its production above a target (TargetMargin >= 0), by varying the feed flow F and the feed temperature T0. The agent simulates the model at its defaults, then searches in four rounds. Each round is a 4 x 4 grid of points over a box, and each box is half the width of the last, centred on the best result so far that meets the target. The agent runs each round as one simulateGrid call, with F and T0 as the grid’s variables, and Claude Code shows the round’s progress after each run as run k of N. With the run at the defaults and a last run to confirm the optimum, that makes 66 simulations. It writes the report as cstr_report.html in the same folder.

To run it:

  1. Download the three files into one folder you can write to.
  2. Open Claude Code in that folder: open a terminal in the folder and run claude. Claude Code’s own file tools read and write the files there. Running says how to check the server is ready.
  3. Paste the contents of optimisation_prompt.md into the chat, unchanged.
  4. When the agent finishes, open cstr_report.html in a web browser.

A run takes roughly 6 to 8 minutes, longer on a slower machine. If Claude Code asks for approval on each tool call, allow this server’s simulateGrid and simulate for the session. The agent calls those most often. Its other calls, such as loadFile and checkModel, happen once or twice. One simulateGrid call runs a whole round of 16 simulations, so it takes longer than a single simulate. Raise Claude Code’s tool-call timeout (MCP_TOOL_TIMEOUT) only if it stops a round before it finishes, as described under Tools.