# 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. Facts read: 2026-11-26 ## Why from code [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#why-title) 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 [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#before-you-start-title) - 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. - [Try it in three steps](https://cmdop.ai/try) - [Tokens](https://docs.cmdop.ai/concepts/tokens) ## Install a package [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#install-title) the TypeScript install line ```text npm install @cmdop/sdk ``` the Python install line ```text pip install cmdop ``` Node 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://.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 [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#first-program-title) 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. a Python program that reads every online computer ```text 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 [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#run-title) - `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`, and `call` takes 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 [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#limits-and-record-title) - 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. - [Choose what an agent may do](https://docs.cmdop.ai/guides/access) - [Tokens](https://docs.cmdop.ai/concepts/tokens) - [The record of calls](https://docs.cmdop.ai/concepts/audit-and-history) ## Errors [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#errors-title) - `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 as `denied`, `offline` or `timed_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 [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#agents-title) Claude Code, Codex and ChatGPT reach the same computers through the MCP address, with the same kind of token and the same permissions. - [Claude Code on another computer over MCP](https://cmdop.ai/academy/lessons/claude-code-remote-machine-mcp.md) - [ChatGPT with your own computer over MCP](https://cmdop.ai/academy/lessons/chatgpt-mcp-your-computer.md) ## Limits [Section on website](https://cmdop.ai/academy/lessons/run-commands-from-python-or-node#limits-title) - 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. - [Package reference](https://docs.cmdop.ai/reference/sdk) - [Changelog](https://docs.cmdop.ai/help/changelog) - [The packages' source (MIT licence)](https://github.com/commandoperator/cmdop-sdk) - [Feature status](https://docs.cmdop.ai/help/feature-status) ## 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 file](https://media.cmdop.ai/prod/media/video/5af96b36a49c3bd9c9209197a17be38887f882c15546234f18dc3afa99c33b9a/video.mp4) [English captions](https://media.cmdop.ai/prod/media/video/20ff9ff51eacf385cdfaa1699e04fbb2a8774706163e3f504d3c6dac3de8f09a/captions.vtt) ### 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. ## Related materials - [Claude Code on another computer over MCP](https://cmdop.ai/academy/lessons/claude-code-remote-machine-mcp.md) - [A home Linux server for Claude Code or Codex, no SSH key](https://cmdop.ai/academy/lessons/home-linux-server-without-ssh-key.md) - [Cut off an AI agent](https://cmdop.ai/academy/lessons/cut-off-an-ai-agent.md) [All materials in this path](https://cmdop.ai/academy/paths/build-with-code.md)