PLECS-MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PLECS-MCPLoad the buck converter model and run a simulation, then summarize the inductor current"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PLECS-MCP
An MCP server that exposes the complete Plexim PLECS Standalone JSON-RPC interface as MCP tools, built on fastmcp.
Highlights:
One MCP tool per RPC method (22/22 on PLECS 5.0.6), plus
plecs_rpcandplecs_batchescape hatchesplecs_connectstarts PLECS automatically (macOS / Windows / Linux) when the RPC port is closedResults are structured JSON; big arrays are auto-written to disk instead of flooding the context
Read-only RPC calls run concurrently with a simulation; blocking/mutating calls are serialized
Write guardrails: install dirs are refused, stray paths need
PLECS_MCP_ALLOWED_ROOTS, overwrites needoverwrite=trueIrreversible operations (
protect,crash) requireconfirm=true
Requirements
PLECS Standalone running locally
RPC enabled in Preferences → RPC (default port
1080)Python 3.10+ (tested with 3.13)
Related MCP server: SimuBridge
Install
cd "/Users/guohuawei/Workspace/AI Usecase/PLECS-MCP"
uv venv --python 3.13 .venv
uv pip install -e . --python .venv/bin/pythonRun
.venv/bin/python -m plecs_mcp # stdio (local agents)
.venv/bin/python -m plecs_mcp --transport http --port 8765 # remote agents
.venv/bin/plecs-mcpCodex (~/.codex/config.toml):
[mcp_servers.plecs]
command = "/Users/guohuawei/Workspace/AI Usecase/PLECS-MCP/.venv/bin/python"
args = ["-m", "plecs_mcp"]Claude Desktop / Cursor (mcpServers JSON):
{
"mcpServers": {
"plecs": {
"command": "/Users/guohuawei/Workspace/AI Usecase/PLECS-MCP/.venv/bin/python",
"args": ["-m", "plecs_mcp"]
}
}
}Transports: stdio (default), http, sse, streamable-http.
Binding a non-loopback host is refused unless PLECS_MCP_ALLOW_REMOTE=1 is set (there is no auth).
Quickstart (3 minutes)
.venv/bin/python examples/quickstart.py --model /path/to/model.plecs
.venv/bin/python examples/quickstart.py --model /path/to/model.plecs \
--analysis "Loop Gain (AC Sweep)"Runs connect → load → simulate (summary) → close, prints per-signal min/max/mean/rms and,
for AC sweeps, gain crossover + phase margin. Without --model it uses PLECS_EXAMPLE_MODEL
or a bundled PLECS demo.
Configuration
Resolution order: environment variables → config.yml → defaults.
config.yml is looked up at $PLECS_MCP_CONFIG, then ./config.yml, then the repo root.
plecs:
host: "127.0.0.1"
port: 1080
timeout: 30Variable | Default | Description |
| – | Explicit path to |
|
| Localhost only (PLECS restriction) |
|
| Must match the PLECS preference |
|
| Read timeout for non-simulation calls |
|
|
|
|
| Above this, results are saved and summarised |
|
| Above this, scope CSV is saved and summarised |
|
| Destination for auto-saved results |
|
| Write roots ( |
|
| RPC timing/error logging on stderr |
| – | Allow non-loopback HTTP bind |
| auto-detect | PLECS binary/bundle used by auto-start (alias: |
Auto-start
plecs_connect(auto_start=True) (default) probes host:port; if the port is closed it locates
the newest install for the host OS, launches it, and polls the port for startup_timeout
(default 30 s):
Host | Discovery | Command |
macOS |
|
|
Windows |
| spawn |
Linux |
| spawn |
Before launching it checks whether a PLECS process already exists (pgrep / tasklist); if so it
skips the launch and tells you to enable Preferences → RPC instead of waiting 30 s.
Overrides: the app_path argument, PLECS_EXECUTABLE, PLECS_APP_PATH.
PLECS RPC is localhost-only, so the MCP server and PLECS must run on the same machine.
Tools
Tool | RPC method | Notes |
|
| Handshake; auto-starts PLECS, returns version + |
|
| Capability discovery |
|
| PLECS help text |
|
| Licence hints, open models, run state |
|
| Returns |
|
| Refuses when this session changed the model ( |
|
|
|
|
| Base64 JSON → parsed; |
|
| Parameter value (string) or all parameters |
|
| Expression string; marks the model dirty |
|
| optStruct or list; |
|
| Name property; |
|
| Switch vector built from |
|
| HoldTrace / RemoveTrace / ClearTraces / SaveTraces / LoadTraces |
|
|
|
|
| Requires Coder; diagnostics are surfaced verbatim |
|
| Atomic subsystems only |
|
| Experimental: wire shape unknown on 5.0.6 |
|
| Raw lines + parsed |
|
| Runtime counters |
|
| Global FMU co-simulation switch |
|
| Appends the demo signature (modifies the file) |
|
| Irreversible once saved; |
|
| Terminates PLECS; |
| any | Several RPC calls in one tool call, per-call errors inline |
| any | Raw passthrough |
Return shape
Every tool returns a JSON object (structured content):
dict results as-is; scalars/arrays wrapped as
{"result": ...}plecs_list_methods→{"methods": [...]};plecs_compare→{"diff": [...], "entries": [...]}plecs_connect→{"ok": true, "capabilities": {...}, ...}or{"ok": false, "hints": [...]}plecs_batch→{"count": n, "results": [{"ok": ..., "result"|"error": ...}]}
Data policy (large results)
Situation | Behaviour |
Simulation above | Full JSON saved under |
| Raw arrays replaced by |
Scope CSV above | Full CSV saved, response has |
| Applied client-side (PLECS ignores its own range options) |
| Base64 MAT decoded and written to |
PNG payloads | Written to |
Writes are refused inside /Applications, /System, /Library, /usr, /bin, /sbin, /etc,
and outside PLECS_MCP_ALLOWED_ROOTS. Existing files are never overwritten without overwrite=true.
Concurrency
Measured on PLECS 5.0.6: statistics returns in 0.01 s while a 0.55 s simulation is running,
and a second simulate still waits for the first. The client mirrors that:
read-only calls share a read lock and run concurrently with a simulation
simulate/analyze/codegen/exportfmu/runScripttake a single "blocking" slot (PLECS allows one)load/close/save/set/scope/protecttake the exclusive write lock, so state never changes mid-run
Verified behaviour (PLECS 5.0.6)
simulatereturnsValuesas signals × time over JSON-RPC; summaries normalise both orientations.Models without top-level outports return
{"Time": [], "Values": []}and a summarynote.Only nested
{"SolverOpts": {"TimeSpan": ...}}is honoured; flat{"StopTime": ...}is silently ignored.SolverOpts.Timeoutworks for bothsimulateandanalyze;AnalysisOpts.Timeoutis rejected.analyzeneeds the analysis Name property;plecs.scopesupports noExportCSV/GetCursorData.plecs.webserverignoresTimeRange/Size; slicing and decimation happen in this server.plecs.save(model, save_as)renames the open model; the session registry follows the rename.plecs.protect(path)takes one subsystem path, returns 0, is idempotent, and only becomes permanent on save.plecs.exportfmu(path)accepts one path and requires an atomic subsystem.plecs.codegen(model)runs and returns Coder diagnostics as an RPC error string.plecs.runScriptis listed bysystem.listMethodsbut every wire shape tried returnsserver error: invalid method parameters— kept as experimental with aparamsoverride.Business errors still return HTTP 200; the JSON
errorfield becomes a tool error.trust_env=False: macOS system proxies can hijack127.0.0.1:1080(HTTP 502), so PLECS is never reached through a proxy.
Known limitations
The RPC model tree exposes outport names and positions but no port index, so channel
iis not auto-labelled;summary.outportsis provided instead of guessing..tracefiles (scope SaveTraces) use a private format and are not parsed.Gain crossover/phase margin only make sense for loop-gain AC sweeps; other analysis kinds are labelled.
Auto-start picks the newest install for the host OS: macOS
/Applications/PLECS*.app, Windows%ProgramFiles%\Plexim\*\plecs.exe, LinuxplecsonPATHor/opt/plecs*/plecs. Other platforms returnunsupported-platformand require a manual start.One MCP server instance manages one PLECS instance (localhost).
Example workflows
# parameter sweep (PLECS-native parallel)
plecs_simulate(model, options=[{"ModelVars": {"R": 10}}, {"ModelVars": {"R": 47}}], summary=True)
# Bode / loop gain
plecs_analyze(model, "Loop Gain (AC Sweep)", summary=True)
# → responses[0].gain_crossover_hz / phase_margin_deg / stable
# scope export with client-side slicing
plecs_webserver("getScopeCsv", [f"{model}/Scope"], time_range=[0, 1e-3], decimate=10)
# state space at one switch combination
plecs_state_space(model, {"FET": 1, "D": 0})
# cheap multi-read
plecs_batch([{"method": "plecs.get", "params": [f"{model}/L1", "L"]},
{"method": "plecs.get", "params": [f"{model}/C1", "C"]}])Error table
Symptom | Meaning | Next step |
| RPC port closed | Run |
| Method missing in this build |
|
| Invalid parameters | Check the tool schema; for |
| Wrong analysis name | Use the Name property from |
| Unsupported scope command | Use |
| A proxy intercepted localhost | Client already uses |
| File exists | Pass |
| Write blocked | Choose a path under |
Tests
.venv/bin/python -m pytest -q # 50 testsUnit: base64/model tree, summary maths, config precedence, paths, locks, app discovery/launch
Surface: all 26 tools registered/documented; destructive tools need confirmation; batch/limits/guards
Integration: when
127.0.0.1:1080is reachable, exercises connect/load/tree/get/simulate/summary/CSV on/tmpcopies of the bundled demos (user models are never touched)
CI (.github/workflows/ci.yml) runs the unit/surface suite on Python 3.10 and 3.13; integration tests
skip automatically when PLECS is not installed.
Layout
src/plecs_mcp/client.py JSON-RPC client (RW lock, timeouts, logging, no proxy)
src/plecs_mcp/config.py config.yml + environment resolution
src/plecs_mcp/paths.py write guardrails and output directories
src/plecs_mcp/session.py model registry (path, dirty flag, rename tracking)
src/plecs_mcp/codec.py base64 decoding, tree/compare parsing, CSV slicing
src/plecs_mcp/summary.py time-series statistics, Bode margins, analysis kinds
src/plecs_mcp/launcher.py per-OS discovery/launch, port polling, process check
src/plecs_mcp/server.py 26 MCP tools
examples/quickstart.py end-to-end smoke test
tests/ unit + surface + integrationThis server cannot be deployed
Maintenance
Related MCP Connectors
Protocol-native energy infrastructure orchestration for AI data centers. Provides 46 MCP tools across 8 grid protocols (IEC-61850, DNP3, Modbus, OCPP, OpenADR, IEEE 2030.5, IEC 60870-5-104, ICCP) with 5 core API primitives: connect, dispatch, settle, comply, and intel. Enables AI agents to programmatically interact with substations, grid interfaces, and energy assets for real-time workload-grid coordination.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
214 tools for AI agents over one MCP endpoint: image, video, audio, 3D, data, storage, mail, GPUs.
MCP facade over the Nebelus Construction API. ~48 tools give full agent build parity: create/update/probe agents, edit graphs, attach knowledge and vector stores, wire connectors, set governance policies and locked guardrails, enable grounding-trace, and read deployment wiring. Purpose-built for regulated industries: data residency is enforced per region (EU / GCC-KSA), with PII controls and an audit trail. Agents are created as drafts — no deploy tool is exposed over MCP by design; publishing happens in the Nebelus console.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server that connects any AI agent to MATLAB — execute code, async jobs, interactive Plotly plots, custom tools, and monitoring dashboard204MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to control MATLAB Simulink models through natural language, providing tools for model creation, block management, wiring, simulation, and more via a local MCP backend.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to automate COMSOL Multiphysics simulations, including model management, geometry building, physics configuration, meshing, solving, and results visualization via the MCP protocol.MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI clients to securely control and interact with a local Windows machine through 218 configurable tools for files, Git, processes, Windows UI, browser automation, WSL, Office, recovery, skills, and child MCP servers.7 npmMIT