Skip to main content

gomc-rest (Python)

English / 日本語

A Python library for talking to Mitsubishi PLCs. Read and write PLC devices over the MC protocol (3E/4E frames) — the protocol is handled for you by a bundled gomc-rest server that the package auto-launches, so you never have to start or distribute an executable yourself.

Bonus — expose a REST API. Enable server_mode to make the bundled server's REST API reachable from other apps on your network (a GUI, another machine, another language); and connect() talks to a gomc-rest server that is already running elsewhere. See Access control.

Under the hood the HTTP layer is provided by gomc-rest-client; this package adds the bundled binary and its process lifecycle.

your Python process
└─ gomc_rest.launch()
     ├─ spawns the bundled gomc-rest on a free loopback port  ── MC protocol ──▶ PLC
     └─ returns a Server that provides a PLCClient pointed at it

Install

pip install gomc-rest

Usage

import gomc_rest

with gomc_rest.launch(plc_host="192.168.0.1") as plc:
    values = plc.read("D100", 3)
    plc.write("D100", [10, 20, 30])
# the bundled server is stopped automatically on exit

launch() returns a Server; using it as a context manager yields a PLCClient (see gomc-rest-client for the full read/write/remote API) and stops the server on exit. Without with, the server is stopped at interpreter exit.

Pass server flags through extra_args:

with gomc_rest.launch(plc_host="192.168.0.1", extra_args=["-enable-remote"]) as plc:
    plc.remote_run()

Client mode (connect to an existing server)

To talk to a gomc-rest server that is already running elsewhere — a shared instance, another machine, or one you launched with server_mode=True — use connect() instead of starting the bundled binary:

with gomc_rest.connect("http://192.168.0.1:8080", token="...") as plc:
    plc.read("D100", 3)

Both launch() and connect() hand you the same PLCClient, so one package covers "bundle and run the server" and "just be a client".

connect() needs no bundled binary, so it works even on platforms without a prebuilt wheel (Windows arm64, glibc < 2.34, macOS < 12): there pip install gomc-rest installs from the sdist, and only launch() is unavailable (it raises a clear error).

Access control

Two independent layers protect the server, both on by default:

  1. Per-launch bearer token. A random token is generated each launch and required by the server, so even another process on the same host that discovers the port cannot call the API. It is set automatically on the returned client and exposed as server.token. Pass an explicit token= to share with another app, or token="" to disable auth (closed-network use).
  2. Loopback binding. By default the server binds to 127.0.0.1, so no other host can reach it.

Set server_mode=True to bind all interfaces so other apps on the network (e.g. gomc-rest-gui, curl from another machine) can call it — give them server.token:

server = gomc_rest.launch(plc_host="192.168.0.1", server_mode=True)
print(server.base_url)   # other apps connect to http://<this-host>:<port>
print(server.token)      # ...with this bearer token
try:
    server.client.read("D100", 3)
finally:
    server.close()

The server has no TLS — only enable server_mode on a trusted network.

Threat model. The token is passed to the server via the GOMCR_TOKEN environment variable (not the command line), so it does not appear in the process list. It protects against other hosts and other OS users. It does not protect against another process running as the same OS user, which can read the server's environment (e.g. /proc/<pid>/environ); the OS user boundary is the trust boundary here.

Versions

This package bundles a pinned gomc-rest binary (currently v1.7.0, set in GOMC_REST_VERSION) that must satisfy gomc-rest-client's MINIMUM_SUPPORTED_GOMC_REST_VERSION; launch() verifies this on startup. The gomc-rest-client dependency is capped (>=1.0,<2) so a breaking client release can't be pulled in silently. If a 1.x client ever requires a newer server than the bundled one, launch() fails at startup with a clear error.

Development

Release procedure and bundled-binary maintenance are documented in RELEASING.md.

Metadata

Release files for gomc-rest 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gomc-rest 0.3.0
File Size Uploaded
gomc_rest-0.3.0.tar.gz 23.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for gomc-rest 0.3.0
File
gomc_rest-0.3.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
gomc_rest-0.3.0-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details
gomc_rest-0.3.0-py3-none-manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
gomc_rest-0.3.0-py3-none-macosx_12_0_x86_64.whl Python 3 none macOS 12.0+ x86-64 Details
gomc_rest-0.3.0-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details

Total release size: 29.3 MB

Release files / gomc_rest-0.3.0.tar.gz

Download URL gomc_rest-0.3.0.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
096b3320d04fa624443f5375d3de443a88e0f08fcbc30aeabfe64065cf48efdb
BLAKE2b-256 checksum
How to use checksums
c8208bd5601c9f7495681f99b9238bdce8dd97566de8292c3f9e6bc8e8bed3b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 12, 2026.

Transparency log

Release files / gomc_rest-0.3.0-py3-none-win_amd64.whl

Download URL gomc_rest-0.3.0-py3-none-win_amd64.whl
Size 6.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
00811534f6e9d799b77fbf36f91730a95217aca5cb912a5e033d109b033dd28e
BLAKE2b-256 checksum
How to use checksums
2108d8d95837ee521b3db8c343e79d9c94617b773dfaae243167f7ba1d9581b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 12, 2026.

Transparency log

Release files / gomc_rest-0.3.0-py3-none-manylinux_2_34_x86_64.whl

Download URL gomc_rest-0.3.0-py3-none-manylinux_2_34_x86_64.whl
Size 6.0 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
97361d6d03274e65e18ae9d42a54d4dd360ea2bd4cd4deb71203a60c2fad0b14
BLAKE2b-256 checksum
How to use checksums
4d88cbba67766addadaac02f490d4ce64ad9bb4ac17b0da8d559f3f0d28992cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 12, 2026.

Transparency log

Release files / gomc_rest-0.3.0-py3-none-manylinux2014_aarch64.whl

Download URL gomc_rest-0.3.0-py3-none-manylinux2014_aarch64.whl
Size 5.5 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
8ae9f6d9fa43f90b71a18f93d4dcf0faae143a909208e23e90e46422bc856c24
BLAKE2b-256 checksum
How to use checksums
c05d722f43d54cb4a6a1d5bd2dd1983d4cfbe8bd43e3d2c0de890acba1437e14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 12, 2026.

Transparency log

Release files / gomc_rest-0.3.0-py3-none-macosx_12_0_x86_64.whl

Download URL gomc_rest-0.3.0-py3-none-macosx_12_0_x86_64.whl
Size 6.1 MB
Tags Python 3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
76268f84109d0b2c243bf612cc1b3f6c372693d2413fa2fc1556e4e4b20be744
BLAKE2b-256 checksum
How to use checksums
1159fd76b5d2d041d4736dd291e0a7d6937585df1a8cd21bf90b70c2a69b5937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 12, 2026.

Transparency log

Release files / gomc_rest-0.3.0-py3-none-macosx_12_0_arm64.whl

Download URL gomc_rest-0.3.0-py3-none-macosx_12_0_arm64.whl
Size 5.7 MB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
f22d795452c48699e77669e32d12c8b02d6549f917484f5c1071dee55d5855b5
BLAKE2b-256 checksum
How to use checksums
dd54adf47baefb3348ab31955324ba6f76c63bf227d6b60ec8c6e0c6c1ec7864
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

6 release files

0.2.0

6 release files

0.1.2

4 release files

0.1.1

4 release files

0.1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page