flexsim_get_node_value
Retrieve data from specific nodes in FlexSim simulation models to access parameters, statistics, and model states for analysis and automation.
Instructions
Get value from FlexSim tree node.
Args:
node_path: Path to node (e.g., "Model/Queue1/stats/input")
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- mcp_server/flexsim_mcp.py:386-400 (handler)Main handler implementation for flexsim_get_node_value tool. Uses the @mcp.tool() decorator for registration, takes NodeAccessInput parameters, and retrieves values from FlexSim tree nodes using FlexScript's getvalue() function.@mcp.tool() async def flexsim_get_node_value(params: NodeAccessInput) -> str: """Get value from FlexSim tree node. Args: node_path: Path to node (e.g., "Model/Queue1/stats/input") """ try: controller = await get_controller() script = f'getvalue(node("{params.node_path}"))' result = controller.evaluate(script) return f"{params.node_path} = {result}" except Exception as e: return format_error(e)
- mcp_server/flexsim_mcp.py:93-96 (schema)Schema definition for NodeAccessInput which defines the input parameters for flexsim_get_node_value tool. Uses Pydantic BaseModel for validation with a required node_path field.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:129-140 (helper)Helper function that formats exceptions into user-friendly error messages. Used by flexsim_get_node_value to handle errors gracefully.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)Helper function that gets or creates the FlexSim controller instance. Used by flexsim_get_node_value to obtain the controller for executing FlexScript commands.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