Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

linuxcnc-grpc

PyPI npm crates.io Go Reference

gRPC interface for LinuxCNC machine control and HAL (Hardware Abstraction Layer).

Why gRPC?

LinuxCNC's native Python API only works locally. This project exposes it over gRPC, enabling:

  • Remote monitoring - Build web dashboards, mobile apps, or desktop GUIs
  • Multi-machine management - Monitor a fleet of CNC machines from one place
  • Any-language integration - Use Go, Node.js, Rust, or any gRPC-supported language
  • Real-time streaming - Subscribe to status updates instead of polling

Running the Server

The server runs on your LinuxCNC machine and exposes the gRPC interface.

Basic Usage

pip install linuxcnc-grpc
# or with uv
uv pip install linuxcnc-grpc
linuxcnc-grpc --host 0.0.0.0 --port 50051

Security warning: the server has no authentication and no TLS. Anyone who can reach the port can command the machine. Bind to 127.0.0.1 and connect through an SSH tunnel (ssh -N -L 50051:127.0.0.1:50051 user@cnc-machine), or use --host 0.0.0.0 only on a trusted LAN. See Security Considerations.

The server can start before LinuxCNC: it waits, reports NOT_SERVING on the gRPC health service and answers UNAVAILABLE on the RPCs that need LinuxCNC until it is up (GetServerInfo, UploadFile, ListFiles, ReadFile, DeleteFile and the HAL service work meanwhile). Pass --require-linuxcnc to make it exit instead.

Auto-start with LinuxCNC

To start the gRPC server automatically when LinuxCNC launches, add to your machine's HAL file:

# Start gRPC server (runs until LinuxCNC exits)
loadusr linuxcnc-grpc --host 0.0.0.0 --port 50051

Or use a dedicated HAL file via your INI:

[HAL]
POSTGUI_HALFILE = grpc-server.hal

Quick Start

Python

pip install linuxcnc-grpc

PyPI package

import grpc
from linuxcnc_pb import linuxcnc_pb2, linuxcnc_pb2_grpc

channel = grpc.insecure_channel("localhost:50051")
stub = linuxcnc_pb2_grpc.LinuxCNCServiceStub(channel)

status = stub.GetStatus(linuxcnc_pb2.GetStatusRequest())
pos = status.position.actual_position
print(f"Position: X={pos.x:.3f} Y={pos.y:.3f} Z={pos.z:.3f}")

Go

go get github.com/dougcalobrisi/linuxcnc-grpc

pkg.go.dev

import (
    pb "github.com/dougcalobrisi/linuxcnc-grpc/packages/go"
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials/insecure"
)

conn, _ := grpc.NewClient("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
client := pb.NewLinuxCNCServiceClient(conn)

status, _ := client.GetStatus(context.Background(), &pb.GetStatusRequest{})
pos := status.GetPosition().GetActualPosition()
fmt.Printf("Position: X=%.3f Y=%.3f Z=%.3f\n", pos.GetX(), pos.GetY(), pos.GetZ())

Node.js / TypeScript

npm install linuxcnc-grpc

npm package

import * as grpc from "@grpc/grpc-js";
import { LinuxCNCServiceClient, GetStatusRequest } from "linuxcnc-grpc";

const client = new LinuxCNCServiceClient("localhost:50051", grpc.credentials.createInsecure());

client.getStatus(GetStatusRequest.create(), (err, status) => {
  if (err) throw err;
  const pos = status!.position!.actualPosition!;
  console.log(`Position: X=${pos.x.toFixed(3)} Y=${pos.y.toFixed(3)} Z=${pos.z.toFixed(3)}`);
});

Rust

crates.io

[dependencies]
linuxcnc-grpc = "1.1"
tokio = { version = "1", features = ["full"] }
tonic = "0.12"
use linuxcnc_grpc::linuxcnc::linux_cnc_service_client::LinuxCncServiceClient;
use linuxcnc_grpc::linuxcnc::GetStatusRequest;

let mut client = LinuxCncServiceClient::connect("http://localhost:50051").await?;
let status = client.get_status(GetStatusRequest {}).await?.into_inner();
if let Some(pos) = status.position.as_ref().and_then(|p| p.actual_position.as_ref()) {
    println!("Position: X={:.3} Y={:.3} Z={:.3}", pos.x, pos.y, pos.z);
}

Using with Claude (MCP)

linuxcnc-mcp is an MCP server and Claude Code plugin built on this API. It is read-only by default; control tools are opt-in and, by default, ask for approval before each call. See Using with Claude.

Examples

Complete examples for all supported languages:

Example Description Python Go Node.js Rust
get_status Poll machine status view view view view
stream_status Real-time status streaming view view view view
jog_axis Jog axes with keyboard view view view view
mdi_command Execute G-code via MDI view view view view
hal_query Query HAL pins/signals view view view view
upload_file Upload, list, delete G-code files view view view view

See examples/README.md for setup instructions.

Services

  • LinuxCNCService - Machine control: status, jogging, MDI, program execution, file management
  • HalService - HAL introspection: query pins, signals, parameters (read-only)

File Management

The server provides UploadFile, ListFiles, ReadFile, DeleteFile and ResolveFile RPCs for remote G-code file management. Files are stored in the NC files directory (default: /home/linuxcnc/linuxcnc/nc_files).

Configure the directory with --nc-files or the LINUXCNC_NC_FILES environment variable:

linuxcnc-grpc --host 0.0.0.0 --nc-files /path/to/nc_files

Safety Warning

This server provides remote control of CNC machinery, and it has no authentication and no TLS: anyone who can reach the port can command the machine. Ensure proper safety measures:

  • Bind to localhost (--host 127.0.0.1) and connect through an SSH tunnel: ssh -N -L 50051:127.0.0.1:50051 user@cnc-machine
  • Otherwise use --host 0.0.0.0 only on a trusted, isolated LAN, never on a shared network or the internet
  • Never leave machines unattended during remote operation
  • Verify E-stop and safety systems are functional

Production Deployment

The packaged server does not enable TLS; the SSH tunnel above is the supported way to secure it. If you embed the servicers in your own server, you can add TLS yourself:

# Server with TLS
credentials = grpc.ssl_server_credentials([(private_key, certificate)])
server.add_secure_port('[::]:50051', credentials)
# Client with TLS
credentials = grpc.ssl_channel_credentials(root_certificates)
channel = grpc.secure_channel('your-machine:50051', credentials)

See Server Configuration for complete TLS setup instructions.

Development

Requires uv for Python dependency management:

# Install dev dependencies
make setup

# Run tests
make test          # Python tests
make test-all      # All languages

# Generate proto code
make proto-all     # Regenerate for all languages

See CLAUDE.md for detailed development documentation.

License

MIT

Metadata

Release files for linuxcnc-grpc 1.1.0rc1

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

Source distribution (sdist)

Source distribution for linuxcnc-grpc 1.1.0rc1
File Size Uploaded Provenance Actions
linuxcnc_grpc-1.1.0rc1.tar.gz 365.5 kB With provenance Details for linuxcnc_grpc-1.1.0rc1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linuxcnc-grpc 1.1.0rc1
File Interpreter ABI Platform Actions
linuxcnc_grpc-1.1.0rc1-py3-none-any.whl Python 3 none any Details for linuxcnc_grpc-1.1.0rc1-py3-none-any.whl

Total release size: 535.5 kB

Release files / linuxcnc_grpc-1.1.0rc1.tar.gz

Download URL linuxcnc_grpc-1.1.0rc1.tar.gz
Size 365.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c7802da1416a9042c070c692070d179918be1a34cee7d6f9838b2bd11e961662
BLAKE2b-256 checksum
How to use checksums
b0202ef62c2fa9c79b2d260a2cfbf35c01d174c014ee2c3aae2cea5aa251b64d
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 Nov 29, 2026.

Transparency log

Release files / linuxcnc_grpc-1.1.0rc1-py3-none-any.whl

Download URL linuxcnc_grpc-1.1.0rc1-py3-none-any.whl
Size 170.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7620238c95b095e7de4ed2ca922ddb31ccf73da8d49962f512afd13d476ad3e6
BLAKE2b-256 checksum
How to use checksums
ec19c27c9d7c9d7922a4fb49f4ee7d691302eb752e8bef6bc1d84f729597bf99
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 Nov 29, 2026.

Transparency log

Security for linuxcnc-grpc 1.1.0rc1

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.

Select from 2 files

Attestation for linuxcnc_grpc-1.1.0rc1.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 Nov 29, 2026.

Transparency log

A 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.

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