Securely control your computer from any AI agent through an encrypted MCP tunnel.
Z-Agent Remote Control is a self-hosted system that lets any AI assistant (Claude, ChatGPT, Super Z, etc.) remotely control your Ubuntu/Linux machine through a secure, auditable MCP (Model Context Protocol) tunnel. It includes a full-featured GTK3 desktop GUI for managing the tunnel, API keys, security settings, and sending agent requests directly from your desktop.
- Features
- Architecture
- Quick Start (5 minutes)
- Detailed Setup
- Using the Desktop App
- Connecting Your AI Agent
- Security Model
- Shell Helper
- Project Structure
- Troubleshooting
- Screenshots
- License
- 7 tabbed panels: Setup, Control, Agent, Security, Settings, Connect, Log
- One-Click Install: Downloads cloudflared, deploys MCP server, creates desktop entry, generates API key β all from the app
- MCP Server Control: Start/stop with real-time status indicators and process management
- Cloudflare Tunnel: Start/stop tunnel, displays live tunnel URL, health monitoring
- Agent Request Panel: Send commands to your own machine through the tunnel with tool selector, quick actions, response viewer, and request history
- API Key Manager: Generate, show/hide, copy, apply custom keys with strength meter
- Security Controls: Allowed directories manager, command blocklist viewer, audit log
- Settings: Port config, auto-start toggles, server info, danger zone (reset/clear)
- Connection Prompt Generator: Auto-generates a complete prompt to paste into any AI agent, updates live with current URL and key
- Share: Copy-self button to share the app with others
- 7 tools:
run_command,read_file,write_file,list_directory,search_files,get_system_info,delete_file - Bearer token authentication
- Path allowlist restriction (file operations only in allowed directories)
- Command blocklist (rm, sudo, shutdown, reboot, halt, mkfs, dd, chmod, chown, kill, killall, pkill)
- Comprehensive audit logging
- Zero dependencies β pure Python stdlib
- Cloudflare Tunnel (free, no account needed) for public HTTPS endpoint
- JSON-RPC 2.0 over HTTP POST
- Works with any AI agent that can make HTTP requests
βββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ
β AI Agent β ββββββΊ β Cloudflare β ββββββΊ β MCP Server β
β (Claude, Z, β HTTPS β Tunnel β HTTP β (localhost) β
β ChatGPT...) β JSON- β (cloudflared) β RPC β Port 9001 β
β β RPC β β β β
β Sends tool β β Public URL: β β File I/O β
β calls via β β *.trycloudflare β β Shell exec β
β HTTP POST β β .com β β System info β
βββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ
β²
β
ββββββββββββββββββββ
β Z Control GUI β
β (GTK3 Desktop) β
β Manages: β
β - MCP Server β
β - Tunnel β
β - Keys/Security β
β - Agent Requestsβ
ββββββββββββββββββββ
Data flow:
- AI agent sends JSON-RPC POST to
https://<tunnel-url>/mcp - Cloudflare Tunnel forwards to
http://localhost:9001/mcp - MCP server validates Bearer token, checks security rules, executes the tool
- Result is sent back through the same path
- Ubuntu/Debian Linux (or any distro with GTK3)
- Python 3.8+ with
python3-gi(GTK bindings) - Internet connection (for cloudflared download)
# Download and run Z Control
mkdir -p ~/.local/share/z-control
curl -sL https://raw.githubusercontent.com/YOUR_USERNAME/Z-Agent-Remote-Control/main/src/z_control.py \
-o ~/.local/share/z-control/z_control.py
python3 ~/.local/share/z-control/z_control.pyThen inside the app:
- Go to π Setup tab
- Click π One-Click Install (downloads cloudflared, deploys MCP server, generates API key)
- Click βΆ Start MCP + Tunnel
- Go to π Connect tab β Copy the full prompt
- Paste it into your AI agent conversation
That's it! Your AI agent can now control your computer.
# Ubuntu/Debian
sudo apt update
sudo apt install -y python3 python3-gi gir1.2-gtk-3.0 cloudflaredNote: If
cloudflaredis not in your package repo, the Z Control app can download it automatically via the Setup tab.
# Create directories
mkdir -p ~/.local/share/z-control
mkdir -p ~/.local/share/applications
# Download files
# Option A: From GitHub
wget -O ~/.local/share/z-control/z_control.py \
https://raw.githubusercontent.com/YOUR_USERNAME/Z-Agent-Remote-Control/main/src/z_control.py
wget -O ~/mcp_server.py \
https://raw.githubusercontent.com/YOUR_USERNAME/Z-Agent-Remote-Control/main/src/mcp_server.py
# Option B: Clone the repo
git clone https://github.com/YOUR_USERNAME/Z-Agent-Remote-Control.git
cp Z-Agent-Remote-Control/src/z_control.py ~/.local/share/z-control/
cp Z-Agent-Remote-Control/src/mcp_server.py ~/cat > ~/.local/share/applications/z-control.desktop << 'EOF'
[Desktop Entry]
Name=Z Control
Comment=MCP Tunnel Controller for AI Agent Remote Control
Exec=python3 ~/.local/share/z-control/z_control.py
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=System;Utility;
StartupNotify=true
EOF
update-desktop-database ~/.local/share/applications/# Launch Z Control
python3 ~/.local/share/z-control/z_control.py
# Or find "Z Control" in GNOME ActivitiesInside the app:
- Setup tab β Click "One-Click Install" if you haven't installed cloudflared yet
- Control tab β Start MCP Server, then Start Tunnel
- Wait for the tunnel URL to appear (looks like
https://xxx-xxx.trycloudflare.com) - Connect tab β Copy the connection prompt
Paste the connection prompt (from the Connect tab) into any AI agent that supports making HTTP requests. The prompt includes:
- The MCP endpoint URL
- The API key
- All available tools and their parameters
- Example JSON-RPC calls
- A ready-to-use shell helper script
| Tab | Purpose |
|---|---|
| π Setup | One-click install, prerequisites check, share the app |
| β Control | Start/stop MCP server & tunnel, system info, test connection, kill all |
| π€ Agent | Send requests through the tunnel, quick actions, response viewer, history |
| π Security | API key manager (generate/show/hide/copy/apply), allowed dirs, blocklist |
| βοΈ Settings | Port config, auto-start, server info, audit log viewer, reset |
| π Connect | Auto-generated connection prompt with copy button |
| π Log | Real-time activity log |
The Agent tab lets you send commands to your own computer through the MCP tunnel β essentially a remote terminal:
- Select a tool from the dropdown (run_command, get_system_info, etc.)
- Type your command in the input field (e.g.,
ls -la /tmp) - Press Enter or click Send Request
- View the response in the output panel
- Use Quick Actions for one-click common commands (disk, RAM, processes, etc.)
- Click any item in Request History to reload it
The agent request uses the tunnel URL if available, or falls back to localhost:{port} for local testing.
The easiest way. Go to the π Connect tab in Z Control and click Copy Full Prompt. Paste it into your AI agent.
Your AI agent needs to send HTTP POST requests to:
POST https://<your-tunnel-url>.trycloudflare.com/mcp
Content-Type: application/json
Authorization: Bearer <your-api-key>
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"run_command","arguments":{"command":"ls -la","timeout":25}}}
Save this as laptop.sh and use echo 'command' | ./laptop.sh:
#!/bin/bash
MCP="https://<your-tunnel-url>.trycloudflare.com/mcp"
API_KEY='<your-api-key>'
CMD=$(cat)
PAYLOAD=$(python3 -c "import json,sys; cmd=sys.stdin.read().strip(); print(json.dumps({'jsonrpc':'2.0','id':1,'method':'tools/call','params':{'name':'run_command','arguments':{'command':cmd,'timeout':25}}}))" <<< "$CMD")
RESP=$(curl -s --connect-timeout 10 --max-time 30 -X POST "$MCP" -H 'Content-Type: application/json' -H "Authorization: Bearer $API_KEY" -d "$PAYLOAD")
echo "$RESP" | python3 -c "import sys,json; data=json.load(sys.stdin); text=data['result']['content'][0]['text']; info=json.loads(text); print(info['stdout']) if info['stdout'] else None; print('STDERR:',info['stderr'],file=sys.stderr) if info['stderr'] else None"See src/laptop.sh.example for a ready-to-use template.
| Layer | Mechanism |
|---|---|
| Authentication | Bearer token (API key) required for every request |
| Transport | HTTPS via Cloudflare Tunnel (TLS encryption) |
| File Isolation | write_file, read_file, delete_file restricted to allowed directories only |
| Command Blocklist | Dangerous commands blocked by substring matching: rm, sudo, shutdown, reboot, halt, mkfs, dd, chmod, chown, kill, killall, pkill |
| Path Traversal | All paths resolved and validated against allowed directories |
| Audit Logging | Every tool call logged with timestamp, tool name, arguments, and result |
| Timeout | All commands have configurable timeout (default 25s) |
- API Key Manager: Generate strong random keys, view strength meter
- Allowed Directories: Control which directories the AI can read/write
- Command Blocklist: View all blocked commands
- Audit Log: Review all actions taken by AI agents
- The default API key is a placeholder β always generate a new one via the Security tab
- Tunnel URLs change every time cloudflared restarts (they're ephemeral)
- The MCP server runs on localhost only β it's never directly exposed to the internet
- File operations (
write_file,read_file,delete_file) are restricted to~/projectsby default
See docs/SECURITY.md for detailed security documentation.
A bash wrapper for quick command execution from your terminal:
# Make it executable
chmod +x laptop.sh
# Run commands
echo "ls -la /tmp" | ./laptop.sh
echo "df -h" | ./laptop.sh
echo "whoami" | ./laptop.shSee src/laptop.sh.example for the template β just replace the MCP URL and API_KEY with your values.
Z-Agent-Remote-Control/
βββ README.md # This file
βββ CHANGELOG.md # Version history
βββ LICENSE # MIT License
βββ docs/
β βββ SETUP.md # Detailed setup guide
β βββ ARCHITECTURE.md # Technical architecture
β βββ SECURITY.md # Security model documentation
βββ src/
βββ z_control.py # Main GTK3 desktop GUI (Z Control v5)
βββ mcp_server.py # MCP server (stdlib Python, zero deps)
βββ laptop.sh.example # Shell helper template
| File | Description | Dependencies |
|---|---|---|
src/z_control.py |
Full GTK3 desktop app with 7 tabs, embedded MCP server, one-click install | Python 3, GTK3 (python3-gi), cloudflared |
src/mcp_server.py |
Standalone MCP server exposing 7 tools over HTTP | Python 3 stdlib only |
src/laptop.sh.example |
Bash helper for terminal-based command execution | bash, curl, python3 |
- Port in use: Another process is using port 9001. Check with
lsof -i :9001or change the port in Settings - Python missing: Ensure
python3is installed. Z Control auto-detects this
- cloudflared not found: Use the Setup tab's One-Click Install, or install manually:
# Option A: apt sudo apt install cloudflared # Option B: Direct download curl -sL https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o ~/.local/bin/cloudflared
- No internet: Cloudflare Tunnel requires internet connectivity
- Ensure both MCP server AND tunnel are running (green health dot)
- Check that the API key matches between Z Control and your AI agent
- Tunnel URLs are ephemeral β if cloudflared restarts, you get a new URL
- Ensure the .desktop file points to the correct path
- Try launching manually:
python3 ~/.local/share/z-control/z_control.py
sudo apt install python3-gi gir1.2-gtk-3.0Add this to your ~/.bashrc:
export PATH="$HOME/.local/bin:$PATH"Then source ~/.bashrc or log out/in.
The app features a dark-themed GTK3 interface with 7 tabs.
| Tab | Description |
|---|---|
| Setup | Prerequisites check and one-click install |
| Control | MCP server and tunnel management |
| Agent | Send requests and view responses |
| Security | API key and directory management |
| Connect | Copy connection prompt for AI agents |
- You download
z_control.pyβ a single Python file with everything embedded - Run it β
python3 z_control.pyβ a dark-themed GUI opens - Click Install β downloads cloudflared, sets up MCP server, generates API key
- Start services β one click starts both MCP server and tunnel
- Copy the prompt β the Connect tab has a ready-made prompt for your AI agent
- Paste into AI β your AI agent can now execute commands, read/write files, and get system info from your computer
- Monitor everything β audit log, activity log, connection health, all in the GUI
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This tool provides remote access to your computer. While security measures are in place (authentication, command blocklist, directory restrictions, audit logging), you should:
- Always use a strong, unique API key
- Review the audit log regularly
- Only enable tunnel when needed β use "Kill All & Lock Down" when done
- Keep allowed directories minimal β only grant access to what's needed
- Never share your tunnel URL and API key publicly
Use at your own risk. The authors are not responsible for any damage caused by misuse.