flexsim_run
Start continuous simulation execution in FlexSim to analyze manufacturing and warehouse digital twins, perform parameter studies, and manipulate models in real-time.
Instructions
Start running the simulation continuously.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server/flexsim_mcp.py:257-265 (handler)The flexsim_run tool handler that starts continuous simulation. Gets the controller and calls controller.run() to start the simulation, returning a success message with a hint to use flexsim_stop to pause.@mcp.tool() async def flexsim_run() -> str: """Start running the simulation continuously.""" try: controller = await get_controller() controller.run() return "✓ Simulation running (use flexsim_stop to pause)" except Exception as e: return format_error(e)
- mcp_server/flexsim_mcp.py:257-265 (registration)Registration of flexsim_run as an MCP tool using the @mcp.tool() decorator from FastMCP framework.@mcp.tool() async def flexsim_run() -> str: """Start running the simulation continuously.""" try: controller = await get_controller() controller.run() return "✓ Simulation running (use flexsim_stop to pause)" except Exception as e: return format_error(e)
- mcp_server/flexsim_mcp.py:119-126 (helper)format_time helper function used to format simulation time as human-readable strings (seconds, minutes, hours).def format_time(seconds: float) -> str: """Format simulation time as human-readable string.""" if seconds < 60: return f"{seconds:.2f}s" elif seconds < 3600: return f"{seconds/60:.2f}m" else: return f"{seconds/3600:.2f}h"
- mcp_server/flexsim_mcp.py:129-140 (helper)format_error helper function that formats exceptions into user-friendly error messages, categorizing errors by type (not found, syntax, license, permission).def format_error(e: Exception) -> str: """Format exception as user-friendly error message.""" msg = str(e) if "not found" in msg.lower(): return f"Not found: {msg}" elif "syntax" in msg.lower(): return f"FlexScript syntax error: {msg}" elif "license" in msg.lower(): return f"License error: {msg}" elif "permission" in msg.lower(): return f"Permission denied: {msg}" return f"Error: {msg}"
- mcp_server/flexsim_mcp.py:147-154 (helper)get_controller helper function that manages the global FlexSim controller instance, creating it lazily on first use via launch_flexsim() with async locking for thread safety.async def get_controller(): """Get or create the FlexSim controller instance.""" global _controller async with _controller_lock: if _controller is None: _controller = await launch_flexsim() return _controller