Build with code · Facts read
Run commands on your own computers from Python or Node, with the same limits as your AI agent
Install the Python or Node package, set an agent token and your address, and your program calls the same tools an AI agent calls through CMDOP's MCP server: run a command, read a file, start a long task. The token is held to the same permissions, and every call is recorded under that agent.
Read a report from your own code
Illustrated workflow · 36 s
Illustrated historical SDK reference. The build report contains sample data, not a new test result. Running the prepared helper requires command execution permission on the enrolled machine.
Open video fileRead transcript
Your application already has useful information. Why build another integration just to read it? With Command Operator's Python SDK, select your connected machine and run a prepared helper with the permissions you've allowed. In our reference container, the helper reads an existing build report. The same JSON comes back to your code. We tested the Python and TypeScript callers against the enrolled container. Your AI. Your computers. Connected.
Why from code
A script, a scheduled job or your own service wants to do what the agent does, on the same computers: check them, run a build, read a log. It should not need its own SSH keys or a backend of its own, and it should be held to the same limits as the agent.
Before you start
- Install CMDOP on the Mac or Linux computer you want to read, connect it to your page and check that it is online. Installing the Python or Node package alone does not connect a computer.
- Run your program on a computer with Python or Node. It can be the computer you are reading, or a different one.
- Create an agent token on your page. The first program only reads system information; leave writing, running commands and screen access off.
- Set CMDOP_URL to your page's address and CMDOP_TOKEN to that agent token in your environment. Keep the token out of source files and shared output.
Install a package
npm install @cmdop/sdkpip install cmdopNode 20 or newer, or Python 3.10 or newer. Use the version npm and PyPI show. The program reads two variables: CMDOP_TOKEN, an agent token from the Agents tab of your page, and CMDOP_URL, your address, https://<your-address>.cmdop.dev. No account yet? cmdop setup makes one: it asks for your email and the code from the letter, and your first computer gets your address.
A first program
Walk your computers and print, for each one, the memory available and the space left on its main disk. It only reads, so a new token can run it as it is.
import cmdop
with cmdop.connect() as c: # CMDOP_TOKEN, CMDOP_URL
for m in c.machines_list():
if m.state != "online":
continue
info = c.machine(m.name).sys_info()
root = next(d for d in info.disks if d.mount == "/")
print(m.name, info.memory_available // 2**20, "MiB available,",
root.available // 2**30, "GiB left on /")machines_list is answered by CMDOP itself, with no computer chosen; so are tasks_list and history_search. sys_info runs on each computer.
This example reads every computer whose state is online, using each name returned by the list. It does not ask you to select one. Expect one line per computer: its name, available memory in MiB and available space on the root disk in GiB. The numbers come from your computers; the program does not write files or run a command.
If there are no online computers, it prints nothing. If a computer has no disk mounted at /, Python raises StopIteration. A refused or failed call also stops this small example. Check the address, the computers on your page and the failure before retrying; an empty result is not a successful read.
Run a command, follow its output
machine(name).run("uptime")waits for the command and returns its output and exit code.stream(...)gives the output as it comes; leaving the loop stops the command.- Every tool is also a method by its name, such as
fs_read, andcalltakes any tool by name. - Running commands is a switch you turn on for that agent by hand. A new token can only read.
The same limits and the same record
- The token is an agent token, so the program gets that agent's permissions and each computer's own limit, exactly as the agent would.
- The token has a lifetime you choose, from 5 minutes to 90 days, and you can revoke it.
- Each call is recorded under that agent, and the computer keeps its own record of calls with their arguments. Give each program its own token, so the record says which one acted.
Errors
unauthorized: check the page address and whether the agent token has expired or been revoked. Never replace it with an owner token just to get past an error.offline: check the selected computer on your page.denied: check the agent's read permission and the computer's own limit; do not enable running commands for a read-only call.- A refused or failed call raises one error type with a
code, such asdenied,offlineortimed_out. Decide by the code. - A lost connection is a separate error, not a refusal.
- Each call can carry a deadline; past it the call ends with
timed_out. - Within a major version the packages only add. A computer whose program is older answers a tool it does not have yet with
unknown_tool.
The same computers for your AI agent
Claude Code, Codex and ChatGPT reach the same computers through the MCP address, with the same kind of token and the same permissions.
Limits
- The packages talk to CMDOP over HTTPS, through the same address as your agents.
- Computers run macOS or Linux. Windows is not supported yet.
- This page makes no claim about speed or uptime.
