mcp-rungkit
Provides tools for editing and simulating Mitsubishi MELSEC iQ-R/FX5 ladder programs and exporting them as MELSEC instruction lists or GX Works3 CSV for import into Mitsubishi engineering tools.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
rungkit
English | 日本語
An AI-native toolkit for PLC ladder programs.
rungkit keeps a ladder diagram as a series-parallel tree, lets an AI agent edit it over MCP, and lets the agent check its own work on a scan simulator. It supports Mitsubishi (MELSEC iQ-R) and IEC 61131-3, and reads and writes ladder text (.ldt), JSON, the MELSEC instruction list, Structured Text and PLCopen XML.
Status: prototype (0.x). Editing commands, simulator, MCP server, PLCopen XML and a browser version are in place.

Try it in the browser
The browser version runs entirely in the page (Go compiled to WebAssembly): write .ldt on the left and see the ladder diagram and diagnostics as you type, click an element to jump to its line or edit it on the diagram (drag contacts, coils, timers and counters from the parts palette onto it, or use the ribbon buttons; Delete and Esc work too), run .ldtest scenarios with a trace, and export to every format. Dark and light themes. Nothing is sent anywhere; your input stays in the browser.
Open it at https://piyoone3939.github.io/rungkit/ (updated with each release by .github/workflows/pages.yml), or build it yourself:
sh web/build.sh # builds web/dist
python -m http.server -d web/dist 8000 # then open http://localhost:8000Related MCP server: io.github.purinzan/gx3-cli-mcp
Install
go install github.com/Piyoone3939/rungkit/cmd/rungkit@latestOr download a binary for Windows, macOS or Linux from GitHub Releases.
Use it from an AI (MCP)
claude mcp add rungkit -- rungkit mcpListed in the official MCP Registry as
io.github.Piyoone3939/rungkitEach release also has MCP Bundles (
rungkit-mcp-<os>-<arch>.mcpb) that apps supporting MCPB, such as Claude Desktop, install by opening the filerungkit mcp FILEstarts with FILE openThe MCP server reads and writes only inside the folder it was started in (change with
-root DIR); standard input (-) is refused
Tools:
Tool | What it does |
| open / start / save (files change only on save) |
| show the program with rung IDs ( |
| apply a list of edit commands; all or nothing; one undo step |
| undo / redo |
| errors and warnings with codes, rung and element IDs |
| run scenarios on the simulator (text or a |
| write |
Edit commands (ops of edit_program):
Command | What it does |
| add a rung |
| replace, delete, move or comment a rung |
| put conditions before or after an element |
| add a branch parallel to an element (or the series range target..to); on an output it adds an output branch |
| replace, delete or re-address an element |
| device comments and variable declarations |
Example: add an emergency stop after the stop button
{"ops": [
{"op": "insert_series", "target": "e3", "position": "after", "text": "!X3"},
{"op": "set_symbol", "name": "X3", "comment": "emergency stop"}
]}Edits that would make a rung an invalid ladder (a contact right of an output, …) are refused with the reason. Device mistakes (writing an input, …) are not refused but returned as diagnostics, so the agent can fix them next.
Ladder text (.ldt)
profile melsec-iqr
sym X0 "start button"
sym X1 "stop button"
sym Y0 "conveyor motor"
rung "run, self-holding" {
(X0 | Y0) & !X1 -> OUT(Y0)
}
rung "lamp and arrival" {
Y0 -> {
OUT(Y1)
rise(X2) -> SET(M10)
}
}Syntax | Meaning |
| series (AND); binds tighter than |
| parallel (OR) |
| normally closed contact |
| rising / falling edge |
| comparison ( |
| one output at the right end, or a |
| coils |
| timer / counter |
| instructions |
| comment |
Example: examples/conveyor.ldt
Command line
rungkit check examples/conveyor.ldt # errors and warnings
rungkit fmt -w examples/conveyor.ldt # canonical form
rungkit export -to melsec examples/conveyor.ldt
rungkit export -to gxw3 -o conveyor.csv examples/conveyor.ldt # CSV for GX Works3 (Edit > Import File)
rungkit export -to st examples/conveyor.ldt
rungkit export -to json examples/conveyor.ldt
rungkit export -to ascii examples/conveyor.ldt # the ladder drawn as text (svg for a picture)check gives every problem a code (E_READ_ONLY, …) and a line and column, so an agent can fix them one by one.
Messages are available in English and Japanese, chosen by -lang en|ja, then RUNGKIT_LANG, then the system language.
PLCopen XML
Reads and writes PLCopen XML (TC6 v2.01) Ladder Diagram, to exchange programs with Beremiz, OpenPLC Editor, CODESYS and others.
rungkit export -to plcopen -name Conveyor examples/conveyor.ldt > conveyor.xml
rungkit check conveyor.xml # .xml opens directly (fmt / test / mcp too)Exports validate against the official schema (tc6_xml_v201.xsd) and build as is in Beremiz (procedure and results); a default 10 ms task is included
Beremiz runs timer and counter calls after the coils, so a rung reading a timer sees it one scan later than on MELSEC; use the ST export for rung-by-rung semantics
OpenPLC Editor v4: its importer was read against rungkit's export (not run yet). Rungs, contacts, coils, timers and instructions match its structure; a rung with a comparison should import with OpenPLC's own layout warning (details)
Supported: contacts (NO/NC/rising/falling), coils (set/reset/pulse), TON/TOF/TP/CTU, comparisons (EQ/NE/LT/LE/GT/GE), MOVE/ADD/SUB/MUL/DIV, pulse instructions (through R_TRIG), rung comments
Import turns the wiring graph back into a series-parallel tree; chained coils and wired ORs work. Circuits that are not series-parallel (bridges) are refused with
E_NON_SERIES_PARALLELPLCopen is IEC, so melsec programs are written with IEC spellings (
K10→10,H1F→16#1F, timerK50→T#5000ms) and the profile is kept inaddDatato restore MELSEC spellings on importChanged by a round trip:
INC/DECbecomeADD/SUB(same behavior),RSTof a word becomesMOV(K0, …), independent circuits in one rung become separate rungsNot exportable:
RSTof timers and counters, MELSEC timers with a word device as preset
Simulator (.ldtest)
Runs the program scan by scan on virtual time and checks it against scenarios.
scan 10ms
test "counts a part 5 s after it arrives" {
set X0 on
run 1 // one scan
set X0 off
set X2 on
run 4s // 4 s of virtual time
expect T0 off
wait T0 on within 2s
expect D0 1
}Command | Meaning |
| set an input or other device ( |
| pin a value (program writes are ignored) / release |
| run N scans / a span of time |
| check the value now |
| run until the value appears; fail after the time |
| record after every scan |
| comment |
T0.ET (timer elapsed time) and C0.CV (counter value) can be read too. Every test starts from a fresh state.
rungkit test examples/conveyor.ldt examples/conveyor.ldtest
rungkit test -trace examples/conveyor.ldt examples/conveyor.ldtest # table of scans where values changed
rungkit test -json examples/conveyor.ldt examples/conveyor.ldtest # for agentsThe simulator follows ladder semantics:
Rungs run top to bottom and every instruction runs every scan (no short-circuit), so edges and timers never miss an input
Outputs are written immediately; later rungs in the same scan see them
An output branch uses the power flow from before the branch (like MELSEC MPS)
MELSEC
Tadds ticks of a free-running 100 ms clock each time it runs, as the CPU does, so it may turn on up to 100 ms before "preset + 1 scan"; counters stop at the set value (a set value of 0 counts as 1);MULwrites the high word to D(n+1),DIVthe remainder to D(n+1), words wrap at 16 bitsSM400(always ON),SM401(always OFF),SM402(ON for the first scan)Division by zero stops with an error naming the scan, rung and element
Profiles
Name | |
| Mitsubishi iQ-R: X/Y/B/W in hexadecimal, |
| Mitsubishi FX5: like |
| IEC 61131-3: declare with |
Structure (onion architecture)
Dependencies point inward only; internal/architecture_test.go enforces it.
Layer | Package | Role |
Domain | rung tree, normalization, shape rules, IDs | |
vendor devices and instructions | ||
errors and warnings | ||
scan simulator | ||
Application | edit commands, undo and redo | |
running scenarios | ||
open, save, check, edit, export, scenarios (what CLI and MCP call); declares the interfaces it needs | ||
Infrastructure |
| |
| ||
JSON | ||
MELSEC list / Structured Text | ||
PLCopen XML | ||
files (outside the working folder refused for MCP) | ||
system language | ||
ladder drawings as text ( | ||
Presentation | command line / MCP server / browser bindings | |
Shared | English and Japanese messages (used by every layer; standard library only) | |
Composition | wire the adapters and start (CLI and MCP / browser) |
Design: docs/design.en.md
Decisions (license, distribution, scope): docs/decisions.en.md
Checking against Mitsubishi's tools: docs/verify-melsec.en.md
How well AI agents use it: eval/agent (Sonnet 5/5, Haiku 5/5 after fixes)
Safety
rungkit does not talk to real PLCs (no download, monitoring or forcing). Review what it writes and load it with the vendor's tool
Check ladder written by an AI with
checkand scenarios before use. Build safety functions such as emergency stops in wiring and safety devices, not in softwareThe MELSEC instruction sequence follows the standard conversion rules, and the simulator follows Mitsubishi's manuals (results).
-to gxw3writes the CSV GX Works3 imports, following the format in its operating manual, but importing it into GX Works3 has not been tried yet (how to check)Mitsubishi Electric, MELSEC, GX Works and others are trademarks of their owners. rungkit is not affiliated with them
Contributing
See CONTRIBUTING.md. Issues and pull requests are welcome in English or Japanese.
License
Your choice of MIT or Apache-2.0.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
AI-native programming language and toolchain for accountable, verifiable agent-driven development.
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
Deterministic reasoning stack for AI agents: simulate, decide & compute, plus cross-domain tools.
Self-hosted AI workspace: semantic RAG document search, long-term memory, and AI chat via MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceThe first and only MCP server for PLC (Programmable Logic Controller) intelligence. Give any AI agent direct access to industrial automation data — ladder logic, tag databases, cross-references, fault root cause analysis, and sequence blockersMIT
- FlicenseAqualityCmaintenanceLets AI agents and users analyze Mitsubishi MELSEC .gx3 projects directly, tracing coil conditions, checking device references, comparing program changes, and inspecting ladder logic without opening GX Works3.134-
- AlicenseAqualityBmaintenanceEnables lossless parsing, inspection, validation, simulation, and creation or editing of FATEK .ldr ladder-logic files through local stdio MCP tools, including a user-import-verified start/stop template. New files are written to an artifacts directory so existing files and original samples are never overwritten.48233MIT
- AlicenseNot gradedqualityBmaintenanceEnables an AI agent to write ladder logic and import programs and comments into Mitsubishi GX Works2, Siemens TIA Portal and Omron CX-Programmer through a single MCP endpoint that routes vendor-prefixed tools to each tool's own backend. Backends keep their own approval flows while a shared rule withholds live-PLC writes and deletions.17Apache 2.0