ModbusPilot Studio
Automation & AI

Drive ModbusPilot from
scripts and AI agents

modbuspilot-cli is the console twin of ModbusPilot. Read and write Modbus devices from Python, PowerShell, Bash, CI jobs or let an AI assistant read your hardware through the built-in MCP server. Same profiles, same license, no cloud.

Quick start

Put modbuspilot-cli.exe next to ModbusPilot.exe (or in your PATH). On macOS it is inside the zip; from source run python modbuspilot_cli.py.

1

Find the port

List serial ports with their USB adapter names.

modbuspilot-cli ports
2

Read registers

Reference addresses like 40001 work directly.

modbuspilot-cli read -p COM20 -b 115200 -a 40001 -c 18
3

Read by name

Load a profile and ask for values in plain words.

modbuspilot-cli get -p COM20 -P psu.json "Battery voltage"

Every command

Run modbuspilot-cli COMMAND --help for all options. Connection options work with every device command.

CommandWhat it doesExample
portsList serial portsmodbuspilot-cli ports --json
readRead coils, inputs or registers (FC01-04) with type, byte order and scalemodbuspilot-cli read -p COM20 -a 40036 -t uint16 --scale 0.001 --unit V
writeWrite registers or coils (FC05, 06, 15, 16), echo checkedmodbuspilot-cli write -p COM20 -a 40039 -v 7
pollRead every enabled poll of a profile with names and unitsmodbuspilot-cli poll -P psu.json --json
getRead named values; --watch repeatsmodbuspilot-cli get -P psu.json "Battery" -w 1 -n 60 -f csv
setWrite a named value in engineering units or value textmodbuspilot-cli set -P psu.json "Run mode" Auto
scanFind slave IDs on the busmodbuspilot-cli scan -p COM20 --from 1 --to 247
rawSend any hex frame and show the replymodbuspilot-cli raw -p COM20 --crc --send "01 03 00 00 00 02"
decodeExplain a captured RTU or TCP frame offlinemodbuspilot-cli decode "01 03 04 08 FD 13 88 64 F5"
profile importSmart Import a PDF, Excel, Word or CSV register tablemodbuspilot-cli profile import manual.pdf --out dev.json
profile showList the registers of a profilemodbuspilot-cli profile show dev.json
licenseShow the edition and evaluation state, or activate a keymodbuspilot-cli license --activate MT2-...
mcpRun the MCP server for AI assistantsmodbuspilot-cli mcp -p COM20 -P psu.json
aiAI kit: guide teaches an AI everything, setup installs the skill, agent and MCP configmodbuspilot-cli ai setup --for copilot

Serial (Modbus RTU)

  • -p COM20 or /dev/ttyUSB0, -b 115200, --bits 8 --parity N --stop 1
  • RTS/CTS off unless --rtscts
  • -s 1 slave ID, --timeout 1000 ms
  • Wake-up bytes: --break-data "BRK 0x55" --break-delay 15 --break-duration 15

Network and profiles

  • Modbus TCP: --host 192.168.1.10 --tcp-port 502
  • Serial gateways: add --rtu-over-tcp
  • -P device.json supplies port, slave and names; options you type win
  • -z treats addresses as 0-based protocol offsets

Made for programs

Choose --format table, --json (-j) or --format csv. JSON always has an ok field, and errors are JSON too.

JSON output

$ modbuspilot-cli get -p COM20 -P psu.json "Battery voltage" -j
{"ok": true, "profile": "Power board", "values": [
  {"address": "40036", "name": "Battery voltage",
   "value": "11.265", "numeric": 11.265, "unit": "V",
   "raw": "2C01", "type": "Unsigned"}]}

$ modbuspilot-cli read -p COM20 -a 41001 -j
{"ok": false, "kind": "exception",
 "error": "Exception 02: Illegal data address"}

Exit codes

0Success
1Device or communication error: timeout, CRC, Modbus exception, port busy
2Wrong usage: missing port, bad address, unknown name
3The command needs a higher edition and the evaluation is used up

ports, decode, license and ai guide are free. Device commands, mcp and ai setup need ModbusPilot Pro; without a Pro key they run inside a 15-minute evaluation window (one per hour). The MCP server and --watch loops stop when the window ends.

Let your AI assistant read the hardware

modbuspilot-cli mcp speaks the Model Context Protocol over stdin/stdout. Add it to your AI tool once, then ask questions like "Is the battery voltage OK?" or "Scan the bus and list all devices."

Where do I ask? In your AI chat, not in ModbusPilot.
  1. Add ModbusPilot to your AI tool once: run modbuspilot-cli ai setup --for copilot in your project folder, or paste one of the configs below.
  2. Restart or reload the AI tool and open its chat (VS Code: Copilot Chat, choose Agent mode; Claude Desktop: a new chat).
  3. Ask your question. The AI tool starts modbuspilot-cli mcp by itself, calls ModbusPilot tools such as get_values and answers. Nothing to open or press in ModbusPilot.
// .vscode/mcp.json
{
  "servers": {
    "modbuspilot": {
      "type": "stdio",
      "command": "C:\\Tools\\ModbusPilot\\modbuspilot-cli.exe",
      "args": ["mcp", "--port", "COM20", "--baud", "115200", "--profile", "C:\\Tools\\ModbusPilot\\psu.json"]
    }
  }
}

Tools the assistant gets

  • get_values / read_device: named values with units from the profile
  • read_registers: any address, type, order and scale
  • describe_profile, load_profile, import_datasheet
  • scan_devices, list_serial_ports, decode_frame, license_status

Safe by default

  • Read-only: write_registers and set_value appear only with --allow-write
  • The serial port is released after every call, so the ModbusPilot app can still use it
  • Runs locally; nothing is sent anywhere except to your AI client
Get the AI kit: Skill, agent, llms.txtor let ModbusPilot configure your AI: modbuspilot-cli ai setup --for copilot

Script examples

import json, subprocess

def modbuspilot(*args):
    run = subprocess.run(["modbuspilot-cli", *args, "--json"], capture_output=True, text=True)
    data = json.loads(run.stdout)
    if not data["ok"]:
        raise RuntimeError(data["error"])
    return data

values = modbuspilot("get", "-p", "COM20", "-P", "psu.json", "Battery voltage")["values"]
battery = float(values[0]["value"])
print("PASS" if 10.5 <= battery <= 12.6 else "FAIL", battery, "V")

Automate your bench today