Skip to main content

Python SDK for CMDOP agent interaction

Project description

cmdop

Turn any machine into an API endpoint.

PyPI Python License

from cmdop import CMDOPClient

# Server in another country. Behind NAT. Behind firewall. Don't care.
with CMDOPClient.remote(api_key="cmd_xxx") as server:
    server.terminal.execute("docker restart app")
    server.files.write("/etc/nginx/sites/new.conf", config)
    logs = server.files.read("/var/log/app/error.log")

No SSH. No VPN. No open ports. No bullshit.


The Problem

You need to run a command on a remote server. What do you do?

Option A: SSH

→ Generate keys
→ Copy public key to server
→ Configure sshd
→ Open port 22
→ Hope firewall allows it
→ Pray NAT doesn't break it
→ paramiko/fabric in Python
→ Debug why it doesn't work

Option B: Build an API

→ Write FastAPI endpoints
→ Implement authentication
→ Get SSL certificate
→ Open ports
→ Deploy to every server
→ Maintain all of this
→ Write client code
→ Repeat for each new operation

Option C: CMDOP

server.terminal.execute("your command")

That's it.


How It Works

┌─────────────┐      ┌─────────────┐      ┌─────────────┐
│  Your Code  │ ──── │ Cloud Relay │ ──── │   Agent     │
│   (SDK)     │      │grpc.cmdop.com│     │  (on server)│
└─────────────┘      └─────────────┘      └─────────────┘
                            │
        Outbound only ──────┘
        No open ports
        Works through any NAT/firewall
  1. Install agent on target machine
  2. Agent connects outbound to cloud relay
  3. Your code connects to same relay with API key
  4. Commands flow through, results come back
  5. Zero network configuration required

What Can You Do?

Terminal — full shell access:

session = server.terminal.create(shell="/bin/bash")
server.terminal.send_input(session.session_id, "kubectl get pods\n")
output = server.terminal.get_history(session.session_id)

Files — complete filesystem control:

server.files.list("/home/user")
server.files.read("/etc/nginx/nginx.conf")
server.files.write("/tmp/config.json", b'{"key": "value"}')
server.files.delete("/tmp/garbage", recursive=True)
server.files.copy("/backup/db.sql", "/restore/db.sql")

Real World

Give AI Agents Hands

# Your LLM can now touch real infrastructure
def execute_on_server(command: str) -> str:
    with CMDOPClient.remote(api_key=KEY) as server:
        session = server.terminal.create()
        server.terminal.send_input(session.session_id, f"{command}\n")
        time.sleep(2)
        return server.terminal.get_history(session.session_id).data.decode()

# "Check why nginx is failing"
# AI runs: execute_on_server("journalctl -u nginx --no-pager -n 50")
# AI reads logs, understands problem, fixes config

Deploy Without The Circus

# No Ansible. No Terraform. No YAML hell.
def deploy(version: str):
    with CMDOPClient.remote(api_key=PROD_KEY) as prod:
        prod.terminal.execute(f"docker pull myapp:{version}")
        prod.terminal.execute("docker-compose up -d")

        # Verify
        health = prod.files.read("/var/log/myapp/health.log")
        assert b"healthy" in health

Fleet Management

# Update 1000 edge devices
async def update_fleet(device_keys: list[str], new_config: bytes):
    async with asyncio.TaskGroup() as tg:
        for key in device_keys:
            tg.create_task(update_device(key, new_config))

async def update_device(key: str, config: bytes):
    async with AsyncCMDOPClient.remote(api_key=key) as device:
        await device.files.write("/etc/app/config.yml", config)
        await device.terminal.execute("systemctl restart app")

Debug Customer Issues

# Support engineer gets temporary access
def diagnose(customer_key: str):
    with CMDOPClient.remote(api_key=customer_key) as machine:
        # See what's running
        session = machine.terminal.create()
        machine.terminal.send_input(session.session_id, "ps aux\n")

        # Read their logs
        logs = machine.files.read("~/Library/Logs/MyApp/error.log")

        # Check disk space
        machine.terminal.send_input(session.session_id, "df -h\n")

Installation

pip install cmdop

Quick Start

from cmdop import CMDOPClient

# Remote server via cloud relay
with CMDOPClient.remote(api_key="cmd_xxx") as client:
    result = client.files.list("/home")
    print(result.entries)

# Local agent on same machine
with CMDOPClient.local() as client:
    result = client.files.list("/home")

Async

from cmdop import AsyncCMDOPClient

async with AsyncCMDOPClient.remote(api_key="cmd_xxx") as client:
    await client.terminal.execute("echo hello")
    content = await client.files.read("/etc/hostname")

API

Terminal

Method What it does
create(shell, cols, rows) Start terminal session
send_input(id, data) Send commands/keystrokes
get_history(id) Get output
resize(id, cols, rows) Resize terminal
send_signal(id, signal) Send SIGINT/SIGTERM/etc
close(id) End session

Files

Method What it does
list(path) List directory
read(path) Read file
write(path, content) Write file
delete(path) Delete file/dir
copy(src, dst) Copy
move(src, dst) Move/rename
mkdir(path) Create directory
info(path) Get metadata

Security

  • TLS everywhere — all traffic encrypted
  • Outbound only — agent never accepts incoming connections
  • API key scoping — keys bound to specific agents/teams
  • No credentials on wire — no SSH keys, no passwords
  • Audit logs — every action tracked

Requirements

  • Python 3.10+
  • CMDOP agent running on target machine

Links

cmdop.com

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmdop-0.1.4.tar.gz (126.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmdop-0.1.4-py3-none-any.whl (224.2 kB view details)

Uploaded Python 3

File details

Details for the file cmdop-0.1.4.tar.gz.

File metadata

  • Download URL: cmdop-0.1.4.tar.gz
  • Upload date:
  • Size: 126.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for cmdop-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ce1da81293ae78f3c26636df00c3a6fe852ab652049b7fe583a8aea82189bb8c
MD5 5e937783f577f5843c7d82aeaef4a18c
BLAKE2b-256 85479e075018e5351561e9641f649b5044ba27e01b31ea066c2f63d502e7c7d4

See more details on using hashes here.

File details

Details for the file cmdop-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: cmdop-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 224.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for cmdop-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3049ef3d1f6a036e9e01454b0f8b58e7fb3bca9e4e24c36111f1bd4814103026
MD5 0b259add2da904ef97fafc8838ea4135
BLAKE2b-256 18aae87a2934744c39b841b2074be2ec161c738f5b1748f921fd46549dfa8e44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page