I built a Modbus simulator that Claude drives over MCP: test SCADA without a PLC
Disclosure: I work on fieldpuppet, the open-source simulator in this post. It is maintained by the team behind PLCGateway.
Here is a prompt I can now type into Claude: Set up 50 energy meters starting at port 6000. Make meter 12 stop answering for 30 seconds, then tell me which registers my SCADA read from it.
A few seconds later there are 50 Modbus TCP devices listening on my laptop, one of them goes silent on schedule, and I get a report of what my software polled. No PLC, no meter, no cabinet.
This post explains why I built it, how the MCP part works, and how to use it without any AI at all.
The problem: the hardware is never on your desk
If you write software that talks Modbus TCP (a SCADA screen, a gateway, a historian, a data collector), you know this situation. The code is ready, but the PLC is in a cabinet at the customer site, the energy meter has not shipped yet, and nobody will let you unplug a pump just to see how your software handles a timeout.
A register table that returns fixed numbers does not help much. Real testing needs:
- Many devices at once, because polling 1 device and polling 200 behave very differently.
- Values that move, so trends, alarms and scaling can be checked.
- Faults on demand: slow answers, no answer, exception replies, dropped connections. These break software in the field and are the hardest to reproduce with real equipment.
- A record of what your software asked for, so you can see whether it polls the registers you think it does.
Why MCP fits this job
Setting up test devices is boring, repetitive work: copy a register list from a manual, pick ports, write a fault timeline. It is exactly the kind of work an assistant does well if it has the right tools.
fieldpuppet is a single Rust executable of about 2 MB with an MCP server built in. It exposes 22 tools, such as create_device, set_signal, apply_scenario, inject_fault and get_traffic_log. Every tool carries read-only and destructive hints, so the client knows which calls change state.
For Claude Code it is one line:
claude mcp add fieldpuppet -- /full/path/to/fieldpuppet mcp
For Claude Desktop, each release has an .mcpb bundle you can install from the Extensions settings. Any MCP client that can start a local server over stdio works.
Things I ask it most often:
- "Here is the register list from a device manual. Build a simulated device that matches it."
- "Make the tank level rise from 20 % to 95 % over two minutes, then switch the high level alarm on."
- "Pump 2 should answer with a device busy exception for the next 30 seconds."
- "Which registers has my SCADA been reading from the drive in the last minute?"
A read-only web dashboard on http://127.0.0.1:5080 shows every device, its live values and a feed of everything the assistant changed, so you are never guessing what it did.
It works without AI too
Describe the devices in YAML:
devices:
- id: pump-1
template: pump
port: 5020
- id: dosing-skid
port: 5021
points:
- name: chlorine_ppm
table: input
address: 0
scale: 0.01
unit: ppm
value: 0.8
signal: { type: random_walk, min: 0.5, max: 1.2, step: 0.02 }
Run it:
fieldpuppet run water-station.yaml
Point your own software at 127.0.0.1, port 5020 or 5021, unit id 1. The chlorine value drifts between 0.5 and 1.2 ppm like a real sensor would.
Addresses are zero-based protocol addresses, so holding register 40001 is address 0.
Test the bad days, not only the good ones
Four fault types are available, each with an optional time limit:
delay: correct answers, but lateno_response: your client sees a timeoutexception: a Modbus exception such as device busydisconnect: the connection closes on every request
This is how you find out whether your software reconnects, whether one dead device stalls the polling of the other 49, and whether stale values are marked as stale.
Limits
- Modbus TCP only. No serial RTU or ASCII yet.
- Devices do not model process behaviour. A pump does not stop because its run coil was cleared; a scenario or the assistant has to change the values.
- Simulation only. It answers requests sent to it and never connects to real equipment.
Try it
The code is on GitHub under MIT / Apache 2.0: CybriantOps/fieldpuppet. It is a new project, so bug reports and feature requests are very welcome.
Which fault case has caused you the most trouble in the field?
Comments
No comments yet. Start the discussion.