Skip to main content
Glama
SethGame

FlexSim MCP Server

by SethGame

flexsim_get_statistics

Retrieve simulation statistics and performance metrics from FlexSim models to analyze manufacturing and warehouse digital twin results.

Instructions

Get simulation statistics and performance metrics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main implementation of flexsim_get_statistics tool. It retrieves simulation performance metrics including current time, run speed, number of objects, and events processed by evaluating a FlexScript against the FlexSim controller.
    @mcp.tool() async def flexsim_get_statistics() -> str: """Get simulation statistics and performance metrics.""" try: controller = await get_controller() stats_script = """ { "time": getmodeltime(), "run_speed": get(runspeed()), "objects": Model.subnodes.length, "events": geteventsprocessed() } """ result = controller.evaluate(stats_script) return f"Statistics:\n```json\n{result}\n```" except Exception as e: return format_error(e)
  • The tool is registered with the MCP server using the @mcp.tool() decorator, which automatically makes it available to MCP clients.
    @mcp.tool() async def flexsim_get_statistics() -> str:
  • Helper function format_error() used by flexsim_get_statistics to provide user-friendly error messages when exceptions occur.
    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}"
  • Helper function get_controller() used by flexsim_get_statistics to obtain or create the FlexSim controller instance with async locking for thread safety.
    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