This release is a pre-release and may not be stable for production use.
pyModbusTCP-cli
Command line tools built on pyModbusTCP:
| Command | Role |
|---|---|
mbtcp-server |
Modbus/TCP server (test a client, a SCADA, a gateway...) |
mbtcp-client |
Modbus/TCP client: read and write requests from the command line |
mbtcp-tcp2rtu |
gateway: Modbus/TCP clients -> Modbus/RTU slaves on a serial line |
mbtcp-rtu2tcp |
gateway: a Modbus/RTU master on a serial line -> a Modbus/TCP server |
mbtcp-rtu-scan |
find the serial settings and the address of Modbus/RTU slaves |
The code of the tools is in the pyModbusTCP library (module pyModbusTCP.tools). This package contains no code:
it only adds the commands to the PATH, with pyserial for the serial tools. So a plain pip install pyModbusTCP puts no
command in the PATH and installs no dependency.
Install
# as isolated command line tools (recommended)
pipx install pyModbusTCP-cli
# or in a virtual environment, with the library
pip install "pyModbusTCP[cli]==0.4.0a4"
Alpha: pyModbusTCP-cli is new with pyModbusTCP 0.4.0, only pre-releases exist for now. The commands, their
options and their output may still change before the final release. Without a version or --pre,
pip install "pyModbusTCP[cli]" installs the stable pyModbusTCP 0.3.1, without the tools.
Without this package, the tools can still be run from the library alone:
python -m pyModbusTCP.tools server --help
python -m pyModbusTCP.tools client --help
pip install "pyModbusTCP[serial]==0.4.0a4" # pyserial, only needed by the serial tools
python -m pyModbusTCP.tools tcp2rtu --help
python -m pyModbusTCP.tools rtu2tcp --help
python -m pyModbusTCP.tools rtu-scan --help
Examples
# server on localhost:5020, log the writes of the clients
mbtcp-server --log-changes
# read 4 holding registers from address 0, write some values
mbtcp-client -p 5020 read-holding 0 -n 4
mbtcp-client -p 5020 write-registers 0 100 200 0x1234
mbtcp-client -p 5020 write-read 0 20 22 1 -n 4 # write then read in one request (function 0x17)
mbtcp-client -p 5020 write-coil 10 on
# float32 values on 2 registers, word swapped (CDAB): -T/--type and -B/--byte-order
mbtcp-client -p 5020 write-registers 20 3.14 -2.5 -T float32 -B CDAB
mbtcp-client -p 5020 read-holding 20 -n 2 -T float32 -B CDAB
# TCP clients of the 192.168.1.0/24 network can read (only) the RTU slaves of /dev/ttyUSB0
mbtcp-tcp2rtu -H 0.0.0.0 -A 192.168.1.0/24 --read-only -b 19200 --parity E /dev/ttyUSB0
# an RTU master on /dev/ttyUSB0 reads the Modbus/TCP server 192.168.1.10 (the gateway is the RTU slave 30)
mbtcp-rtu2tcp -a 30 -H 192.168.1.10 /dev/ttyUSB0
# find the baud rate, the format and the address of the RTU slaves of /dev/ttyUSB0 (stop the usual master first)
mbtcp-rtu-scan --all /dev/ttyUSB0
On a terminal, mbtcp-client prints a table (registers in hexadecimal, unsigned, signed, binary and ASCII, bits
in a grid); with -i it is refreshed in place and the changed values are highlighted. For a script, -f plain,
-f csv or -f json (the default output of a pipe is plain: one address value line per item).
Run any command with --help for all its options, -v/--version for its version.
Security
Modbus/TCP has no authentication and no encryption: any host that can reach a server can read and write its data. The server and the TCP to RTU gateway are designed to be safe by default:
- they listen on
localhostand on port 5020 by default: use-Hwith the address of the network interface that needs it (0.0.0.0only if every network of the host is trusted); -A/--allowrestricts the clients to some IP addresses or networks,--read-onlyrefuses every write;- the TCP to RTU gateway only relays the standard data functions by default (no diagnostics, file records or vendor
functions):
--functionssets the list; - the TCP to RTU gateway refuses broadcast requests (unit id 0) unless
--allow-broadcastis set (and then only for the write functions, answered at once); --max-connections-per-host(default 16) keeps a single client host from taking every connection, and the TCP to RTU gateway shares the serial line between the client hosts (at most 2 requests per host waiting for the line or in progress).
Port 502 (the standard Modbus/TCP port) is a privileged port on Unix systems. Never run these commands as root (or
with sudo) to listen on it. Give the CAP_NET_BIND_SERVICE capability to the Python interpreter of a virtual
environment dedicated to the tools instead:
python3 -m venv --copies ~/mbtcp-venv # --copies: real interpreter files, not links to the system one
~/mbtcp-venv/bin/pip install pyModbusTCP-cli
sudo setcap 'cap_net_bind_service=+ep' ~/mbtcp-venv/bin/python3
~/mbtcp-venv/bin/mbtcp-server -H 192.168.1.10 -p 502
The commands of this virtual environment run its bin/python3, the file with the capability. This does not work
with pipx, whose environments use links to the system interpreter (setcap refuses them). See "Listen on the standard
Modbus port 502 without root" in the examples README
for the details and the precautions.
See also the security policy of pyModbusTCP.
Versions
pyModbusTCP-cli has the version of pyModbusTCP and requires exactly this release of the library (where its code is).
Metadata
Release files for pyModbusTCP-cli 0.4.0a4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymodbustcp_cli-0.4.0a4.tar.gz | 4.7 kB | With provenance | Details for pymodbustcp_cli-0.4.0a4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymodbustcp_cli-0.4.0a4-py3-none-any.whl | Python 3 | none | any | Details for pymodbustcp_cli-0.4.0a4-py3-none-any.whl |
Total release size: 9.2 kB
Release files / pymodbustcp_cli-0.4.0a4.tar.gz
| Download URL | pymodbustcp_cli-0.4.0a4.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f42d3acbc8d279b1f94f0321c772e1014cfc4de0af789f322173f4b99febb7a
|
|
BLAKE2b-256 checksum How to use checksums |
c5c1fd2789a4c1c2810bb7615cdbb0d190b88a3bf18ac674f29bbd85ea8047a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / pymodbustcp_cli-0.4.0a4-py3-none-any.whl
| Download URL | pymodbustcp_cli-0.4.0a4-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10ba736a6661a0bf8448725b5b716ee3f25c23b0d0dfdddf4ce8646ed61198ae
|
|
BLAKE2b-256 checksum How to use checksums |
8c4974785372817dd8afcb0aaae8a24f37f1263bb8b678319ebcb60d5342b3f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for pyModbusTCP-cli 0.4.0a4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pymodbustcp_cli-0.4.0a4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.