cx-programmer-mcp

cx-programmer-mcp

MCP server for editing OMRON CX-Programmer ladder logic projects, supporting sections, rungs, symbols, and program validation via natural language.

Category
访问服务器

README

cx-programmer-mcp

An MCP (Model Context Protocol) server for editing OMRON CX-Programmer ladder logic programs programmatically — without opening the GUI.

Works with .CXP / .CXT files for OMRON CJ/CP/CS series PLCs.

Scope: Programs, Sections, Ladder Mnemonics, rung comments, and symbol table only.
Does not touch PLC Setup, I/O Table, network configuration, passwords, or transfer to PLC.


How it works

OMRON documents .CXP as a compressed version of .CXT. .CXT is a text-based format that CX-Programmer can import/export. This server reads .CXP or .CXT, edits the program in memory, then saves the result as .CXT / .CXP for review in CX-Programmer before deploying to a real PLC.

Uses Python MCP SDK v2 (MCPServer) with stdio transport.


Requirements

  • Python >= 3.10
  • uv package manager
  • CX-Programmer installed (to open .cxp output and download to PLC)

Installation

cd cx-programmer-mcp
uv sync
uv run cx-programmer-mcp

Project Template Setup

Built-in template (CJ2M CPU11)

A native CJ2M CPU11 template is included. Generate a blank project:

uv run python make_template.py

Other PLC models

Each PLC model has a different binary configuration. For models other than CJ2M CPU11:

  1. Open CX-Programmer on your machine
  2. Create a new empty project for your PLC model (CP1L, CS1G, etc.)
  3. Save it as .CXP or .CXT
  4. Place the file in the project/ folder
  5. Update make_template.py to point to your file:
SRC = Path(__file__).parent / "project" / "your_blank_template.cxp"
  1. Run make_template.py once

Example Program

An example ladder program is included: project/example_basic_io.cxp

It demonstrates a simple conveyor/IO controller with:

  • Manual output control (hold-to-run)
  • Scheduled auto run via RTC (configurable via DM)
  • Timer-based duration
  • SET/RSET latch
  • Emergency reset

To rebuild it from source:

uv run python make_template.py
uv run python build_program.py

Output: project/example_basic_io.cxp — open in CX-Programmer to review and download.


Review Program

uv run python review_program.py

MCP Client Configuration

Add to your MCP client config (Claude Desktop, Kiro, Cline, etc.):

{
  "mcpServers": {
    "cx-programmer": {
      "command": "uv",
      "args": ["run", "cx-programmer-mcp"],
      "cwd": "ABSOLUTE_PATH_TO_THIS_FOLDER"
    }
  }
}

Windows example:

"cwd": "C:\\Users\\yourname\\cx-programmer-mcp"

Optional — restrict file access to specific folders:

CX_MCP_ALLOWED_ROOTS=C:\PLC_Projects

Runtime Schedule Changes

Use CX-Programmer Online Mode → PLC Memory → DM Area:

DM Function Default
D0 Schedule 1 — hour 6
D1 Schedule 1 — minute 0
D2 Schedule 2 — hour 16
D3 Schedule 2 — minute 0
D4 Run duration x100ms 300 (=30s)

Changes take effect immediately without PLC restart.


Run Tests

uv run pytest -q

Available MCP Tools

Tool Description
load_project Load a .cxp or .cxt file into a session
list_programs List all programs in the project
list_sections List sections in a program
get_program_context Get full ladder content of a program
get_rungs Get rungs in a section
replace_rung Replace a rung's instructions
insert_rung Insert a new rung
delete_rung Delete a rung
set_rung_comment Set a rung comment
patch_program Batch multiple rung edits atomically
create_section Add a new section
rename_section Rename an existing section
upsert_symbol Add or update a symbol
clear_symbols Clear all symbols in a scope
list_symbols List all symbols
validate_program Validate XML structure
save_cxt Save as .cxt
save_cxp Re-encode and save as .cxp
list_project_templates List available built-in templates
create_project_from_template Create a new blank project from template
compile_rung Validate mnemonic instructions
simulate_rung Boolean simulation of a rung
analyze_rung Analyze rung structure
program_diagnostics Full program diagnostics
semantic_snapshot Semantic JSON snapshot for AI review
launch_in_cx_programmer Save and open in CX-Programmer (Windows)

Project Structure

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

Notes

  • Always run Program Check in CX-Programmer before downloading to a real PLC.
  • This tool edits program logic only — I/O table, unit setup, and PLC configuration are preserved as-is from the template.
  • .CXP output is binary-compatible with CX-Programmer 9.73 on CJ2M CPU11.
  • For other PLC models, provide your own blank .CXP template (see Project Template Setup).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选