Skip to main content
Pre-release

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

Grok Gadgets Linux SDK

Turn Python functions into gadgets your Grok Bot can call through the Grok Gadgets gateway. Start with a software lamp; add your hardware code later. This SDK does not yet have accepted Linux hardware evidence. The separate ESP32 kit has physical evidence. Native Grok Bot MCP access remains unverified (project status). Independent project, not affiliated with SpaceXSI.

Writing style: ASD-STE100-inspired English. Use short sentences, active verbs and one instruction per step. This is not certified compliance.

Quickstart

Needs Git and uv. Packages are not on PyPI yet.

git clone https://github.com/adidshaft/grok-gadgets-linux-sdk.git
cd grok-gadgets-linux-sdk
uv sync --extra gateway

Save this as my_gadget.py:

from grok_gadgets_linux import Gadget

lamp = Gadget("desk-lamp", "Desk lamp", state={"on": False})


@lamp.command("Turn the desk lamp on or off")
def set_light(on: bool) -> dict:
    # Your hardware code goes here, for example gpio.write(17, on).
    return {"on": on}

Run it:

uv run grok-linux-agent dev ./my_gadget.py

dev starts a local gateway, connects your gadget with no token to copy, and prints the connector settings Grok Bot will use. Run the local rehearsal:

uv run grok-gadgets-gateway rehearse --device desk-lamp --command set.light --args '{"on": true}'

Install with pip

The package is not on PyPI yet. Each GitHub release has a wheel and SHA256SUMS. Install the wheel into a virtual environment with Python 3.11+:

python3 -m venv .venv
.venv/bin/python -m pip install https://github.com/adidshaft/grok-gadgets-linux-sdk/releases/download/v0.1.0-alpha.5/grok_gadgets_linux_sdk-0.1.0a5-py3-none-any.whl
.venv/bin/grok-linux-agent --help

How it works

flowchart LR
    A["Your Python functions"] --> S["SDK agent"]
    S <-->|"127.0.0.1:8765"| G["Gateway"]
    B["Grok Bot (connection in progress)"] -.-> G
    R["rehearse (local check)"] --> G

Your file declares a Gadget and its commands. The agent connects it to the gateway on the same computer, and the gateway offers its commands to Grok Bot, with your one-line descriptions. dev runs both in one process. Each command's schema comes from its type hints, so the SDK refuses bad arguments before your code runs.

Add your hardware

Put your GPIO, I2C or serial code inside the command function. Plain functions run in a worker thread, so blocking calls are fine; async def works too. Return what the device now reports. Set simulated=False only when your code really controls hardware.

from typing import Annotated

from grok_gadgets_linux import Range


@lamp.command("Set the brightness from 0 to 100", name="level.set")
def level(level: Annotated[int, Range(0, 100)]) -> dict:
    # pwm.duty(level)  <- your hardware call goes here
    return {"level": level}

Events, shutdown hooks, the original Device API and limits are in the developer guide.

Run it as a service

Next to a long-running grok-gadgets-gateway serve, give the gadget its own token:

grok-gadgets-gateway enroll desk-lamp --token-file desk-lamp.token
grok-linux-agent --factory-file ./my_gadget.py --token-file desk-lamp.token

The agent re-reads the token file on every connection, so enroll --rotate needs no restart. A systemd user unit template, reconnect limits and exit codes are in the operation guide (systemd is not yet verified).

Platforms

Python 3.11–3.14. CI runs on Ubuntu every night, including the README quick start and the gateway integration tests against gateway main. Raspberry Pi 3, 4, 5 and Zero 2 W have PyPI wheels for every dependency. The armv6l models (Pi Zero, Zero W, Pi 1) need a Rust toolchain for rpds-py. Nobody has tested a Raspberry Pi yet; see the project status.

Troubleshooting

The agent prints Agent stopped (<code>). <hint> and exits with a distinct code.

Exit Meaning Next step
2 Configuration (token_missing, factory_error, ...) Use grok-linux-agent dev ./my_gadget.py, or set --token-file; install the gadget's dependencies
3 unauthorized or revoked Check the device ID and token; see token recovery
4 Protocol contract, for example frame_too_large Shorten schemas, descriptions or state (16 KiB hello, 2048-byte other frames)
5 reconnect_exhausted Start the gateway, or use --retry-forever

Never retry an uncertain physical action with a new command ID: read the state first. Gadget files run trusted local code; never run code from a conversation.

Community

Show your gadget, ask questions and share ideas on r/GrokGadgets. Report bugs in GitHub Issues. New here? Pick a good first issue and read CONTRIBUTING. Help: SUPPORT. Security: SECURITY. Keep tokens and household details out of public posts. Contribute on the dev branch; main holds tagged stable releases (branches).

License and affiliation

Apache-2.0; see LICENSE and NOTICE. Grok Gadgets is an independent open-source project. It is not affiliated with, endorsed by or sponsored by SpaceXSI. We reconstructed the pre-publication commit dates; see the history record. Detailed verification records: launch verification and historical record.

Metadata

Release files for grok-gadgets-linux-sdk 0.1.0a5

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

Source distribution (sdist)

Source distribution for grok-gadgets-linux-sdk 0.1.0a5
File Size Uploaded
grok_gadgets_linux_sdk-0.1.0a5.tar.gz 125.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grok-gadgets-linux-sdk 0.1.0a5
File Interpreter ABI Platform
grok_gadgets_linux_sdk-0.1.0a5-py3-none-any.whl Python 3 none any Details

Total release size: 157.4 kB

Release files / grok_gadgets_linux_sdk-0.1.0a5.tar.gz

Download URL grok_gadgets_linux_sdk-0.1.0a5.tar.gz
Size 125.2 kB
Tags Source
SHA-256 checksum
How to use checksums
343dc158c86ac0bb6683d6b6a677f3daecf3ab7381ce8c5f692aba9e05a2f7ca
BLAKE2b-256 checksum
How to use checksums
24a4729b8d3521644ea6b7097f0d8537ad64afe7ef9b6bd4ae5ca4be0ab66df6
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 Oct 12, 2026.

Transparency log

Release files / grok_gadgets_linux_sdk-0.1.0a5-py3-none-any.whl

Download URL grok_gadgets_linux_sdk-0.1.0a5-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92f7be251f9b42cf8fe0cf37d3baec81a120399afcaf0c4fb25ba7ab737fadf2
BLAKE2b-256 checksum
How to use checksums
eefb11d335a4a874fab6ad7ebed9039ba9d83c9bb2faa3bc60559e042366e389
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 Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0a5 This release

2 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