Skip to main content
Glama
SethGame

FlexSim MCP Server

by SethGame

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

Implementation Reference

  • 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)
  • 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)
  • FastMCP server instance creation where tools are registered via the @mcp.tool() decorator.
    mcp = FastMCP("flexsim_mcp", lifespan=lifespan)
  • 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}"
  • 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

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