Skip to main content
Glama
SethGame

FlexSim MCP Server

by SethGame

flexsim_new_model

Create a new blank simulation model to build manufacturing or warehouse digital twins for analysis and parameter studies.

Instructions

Create a new blank model.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler implementation for flexsim_new_model tool. Gets the FlexSim controller, executes newmodel() FlexScript command, and returns success/error message.
    @mcp.tool()
    async def flexsim_new_model() -> str:
        """Create a new blank model."""
        try:
            controller = await get_controller()
            controller.evaluate("newmodel()")
            return "✓ New blank model created"
        except Exception as e:
            return format_error(e)
  • Helper function get_controller() that retrieves or creates the FlexSim controller instance, used by flexsim_new_model to access the simulation.
    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
  • Helper function format_error() that formats exceptions into user-friendly error messages, used by flexsim_new_model for error handling.
    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}"
  • FastMCP server initialization at line 216 where the MCP server instance 'mcp' is created, which is used to register the flexsim_new_model tool via the @mcp.tool() decorator.
    mcp = FastMCP("flexsim_mcp", lifespan=lifespan)
  • Documentation entry for flexsim_new_model tool in the Model & Script section, describing it as 'Create blank model'.
    | `flexsim_new_model` | Create blank model |

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