cx-programmer-mcp
cx-programmer-mcp
一个用于以编程方式编辑欧姆龙 CX-Programmer 梯形图逻辑程序的 MCP(模型上下文协议)服务器 —— 无需打开图形界面。
适用于 OMRON CJ/CP/CS 系列 PLC 的 .CXP / .CXT 文件。
适用范围:仅包括程序、段(Section)、梯形图助记符、梯级注释和符号表。
不涉及 PLC 设置、I/O 表、网络配置、密码或传输到 PLC。
工作原理
OMRON 将 .CXP 定义为 .CXT 的压缩版本。.CXT 是 CX-Programmer 可以导入/导出的基于文本的格式。该服务器读取 .CXP 或 .CXT,在内存中编辑程序,然后将结果保存为 .CXT / .CXP,以便在部署到真实 PLC 之前在 CX-Programmer 中进行审查。
使用 Python MCP SDK v2(MCPServer),采用 stdio 传输。
Related MCP server: TwinCAT Validator MCP Server
系统要求
Python >= 3.10
uv 包管理器
已安装 CX-Programmer(用于打开
.cxp输出并下载到 PLC)
安装
cd cx-programmer-mcp
uv sync
uv run cx-programmer-mcp项目模板设置
内置模板(CJ2M CPU11)
已包含原生 CJ2M CPU11 模板。生成空白项目:
uv run python make_template.py其他 PLC 型号
每种 PLC 型号都有不同的二进制配置。对于 CJ2M CPU11 以外的型号:
在您的机器上打开 CX-Programmer
为您的 PLC 型号(CP1L、CS1G 等)创建一个新的空项目
将其保存为
.CXP或.CXT将文件放入
project/文件夹更新
make_template.py以指向您的文件:
SRC = Path(__file__).parent / "project" / "your_blank_template.cxp"运行
make_template.py一次
示例程序
附带一个示例梯形图程序:project/example_basic_io.cxp
它演示了一个简单的传送带/IO 控制器,具有以下功能:
手动输出控制(保持运行)
通过 RTC 定时自动运行(可通过 DM 配置)
基于定时器的持续时间
SET/RSET 锁存
紧急复位
要从源码重新构建:
uv run python make_template.py
uv run python build_program.py输出:project/example_basic_io.cxp —— 在 CX-Programmer 中打开以进行审查和下载。
审查程序
uv run python review_program.pyMCP 客户端配置
添加到您的 MCP 客户端配置(Claude Desktop、Kiro、Cline 等):
{
"mcpServers": {
"cx-programmer": {
"command": "uv",
"args": ["run", "cx-programmer-mcp"],
"cwd": "ABSOLUTE_PATH_TO_THIS_FOLDER"
}
}
}Windows 示例:
"cwd": "C:\\Users\\yourname\\cx-programmer-mcp"可选 —— 将文件访问限制到特定文件夹:
CX_MCP_ALLOWED_ROOTS=C:\PLC_Projects运行时计划更改
使用 CX-Programmer 在线模式 → PLC 内存 → DM 区:
DM | 功能 | 默认值 |
| 计划 1 —— 小时 | 6 |
| 计划 1 —— 分钟 | 0 |
| 计划 2 —— 小时 | 16 |
| 计划 2 —— 分钟 | 0 |
| 运行持续时间 x100ms | 300(=30 秒) |
更改立即生效,无需 PLC 重启。
运行测试
uv run pytest -q可用的 MCP 工具
工具 | 描述 |
| 将会话中加载 |
| 列出项目中的所有程序 |
| 列出程序中的区段 |
| 获取程序的完整梯形图内容 |
| 获取某区段中的梯级 |
| 替换梯级的指令 |
| 插入新梯级 |
| 删除梯级 |
| 设置梯级注释 |
| 以原子方式批量编辑多个梯级 |
| 添加新区段 |
| 重命名现有区段 |
| 添加或更新符号 |
| 清除某作用域中的所有符号 |
| 列出所有符号 |
| 校验 XML 结构 |
| 保存为 |
| 重新编码并保存为 |
| 列出可用的内置模板 |
| 从模板创建新的空白项目 |
| 校验助记符指令 |
| 梯级布尔仿真 |
| 分析梯级结构 |
| 完整的程序诊断 |
| 用于 AI 审查的语义快照 |
| 保存并在 CX-Programmer 中打开(Windows) |
项目结构
cx-programmer-mcp/
├── src/cx_programmer_mcp/ # MCP server and CXT library
│ ├── server.py # MCP tool definitions
│ ├── cxt.py # CXT/CXP parser and editor
│ ├── ladder.py # Mnemonic compiler and simulator
│ ├── diagnostics.py # Program diagnostics
│ ├── recipes.py # Reusable ladder patterns
│ ├── templates/ # Built-in PLC templates
│ │ └── CJ2M_CPU11.cxt # Native CJ2M CPU11 template
│ └── ...
├── tests/ # Test suite (16 tests)
├── project/ # Output folder
│ └── example_basic_io.cxp # Example ladder program
├── build_program.py # Builds the example ladder program
├── write_build.py # Regenerates build_program.py
├── make_template.py # Generates blank template from base
├── review_program.py # Prints program content to console
└── pyproject.toml注意事项
在下载到真实 PLC 之前,请务必在 CX-Programmer 中运行程序检查。
此工具仅编辑程序逻辑 —— I/O 表、单元设置和 PLC 配置保持模板原样不变。
输出
.CXP与 CX-Programmer 9.x 二进制兼容。对于其他 PLC 型号,请提供您自己的空白
.CXP模板(参见项目模板设置)。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceA Model Context Protocol server that enables seamless interaction between MCP clients (like Claude Desktop) and CODESYS V3 programming environments, allowing automation of project management, POU creation, code editing, and compilation tasks.131114MIT
- AlicenseBqualityCmaintenanceAn MCP server for validating, auto-fixing, and scaffolding TwinCAT 3 XML files using deterministic code quality tools and IEC 61131-3 OOP checks. It enables AI assistants to perform structural validation, apply safe fixes, and generate canonical code skeletons for industrial automation projects.1633MIT
- FlicenseNot gradedqualityAmaintenanceMCP server that connects AI assistants to Siemens TIA Portal via the Openness API. AI-assisted PLC programming, project management, hardware configuration, cross-reference analysis, and deployment. 16 tools, 166 actions.27
- AlicenseBqualityBmaintenanceMCP server that enables AI agents to read, edit, and create PLC projects in EcoStruxure Control Expert via COM automation.52MIT
Related MCP Connectors
MCP Server for Slima - AI Writing IDE for Novel Authors with AI Beta Reader.
MCP server for generating rough-draft project plans from natural-language prompts.
2,000+ MCP servers read at source level. Know what one does before you connect. Free, no key.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/BlackUppsss/Cx-Proggrammer-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server