Uses Gradio as the SDK framework for the FlexSim MCP server application interface.
Integrates with FlexSim simulation software through the FlexSimPy Python SDK, providing tools to control simulations, run experiments, execute FlexScript code, manipulate model nodes, and export results for manufacturing and warehouse analysis.
title: FlexSim MCP Server emoji: ⚙️ colorFrom: blue colorTo: green sdk: gradio sdk_version: "5.0.0" app_file: app.py pinned: false
FlexSim MCP Server (incl. FlexSimPy)
Control and automate FlexSim simulations via the Model Context Protocol (MCP). This repository exposes a FastMCP server that launches FlexSim (via FlexSimPy) and provides tools to open models, run/stop, step, query/set node values, evaluate FlexScript, export results, and more.
Why this matters
Bridges digital twins and AI assistants (Claude/Cursor) for manufacturing/warehouse analysis and “what-if” studies.
Demonstrates robust systems engineering: GUI process orchestration, async I/O, protocol handling, Windows quirks, and reproducible automation.
Design
Features
MCP server entry point:
mcp_server/flexsim_mcp.pyTools exposed:
Simulation control:
flexsim_open_model,flexsim_reset,flexsim_run,flexsim_run_to_time,flexsim_stop,flexsim_step,flexsim_get_timeModel/script:
flexsim_evaluate,flexsim_compile,flexsim_save_model,flexsim_new_modelNode access:
flexsim_get_node_value,flexsim_set_node_valueResults/stats:
flexsim_get_statistics,flexsim_export_results
Logging:
mcp_server/flexsim_mcp.logReproducible environment:
uv syncFlexSimPy build automation:
utility/build_automation.pyIntegration tests:
tests/integration/test_mcp_client.py(stdio-based MCP client)GUI sanity test:
utility/integration_test.pyConfigurable behavior via
config.tomland environment overrides
Requirements
OS: Windows
Python: 3.12 (default; configurable via
config.tomlorFLEXSIM_PYTHON_VERSION)Package manager:
uv(https://astral.sh)FlexSim:
Real runs require a local FlexSim installation (or repo-local mirror in
FlexSimDev/program)FlexSimPy SDK submodule is provided at
depends/FlexSimPy(see.gitmodules)
Quickstart
Guided setup (recommended)
Manual setup
Configuration
Primary configuration lives in config.toml (repo root). You can also override at runtime using environment variables.
Example (excerpt from config.toml):
Environment overrides (see utility/config.py):
FLEXSIM_CONFIG_PATH– path to an alternateconfig.tomlFLEXSIM_INSTALL_PATH– override FlexSim program pathFLEXSIM_PYTHON_VERSION– override Python version for FlexSimPyFLEXSIM_LOG_LEVEL– override logging level
Running the MCP server
Two modes:
Test mode (interactive; no stdio protocol)
MCP stdio mode (default when no flags are passed)
Client configuration (for Claude/Cursor/etc.):
Example tool calls (JSON-RPC via MCP)
Open a model
Run to time and read time
Evaluate FlexScript
Get/Set node value
More FlexScript examples and behavior: see eval-flexscript.md.
Tests
Integration tests (stdio client; verifies tools and basic run sequence):
GUI sanity test (manual, interactive menu):
Repository structure
mcp_server/flexsim_mcp.py— FastMCP server and FlexSimPy controller logic (entry point)utility/config.py— configuration loader with env overridesbuild_automation.py— FlexSimPy build/install orchestration (MSBuild resolution, .pyd install)copy_flexsim.py— copies a FlexSim installation intoFlexSimDev/(usesflexsim.src_path)integration_test.py— GUI-backed sanity test (suppresses CEF stderr, safe cleanup)utility.py— helpers: suppress stderr, kill FlexSim processes, force exit
tests/integration/test_mcp_client.py— async stdio client that starts the server and calls toolsREADME.md— test descriptions and sample outputs
depends/FlexSimPy— FlexSimPy SDK submoduleFlexSimDev/program— optional repo-local mirror of FlexSim installconfig.toml,mcp_server_config.json,AGENTS.md,eval-flexscript.md
Batch Experiment Orchestrator (Design)
A high-impact enhancement to run parameter sweeps with replications, gather metrics, and export a unified summary.csv (and manifest.json), enabling “what-if” studies at scale.
Design document:
Batch_Experiment_Orchestrator.mdStatus: design in-repo; implementation planned (not yet in
flexsim_mcp.py)MVP tool (planned):
flexsim_run_experimentswith parameter list, seeds/replications, run_to_time, stats, artifact_dir
Troubleshooting
FlexSim not found:
Update
flexsim.install_pathinconfig.tomlor setFLEXSIM_INSTALL_PATHOptionally use
utility/copy_flexsim.pyto mirror an existing install intoFlexSimDev/
FlexSimPy unavailable:
Check status:
uv run python utility/build_automation.py --statusRebuild for the active Python version and ensure the
.pydis installed
Stdio client issues:
Ensure you run the server without
--test-modewhen using stdio clientsCheck
mcp_server/flexsim_mcp.logfor details
GUI noise (CEF) or shutdown issues:
The utilities suppress CEF stderr and force a safe interpreter exit when needed