Remote Execution: Run Your AI Tools From Anywhere
Learn how cli4ai's remote execution feature lets you run AI tools on any machine from anywhere. Perfect for browser automation, headless servers, and distributed workflows.
What if your AI agent could control a browser running on your Mac mini at home while you’re working from a coffee shop? Or execute tools on a powerful cloud server from your laptop? That’s exactly what cli4ai’s new remote execution feature enables.
The Problem: Tools Are Stuck on One Machine
AI agents are getting incredibly capable, but they’re often limited by their environment. Consider these scenarios:
Browser automation: You want your AI to interact with websites, but you’re on a headless Linux server with no display. Chrome won’t even launch.
Resource constraints: Your laptop is running low on battery, but you need to run a heavy data processing tool that would take hours.
Environment-specific tools: The tool you need only works on macOS, but you’re on Windows.
Team collaboration: Multiple team members need access to the same configured tools with the same credentials.
The traditional solution is to SSH into machines, set up remote desktops, or build complex deployment pipelines. That’s a lot of friction for what should be simple.
The Solution: cli4ai serve
With cli4ai 1.2.0, any machine running cli4ai can become a remote server:
# On your Mac mini, cloud server, or any machine
cli4ai serve
That’s it. Your machine is now accessible as a remote tool server on port 4100.
From any other machine, you can now execute tools as if they were local:
# On your laptop, anywhere in the world
cli4ai remotes add mac-mini http://192.168.1.100:4100
cli4ai run --remote mac-mini chrome launch
cli4ai run --remote mac-mini twitter trends
The remote machine does the work. You get the results. It feels like the tools are running locally, but they’re not.
Real-World Use Cases
Browser Automation Without Displays
This is the killer use case. Browser automation tools like Puppeteer and Playwright need a display to run Chrome. On a headless server, you’re stuck with complex Xvfb setups or expensive cloud browser services.
With remote execution:
- Set up a cheap Mac mini or any machine with a display
- Install cli4ai and the chrome package
- Run
cli4ai serve - Control that browser from anywhere
# From your laptop
cli4ai run --remote mac-mini chrome launch
cli4ai run --remote mac-mini chrome navigate "https://twitter.com"
cli4ai run --remote mac-mini chrome screenshot
Your AI agent running on a headless cloud server can now interact with real browsers on real machines.
Distributed Tool Execution
Different machines excel at different things:
- Your gaming PC has a powerful GPU for ML inference
- Your Mac mini runs macOS-specific tools
- Your cloud server has fast internet for API calls
Remote execution lets you route tools to the right machine:
cli4ai remotes add gpu-server http://192.168.1.50:4100
cli4ai remotes add mac-mini http://192.168.1.51:4100
cli4ai remotes add cloud http://api.myserver.com:4100
# Run ML inference on the GPU server
cli4ai run --remote gpu-server llama generate "..."
# Run Apple-specific tools on Mac
cli4ai run --remote mac-mini shortcuts run "My Shortcut"
# Run API-heavy tools on cloud
cli4ai run --remote cloud github sync-all
Team Tool Sharing
Instead of every team member configuring the same tools with the same credentials, set up one server:
# On the team server
cli4ai add -g slack twitter github mongodb
cli4ai secrets set SLACK_TOKEN xxx
cli4ai secrets set TWITTER_API_KEY xxx
cli4ai serve --api-key team-secret-key
Now everyone on the team can access these configured tools:
# Any team member
cli4ai remotes add team-tools http://tools.internal:4100 --api-key team-secret-key
cli4ai run --remote team-tools slack channels
Credentials stay on the server. Team members just use the tools.
Making It Secure with Tailscale
Exposing a server on the internet sounds scary. Here’s the good news: you don’t have to.
Tailscale creates a private mesh network between your devices. It’s free for personal use and takes about 60 seconds to set up.
With Tailscale:
- Install Tailscale on both machines
- They get private IPs (100.x.x.x) that only your devices can access
- Traffic is end-to-end encrypted
- Works through NAT, firewalls, even cellular networks
# On your Mac mini
tailscale up
cli4ai serve
# From anywhere in the world (coffee shop, airport, phone hotspot)
cli4ai remotes add mac-mini http://100.64.0.1:4100
cli4ai run --remote mac-mini chrome launch
No port forwarding. No firewall rules. No VPN configuration. It just works.
If you use Tailscale’s MagicDNS feature, you can even use hostnames:
cli4ai remotes add mac-mini http://mac-mini:4100
API Endpoints
Under the hood, cli4ai serve exposes a simple REST API:
| Endpoint | Description |
|---|---|
GET /health | Health check |
GET /packages | List installed packages |
GET /packages/:name | Get package info |
POST /run | Execute a tool command |
POST /routines/:name/run | Run a routine |
This means you can integrate with any HTTP client, not just cli4ai:
curl -X POST http://mac-mini:4100/run \
-H "Content-Type: application/json" \
-d '{"package": "twitter", "command": "trends"}'
Build webhooks, integrations, or custom clients—the API is simple and predictable.
Security Best Practices
Remote execution is powerful, which means it needs to be secured properly:
Always Use API Keys in Production
# On the server
cli4ai serve --api-key your-secret-key
# When adding the remote
cli4ai remotes add server http://host:4100 --api-key your-secret-key
Restrict Scopes
Limit what operations can be performed:
# Only allow read operations
cli4ai serve --scope read
# Allow read and write, but not delete
cli4ai serve --scope read,write
Use Private Networks
Don’t expose cli4ai directly to the internet. Use:
- Tailscale for personal/small team use
- WireGuard for custom VPN setups
- Private VPC networks in cloud environments
Firewall the Port
If you must expose the port, firewall it to specific IPs:
# Only allow connections from specific IP
ufw allow from 203.0.113.50 to any port 4100
What’s Next
Remote execution is just the beginning. We’re exploring:
Automatic failover: If one remote is down, automatically try another.
Load balancing: Distribute tool execution across multiple machines.
Remote routines: Run multi-step workflows entirely on remote machines.
Streaming output: Real-time output streaming for long-running commands.
Getting Started
Upgrade to cli4ai 1.2.0:
npm install -g cli4ai@latest
Start a server:
cli4ai serve
Connect from another machine:
cli4ai remotes add my-server http://IP:4100
cli4ai run --remote my-server github notifs
Check out the full documentation for more details on authentication, API endpoints, and advanced configuration.
Your AI tools are no longer stuck on one machine. Run them from anywhere.
Ready to supercharge your AI workflows?
Install cli4ai and give your AI agents access to powerful CLI tools in minutes.
Get Started Free