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.
Guides · Facts read
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.
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.
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
- 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.