Skip to main content
Glama
BlackUppsss

cx-programmer-mcp

by BlackUppsss

cx-programmer-mcp

OMRON CX-Programmer のラダープログラムを、GUI を開かずにプログラムから編集するための MCP (Model Context Protocol) サーバーです。

OMRON CJ/CP/CS シリーズ PLC.CXP / .CXT ファイルに対応しています。

対象範囲: プログラム、セクション、ラダーニーモニック、ラングコメント、シンボルテーブルのみ。 PLC セットアップ、I/O テーブル、ネットワーク設定、パスワード、PLC への転送には触れません


仕組み

OMRON は .CXP.CXT の圧縮版として定義しています。.CXT は CX-Programmer がインポート/エクスポートできるテキストベースの形式です。このサーバーは .CXP または .CXT を読み込み、メモリ上でプログラムを編集してから、実機の PLC に展開する前に CX-Programmer で確認できるよう、結果を .CXT / .CXP として保存します。

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 以外のモデルの場合:

  1. お使いのマシンで CX-Programmer を開きます

  2. ご利用の PLC モデル(CP1L、CS1G など)で新しい空のプロジェクトを作成します

  3. .CXP または .CXT として保存します

  4. ファイルを project/ フォルダーに配置します

  5. make_template.py を更新して、ご利用のファイルを指定します:

SRC = Path(__file__).parent / "project" / "your_blank_template.cxp"
  1. 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.py

MCP クライアント設定

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

機能

初期値

D0

スケジュール 1 — 時

6

D1

スケジュール 1 — 分

0

D2

スケジュール 2 — 時

16

D3

スケジュール 2 — 分

0

D4

運転時間 x100ms

300 (=30s)

変更は PLC を再起動しなくてもすぐに反映されます。


テストの実行

uv run pytest -q

利用可能な MCP ツール

ツール

説明

load_project

.cxp または .cxt ファイルをセッションに読み込みます

list_programs

プロジェクト内のすべてのプログラムを一覧表示します

list_sections

プログラム内のセクションを一覧表示します

get_program_context

プログラムの完全なラダーコンテンツを取得します

get_rungs

セクション内のラングを取得します

replace_rung

ラングの命令を置き換えます

insert_rung

新しいラングを挿入します

delete_rung

ラングを削除します

set_rung_comment

ラングコメントを設定します

patch_program

複数のラング編集を原子的に一括実行します

create_section

新しいセクションを追加します

rename_section

既存のセクションの名前を変更します

upsert_symbol

シンボルを追加または更新します

clear_symbols

スコープ内のすべてのシンボルをクリアします

list_symbols

すべてのシンボルを一覧表示します

validate_program

XML 構造を検証します

save_cxt

.cxt として保存します

save_cxp

再エンコードして .cxp として保存します

list_project_templates

利用可能な組み込みテンプレートを一覧表示します

create_project_from_template

テンプレートから新しい空のプロジェクトを作成します

compile_rung

ニーモニック命令を検証します

simulate_rung

ラングのブールシミュレーションを行います

analyze_rung

ラング構造を解析します

program_diagnostics

プログラムの完全な診断

semantic_snapshot

AI レビュー用のセマンティック JSON スナップショット

launch_in_cx_programmer

保存して 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 出力は CJ2M CPU11 上の CX-Programmer 9.73 とバイナリ互換です。

  • 他の PLC モデルの場合は、専用の空の .CXP テンプレートを用意してください(プロジェクトテンプレートのセットアップ を参照)。

Install Server
F
license - not found
B
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • A
    license
    B
    quality
    C
    maintenance
    An 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.
    16
    33
    MIT
  • F
    license
    Not graded
    quality
    A
    maintenance
    MCP 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

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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