flexsim_reset
Reset a FlexSim simulation to its initial state with time set to zero, allowing you to restart model analysis from the beginning.
Instructions
Reset simulation to initial state (time = 0).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server/flexsim_mcp.py:246-254 (handler)Main handler implementation of flexsim_reset tool. Uses @mcp.tool() decorator for registration, gets the FlexSim controller, calls reset() to reset simulation to time 0, and returns a success message with error handling.@mcp.tool() async def flexsim_reset() -> str: """Reset simulation to initial state (time = 0).""" try: controller = await get_controller() controller.reset() return "✓ Simulation reset to time 0" except Exception as e: return format_error(e)
- mcp_server/flexsim_mcp.py:147-154 (helper)Helper function get_controller() that manages the global FlexSim controller instance with lazy initialization and thread-safe locking.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
- mcp_server/flexsim_mcp.py:129-140 (helper)Helper function format_error() that converts exceptions into user-friendly error messages for display.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}"
- tests/integration/test_mcp_client.py:269-298 (registration)Test code that validates flexsim_reset tool is registered and tests its execution as part of the integration test suite.required_tools = ["flexsim_open_model", "flexsim_reset", "flexsim_run", "flexsim_stop", "flexsim_get_time"] for tool in required_tools: if tool not in tool_names: print(f"\nERROR: {tool} tool not found!") return False print("\n✓ All required tools found") # Open model print(f"\nOpening model: {test_model}") result = await client.call_tool( "flexsim_open_model", {"model_path": str(test_model)} ) if "result" not in result: print(f"\n✗ Failed to open model: {result.get('error')}") return False print("✓ Model opened") # Reset simulation print("\nResetting simulation...") result = await client.call_tool("flexsim_reset") if "result" not in result: print(f"\n✗ Failed to reset: {result.get('error')}") return False print("✓ Simulation reset")
- mcp_server/flexsim_mcp.py:216-216 (registration)FastMCP server initialization at module level where all @mcp.tool() decorated functions including flexsim_reset are registered with the MCP server.mcp = FastMCP("flexsim_mcp", lifespan=lifespan)