flexsim_set_node_value
Modify FlexSim simulation parameters by updating values in tree nodes to adjust model behavior during digital twin analysis.
Instructions
Set value in FlexSim tree node.
Args:
node_path: Path to node
value: New value to set
Example:
node_path="Model/Processor1/variables/processtime"
value=5.0
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- mcp_server/flexsim_mcp.py:403-435 (handler)The main handler function for flexsim_set_node_value. Takes NodeAccessInput with node_path and value, builds FlexScript setvalue command, executes it via controller, and verifies the new value.@mcp.tool() async def flexsim_set_node_value(params: NodeAccessInput) -> str: """Set value in FlexSim tree node. Args: node_path: Path to node value: New value to set Example: node_path="Model/Processor1/variables/processtime" value=5.0 """ try: controller = await get_controller() if params.value is None: return "Error: No value provided" # Build script to set value if isinstance(params.value, str): script = f'setvalue(node("{params.node_path}"), "{params.value}")' else: script = f'setvalue(node("{params.node_path}"), {params.value})' controller.evaluate(script) # Verify verify = f'getvalue(node("{params.node_path}"))' new_value = controller.evaluate(verify) return f"✓ {params.node_path} = {new_value}" except Exception as e: return format_error(e)
- mcp_server/flexsim_mcp.py:93-96 (schema)Input schema definition for node access operations. Defines node_path (required string) and value (optional Any) fields using Pydantic BaseModel.class NodeAccessInput(BaseModel): """Input for node operations.""" node_path: str = Field(..., min_length=1) value: Any | None = Field(default=None)
- mcp_server/flexsim_mcp.py:216-216 (registration)FastMCP server instance creation where tools are registered via the @mcp.tool() decorator.mcp = FastMCP("flexsim_mcp", lifespan=lifespan)
- mcp_server/flexsim_mcp.py:129-140 (helper)Error formatting utility used by the handler to format exceptions into user-friendly error messages with specific handling for common FlexSim error types.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)Controller getter function used by the handler to obtain the FlexSim controller instance, launching FlexSim if not already running.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