Skip to main content
Glama
SethGame

FlexSim MCP Server

by SethGame

flexsim_open_model

Open FlexSim simulation model files to analyze manufacturing and warehouse digital twins, run parameter studies, and manipulate models in real-time.

Instructions

Open a FlexSim model file.

Args:
    model_path: Path to .fsm or .fsx file

Example:
    model_path="C:/Models/warehouse.fsm"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler function for flexsim_open_model tool. Uses @mcp.tool() decorator, gets FlexSim controller, opens the model file asynchronously, and returns formatted result with model name and time.
    @mcp.tool()
    async def flexsim_open_model(params: OpenModelInput) -> str:
        """Open a FlexSim model file.
    
        Args:
            model_path: Path to .fsm or .fsx file
    
        Example:
            model_path="C:/Models/warehouse.fsm"
        """
        try:
            controller = await get_controller()
            loop = asyncio.get_event_loop()
            await loop.run_in_executor(None, controller.open, params.model_path)
    
            model_name = Path(params.model_path).stem
            time = controller.time()
    
            return f"✓ Opened: {model_name}\nTime: {format_time(time)}"
        except Exception as e:
            return format_error(e)
  • Input validation schema for flexsim_open_model. Uses Pydantic BaseModel to validate model_path is a non-empty string with .fsm or .fsx extension and that the file exists.
    class OpenModelInput(BaseModel):
        """Input for opening a model."""
        model_path: str = Field(..., min_length=1)
    
        @field_validator("model_path")
        @classmethod
        def validate_path(cls, v: str) -> str:
            path = Path(v)
            if path.suffix.lower() not in [".fsm", ".fsx"]:
                raise ValueError("Model must be .fsm or .fsx file")
            if not path.exists():
                raise ValueError(f"File not found: {v}")
            return str(path.resolve())
  • FastMCP server instance creation where tools are registered. The flexsim_open_model handler is registered via @mcp.tool() decorator on line 223.
    mcp = FastMCP("flexsim_mcp", lifespan=lifespan)
  • Controller management helper that lazily initializes FlexSim controller on first use, ensuring singleton pattern with async lock protection.
    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 functions used by flexsim_open_model: format_time() converts seconds to human-readable format, format_error() creates user-friendly error messages from exceptions.
    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"
    
    
    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 states the action ('Open a FlexSim model file') but lacks behavioral details: it doesn't specify if this loads the model into memory, requires specific permissions, affects other operations (e.g., closing previous models), or has side effects like initialization. The example adds minimal context but is insufficient for a mutation tool.

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 front-loaded with the core purpose in the first sentence, followed by a clear Args section and a practical example. Every sentence earns its place: no fluff, and the structure (purpose, parameters, example) is logical 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 1 parameter with low schema coverage and an output schema (which reduces need to explain returns), the description is minimally adequate. It covers the parameter semantics well but lacks behavioral context (e.g., what 'opening' entails, error handling). For a tool that likely mutates state (opening a model), more detail on effects and usage context 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?

With 0% schema description coverage, the description must compensate, which it does effectively. It explains 'model_path' as 'Path to .fsm or .fsx file' and provides an example with a concrete path, adding meaning beyond the schema's generic 'Model Path' title. However, it doesn't detail path format constraints (e.g., absolute vs. relative, network paths).

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 ('Open') and resource ('FlexSim model file'), making the purpose immediately understandable. It distinguishes from siblings like 'flexsim_new_model' (creates new) and 'flexsim_save_model' (saves existing), though not explicitly. However, it doesn't fully differentiate from all siblings (e.g., 'flexsim_compile' might also involve opening).

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., if a model must be opened before running or evaluating), nor does it specify when not to use it (e.g., for new models vs. existing ones). The example shows usage but lacks contextual rules.

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