Skip to main content
Glama
SethGame

FlexSim MCP Server

by SethGame

flexsim_step

Advance FlexSim simulations by stepping through specified events to analyze manufacturing and warehouse digital twins, enabling parameter studies and real-time model manipulation.

Instructions

Step through simulation events.

Args:
    steps: Number of events to step (1-1000, default: 1)

Example:
    steps=10  # Advance 10 events

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler function for flexsim_step tool. Steps through simulation events by executing FlexScript step() command N times. Gets the FlexSim controller, records start time, loops through the specified number of steps calling controller.evaluate('step()'), then returns formatted time progress.
    @mcp.tool()
    async def flexsim_step(params: StepInput) -> str:
        """Step through simulation events.
    
        Args:
            steps: Number of events to step (1-1000, default: 1)
    
        Example:
            steps=10  # Advance 10 events
        """
        try:
            controller = await get_controller()
            start = controller.time()
    
            # Use FlexScript step() command since Controller doesn't have native step method
            for _ in range(params.steps):
                controller.evaluate("step()")
    
            end = controller.time()
    
            return (
                f"✓ Stepped {params.steps} events\n"
                f"Time: {format_time(start)} → {format_time(end)}"
            )
        except Exception as e:
            return format_error(e)
  • Pydantic input schema for flexsim_step tool. Validates steps parameter as an integer between 1 and 1000, with default value of 1.
    class StepInput(BaseModel):
        """Input for stepping simulation."""
        steps: int = Field(default=1, ge=1, le=1000)
  • Controller management function that lazily initializes the FlexSim controller instance. Uses async lock for thread safety. Returns existing controller or launches new FlexSim instance if needed.
    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
  • Utility function that formats simulation time in seconds into human-readable format (seconds, minutes, or hours based on magnitude).
    def format_time(seconds: float) -> str:
        """Format simulation time as human-readable string."""
        if seconds < 60:
            return f"{seconds:.2f}s"
        elif seconds < 3600:
            return f"{seconds/60:.2f}m"
        else:
            return f"{seconds/3600:.2f}h"
  • Error formatting utility that converts exceptions into user-friendly error messages. Handles common FlexSim error types like not found, syntax, license, and permission errors.
    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}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions stepping through events but lacks details on behavioral traits such as whether this pauses or resumes the simulation, what happens if the simulation is not running, if it requires specific permissions, or how it interacts with other tools. The example adds minimal context, but overall, the description is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose, followed by args and an example. Every sentence earns its place by providing essential information without redundancy, and the structure is clear and efficient for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation tool with no annotations) and the presence of an output schema (which handles return values), the description is moderately complete. It covers the purpose and parameters well but lacks behavioral context like side effects or prerequisites. For a tool that likely alters simulation state, more details on usage constraints would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'steps' refers to the 'Number of events to step' with a range and default, clarifying the parameter's purpose and constraints. Since there's only one parameter and the schema lacks descriptions, the description effectively compensates, though it doesn't detail the event types or simulation state implications.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('step through') and resource ('simulation events'), making the purpose understandable. It distinguishes this tool from siblings like 'flexsim_run' or 'flexsim_run_to_time' by focusing on event-by-event advancement rather than continuous running or time-based execution. However, it doesn't explicitly contrast with all siblings like 'flexsim_reset' or 'flexsim_compile'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying the tool steps through events, suggesting it's for controlled simulation progression. It doesn't provide explicit guidance on when to use this versus alternatives like 'flexsim_run' (for full execution) or 'flexsim_run_to_time' (for time-based advancement), nor does it mention prerequisites or exclusions, leaving usage context somewhat inferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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