Skip to main content
Glama
SethGame

FlexSim MCP Server

by SethGame

flexsim_run_to_time

Advance a FlexSim simulation to a specified target time, with options for maximum speed execution or real-time GUI updates.

Instructions

Run simulation until reaching target time.

Args:
    target_time: Target simulation time in seconds
    fast_mode: Run at maximum speed (default: True). Set to False for real-time GUI updates.

Example:
    target_time=3600  # Run for 1 hour

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main implementation of flexsim_run_to_time tool. Handles both fast mode (blocking, no GUI) and real-time mode (with GUI updates) simulation running until a target time is reached.
    @mcp.tool()
    async def flexsim_run_to_time(params: RunToTimeInput) -> str:
        """Run simulation until reaching target time.
    
        Args:
            target_time: Target simulation time in seconds
            fast_mode: Run at maximum speed (default: True). Set to False for real-time GUI updates.
    
        Example:
            target_time=3600  # Run for 1 hour
        """
        try:
            controller = await get_controller()
            start = controller.time()
    
            if start >= params.target_time:
                return f"Already at time {format_time(start)}"
    
            if params.fast_mode:
                # Fast mode: blocking call at max speed (no GUI updates)
                controller.runToTime(params.target_time)
            else:
                # Real-time mode: set stop time and run with GUI animation
                controller.evaluate(f"setstoptime({params.target_time})")
                controller.run()
                
                # Poll until target time reached or simulation stops
                while True:
                    current = controller.time()
                    if current >= params.target_time:
                        controller.stop()
                        break
                    await asyncio.sleep(0.1)
    
            end = controller.time()
    
            mode_str = "fast" if params.fast_mode else "real-time"
            return (
                f"✓ Simulation complete ({mode_str})\n"
                f"Start: {format_time(start)}\n"
                f"End: {format_time(end)}\n"
                f"Duration: {format_time(end - start)}"
            )
        except Exception as e:
            return format_error(e)
  • Pydantic BaseModel schema defining input parameters for flexsim_run_to_time tool. Validates target_time (must be positive) and fast_mode (optional, defaults to False).
    class RunToTimeInput(BaseModel):
        """Input for running to a specific time."""
        target_time: float = Field(..., gt=0)
        fast_mode: bool = Field(default=False)
  • Tool registration using FastMCP's @mcp.tool() decorator, which automatically registers flexsim_run_to_time with the MCP server and generates the tool schema from the RunToTimeInput type hint.
    @mcp.tool()
  • Helper function used by flexsim_run_to_time to format simulation time values (seconds) into human-readable strings (s/m/h).
    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"
  • Helper function that lazily initializes and returns the FlexSim controller instance. Used by flexsim_run_to_time to access the FlexSim API.
    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
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains what the tool does (runs simulation to target time) and mentions fast_mode behavior (maximum speed vs real-time GUI updates), but doesn't cover important aspects like whether this is a blocking operation, error conditions, or what happens if target_time is unreachable.

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 perfectly structured and concise: a clear purpose statement, parameter explanations, and a practical example. Every sentence adds value with no redundancy. The information is front-loaded with the core functionality stated first.

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

Completeness4/5

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

Given the tool has an output schema (which handles return values), no annotations, and good parameter coverage in the description, this is mostly complete. The main gap is lack of behavioral context about blocking nature, error handling, or simulation state implications, preventing a perfect score.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining both parameters: target_time ('Target simulation time in seconds') and fast_mode ('Run at maximum speed... Set to False for real-time GUI updates'). The example further clarifies target_time usage with a concrete value (3600 seconds = 1 hour).

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

Purpose5/5

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

The description clearly states the tool's purpose with a specific verb ('Run simulation') and resource ('until reaching target time'), distinguishing it from siblings like flexsim_step (single step) or flexsim_run (continuous run). The example reinforces this by showing a 1-hour simulation run.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool (to run simulation to a specific time) and includes guidance on fast_mode parameter usage. However, it doesn't explicitly contrast with alternatives like flexsim_step (for single steps) or flexsim_run (for continuous running), which would be needed for a perfect score.

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