Skip to main content
Glama
SethGame

FlexSim MCP Server

by SethGame

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
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • 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)
  • 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)
  • 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}"
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SethGame/mcp_flexsim'

If you have feedback or need assistance with the MCP directory API, please join our Discord server