control-expert-mcp
MCP server that enables AI agents to read, edit, and create PLC projects in EcoStruxure Control Expert via COM automation.
README
Control Expert MCP Server
An MCP server that connects AI agents (Claude Desktop, Claude Code, VS Code Copilot, or any MCP client) to a local EcoStruxure Control Expert (formerly Unity Pro) installation — so the AI can read, edit, and create PLC projects from scratch.
Inspired by tiaportal-mcp for Siemens TIA Portal. Where TIA Portal exposes the Openness API, Control Expert exposes the Unity Developer's Edition (UDE) COM automation server (PSBroker.PServerBroker) — this server drives it through pywin32 and exposes it as MCP tools over stdio.
AI agent (Claude, Copilot, ...) ──MCP/stdio──> control-expert-mcp ──COM──> Control Expert
What the AI can do
- Projects: create from scratch for any CPU in the hardware catalog (M340, M580, Premium, Quantum...), open/save
.stu/.sta, import/export.xef/.zef - Browse: tasks, sections, variables, DFB/DDT types, CPU/hardware info, build state
- Program: create/read/delete sections in ST, LD, FBD, SFC, IL; write logic by importing Control Expert XML (the AI reads an existing section's XML once and mirrors the schema — validated round-trip for all five languages)
- Hardware: walk the full bus → drop → rack → module topology, add/remove IO modules by catalog part number, change the CPU
- Modbus / DTMs (validated live on M580): browse the DTM topology, add slave DTMs (
add_dtm("Modbus Device", ..., parent_dtm="BMEP58_ECPU_EXT")— the protocol id isModbusand is auto-tried), set device IP addresses, read the scanner state (get_dtm_control_parameters), and add Modbus scan requests (read/write addresses + sizes) by editing the master DTM dataset throughget_master_dtm_dataset/set_master_dtm_dataset— aManagedModbusRequesttemplate with the numbering rules is built into the tool description; a written scan line buildsbuilt_okand shows up as aModbusScanLinein the scanner config - Networks (Premium/Quantum): create logical Ethernet networks and set their IP service configuration
- Variables: list/create/update/delete global variables incl. type, comment, address (
%MW...), initial value - Build: analyze and build the project, get the resulting build state
- UI: pop the Control Expert window open so a human can watch or take over
- Online (opt-in): connect to PLC/simulator, download/upload, run/stop
Requirements
- Windows with EcoStruxure Control Expert (or Unity Pro) installed and licensed — tested against Control Expert 14.0, but any version that registers
PSBroker.PServerBroker.1should work (the UDE automation server ships with Control Expert itself; the separate UDE package is only needed for documentation) - Python 3.10+ with
pywin32 - The server must run on the same machine as Control Expert (DCOM remoting is possible but not configured here)
Install
cd control-expert-mcp
python -m venv .venv
.venv\Scripts\pip install -e .
Hook up an AI client
The server speaks MCP over stdio. Point your client at the venv's Python:
Claude Desktop
%APPDATA%\Claude\claude_desktop_config.json (see samples/claude_desktop_config.json):
{
"mcpServers": {
"control-expert": {
"command": "C:\\path\\to\\control-expert-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "control_expert_mcp"]
}
}
}
Claude Code
claude mcp add control-expert -- C:\path\to\control-expert-mcp\.venv\Scripts\python.exe -m control_expert_mcp
VS Code (GitHub Copilot agent mode)
.vscode/mcp.json (see samples/vscode-mcp.json):
{
"servers": {
"control-expert": {
"type": "stdio",
"command": "C:\\path\\to\\control-expert-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "control_expert_mcp"]
}
}
}
Tools
| Tool | Purpose |
|---|---|
get_status |
Server version, open project, CPU, build state |
open_project |
Open .stu / .sta / .xef / .zef |
new_project |
Create a project for a CPU (e.g. BMX P34 2020 + 02.70) |
save_project / close_project |
Persist / close (close discards unless save=true) |
build_project / analyze_project |
Build or analyze; returns resulting build state |
get_project_structure |
Tasks, sections (+language), events, fct modules |
list_variables |
Variables with type/comment/address/initial value |
create_variable / update_variable / delete_variable |
Variable editing |
read_section |
Section logic as Control Expert XML |
write_st_logic |
Write ST logic as plain IEC text (no XML) — creates or replaces a section, with inline variable declarations |
get_language_reference |
Authoring guide + validated example for ST/LD/FBD/SFC/IL — the exchange-XML structure rules an AI client needs to write graphical logic (FBD pin-geometry rule, LD line/cell model, SFC chart layout) |
create_section / delete_section |
Section management (ST/LD/FBD/SFC/IL) |
create_task |
Add MAST/FAST/AUX/SAFE task |
import_xml |
The main write path — import section logic, variables, DFB/DDT types, configuration, or whole-project exchange files (inline XML or file) |
export_xml |
Export variables / program / configuration / one DFB / one section as XML |
export_project |
Full application export to .xef / .zef |
list_data_types |
DFB + DDT types |
get_hardware |
CPU + bus → drop → rack → module tree |
add_io_module / remove_io_module |
Add/remove rack modules by part number + catalog version (e.g. BMX DDI 1602 + 02.00) |
add_drop / add_rack |
Build out remote drops/racks (e.g. an X80 EIO drop + BME XBP 1200 rack on an M580 RIO bus) |
change_cpu |
Swap the CPU reference |
list_animation_tables / create_animation_table / delete_animation_table |
Watch/animation tables (accepts hierarchical paths like Pump1.Speed, SFC_Demo.S_Init.x) for monitoring/forcing values online |
list_dtms |
DTM Browser topology with names, types, addresses |
add_dtm / delete_dtm |
Add communication DTMs or slave devices (e.g. Modbus Device under the M580 CPU DTM) |
set_dtm_address |
Set a slave's IP / bus address (+ optional gateway/subnet — fixes the "IP Address and Gateway address are not in the same domain" build warning) |
configure_cpu_ethernet |
M580 CPU embedded Ethernet: IP/subnet/gateway + Security-screen services (tftp/eip/dhcp_bootp/ftp/web/snmp). Enabling tftp+eip+dhcp_bootp clears the remote-EIO CRA build error |
get_dtm_control_parameters / set_dtm_control_parameters |
Modbus TCP I/O scanner config XML (CetControlParameter* schema): IP, unit id, timeouts, ModbusTcpRequest scan lines |
get_dtm_dataset / set_dtm_dataset |
A slave DTM's own dataset (identity + bus address) |
get_master_dtm_dataset / set_master_dtm_dataset |
The master/CPU DTM dataset (via ZEF round-trip) — <SlaveDevices>/<ManagedModbusRequestList> holds the Modbus scan lines; write a ManagedModbusRequest node to add a request |
list_networks / add_network / set_network_ip |
Logical networks on Premium/Quantum |
show_ui |
Make the Control Expert window visible |
plc_* (opt-in) |
Online: setup/connect/disconnect/state/transfer/run/stop |
How the AI writes logic
Program sections are exchanged as Control Expert XML. An ST section looks like:
<STExchangeFile>
<fileHeader company="Schneider Automation" product="Control Expert V14.0 - 190112"
dateTime="date_and_time#2026-6-11-1:0:0" content="Structured source file"
DTDVersion="41"></fileHeader>
<contentHeader name="Project" version="0.0.000"></contentHeader>
<program>
<identProgram name="Logic01" type="section" task="MAST"></identProgram>
<STSource>
IF StartButton AND NOT StopButton THEN
MotorRun := TRUE;
ELSE
MotorRun := FALSE;
END_IF;
</STSource>
</program>
</STExchangeFile>
import_xml(kind="section", xml_content=...) creates the section if it doesn't exist, or deletes-and-replaces it on conflict. The agent should declare referenced variables first (create_variable) or include a <dataBlock>, then build_project to validate.
Online tools (live PLC / simulator) — disabled by default
Tools that touch a controller (plc_connect, plc_transfer, plc_command, ...) are not registered unless you set the environment variable:
CE_MCP_ENABLE_ONLINE=1
Starting/stopping a PLC or downloading an application affects the physical process. Only enable this on test benches or with the simulator, and keep a human in the loop.
Simulator commissioning (validated end to end): launch the PLC simulator first — start_simulator or PLC_Simulator\sim.exe from the Control Expert install (it sits in the tray) — then plc_setup_connection("simulator", "127.0.0.1") → plc_connect("simulator") → plc_transfer("pc_to_plc") → plc_command("run"). The project must build clean (built_ok) before download. plc_state reports connection + run/stop and whether PC == PLC.
Known limitation: a freshly started simulator with no station loaded (
plc_state=no_conf) rejectsplc_transferwith "Family check failed" — the API download (unlike the Control Expert GUI's) requires the sim to already have a station of a matching family. Seed it once by transferring any project from the Control Expert GUI (PLC → Simulation Mode → Connect → Transfer); the loaded station persists while sim.exe runs, and all API downloads work from then on (stop the PLC first — transfer to a running PLC fails).
Troubleshooting
Catalog object not foundonnew_project— the CPU part number/version must exactly match the hardware catalog of your Control Expert version (spacing matters:BMX P34 2020, firmware like02.70is required).application object reference is not found in the catalogonadd_io_module— same rule for modules: the catalog version is mandatory (02.00for most M340 IO modules,01.00for racks/power supplies).new_projectfails with a bareException occurredfor a CPU family — your Control Expert license/DTM library probably doesn't include that platform. The error carries no description; test the same CPU in the Control Expert GUI to confirm.add_dtmsays "protocol Id parameter is empty or invalid" / "Impossible to create a new DTM object" — slave DTMs need the FDT protocol name as protocol_id (Modbusfor the generic Modbus TCP device; the server auto-triesModbusandEtherNet/IPwhen empty) and a device_type_name that exactly matches the DTM catalog (Modbus Device). List the catalog names withtools/list_dtm_catalog.py.set_master_dtm_datasetcrashes the server (RPC failed) — almost always malformed request XML; in particularrequestUniqueIDmust be a fresh GUID, not an integer. Mirror the validated template in the tool description exactly.Write access mode is already reserved by another client— Control Expert (the GUI) or another automation client has the project open for writing. Close it there first. The server holds one write token per session by design.- Broker creation fails — Control Expert isn't installed, or its COM registration is broken (re-register by repairing the installation).
- First call is slow —
open_project/new_projectstart the Unity server process and can take 30–120 s for large projects. Configure generous tool timeouts in your client. - Import fails with
Invalid file— the XML doesn't match the exchange schema. Export a similar object first (read_section,export_xml) and mirror its structure, includingfileHeader/contentHeader.
Architecture notes
- All COM calls run on a single dedicated STA worker thread (COM apartment affinity); MCP tool calls are marshalled onto it (the dispatcher is reentrant — nested bridge calls on the worker thread execute directly).
- Hardware and DTM objects expose their members on secondary dual interfaces (
IProject3,IConfiguration2,IBus,IModule,IPServerDtm*, ...) that the default dispinterface doesn't include. The bridge QIs each object with IIDs harvested fromHKCR\Interfaceand wraps the result as IDispatch (_qi), which is the only way to reachDTMRoot,InternalBuses,AddChild, etc. from late-bound clients. - The write-access token (
app.Project(1)) is acquired once per session and cached; failed-call tracebacks are stripped so they can't pin COM references and deadlockProjectClose. Projectis a parameterized COM property — it is invoked with explicitDISPATCH_PROPERTYGETflags because pywin32 dynamic dispatch can't call it.- Import temp files get the extension matching the XML root element (
STExchangeFile→.xst,VariablesExchangeFile→.xsy, ...) because Control Expert picks the parser from the extension. - Enum constants (languages, export options, PLC commands...) were extracted from
PServer.tlb— see src/control_expert_mcp/constants.py and tools/dump_tlb_enums.py.
Disclaimer
Not affiliated with Schneider Electric. The UDE automation interface is provided by Schneider "as is" and is no longer commercialized; this project drives it at your own risk. Never point online tools at production equipment without qualified supervision.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。