CLOUDFLARE WORKERS · SHELL API
agent-exec-api
Shell command execution API for Cloudflare Worker agents
A secure, lightweight HTTP service that provides authenticated command execution capabilities for environments without native shell access, specifically designed for Cloudflare Workers.
Explore capabilitiesFeatures
Everything needed to run shell commands safely inside Worker-like environments.
Authenticated Execution
Bearer token authentication with constant-time comparison.
Security Hardened
Rate limiting, request size caps, command timeouts, and unprivileged execution.
Docker Ready
Alpine-based container optimized for small deployments (256MB+ hosts).
Process Management
Proper process group handling with timeout-based cleanup.
Cross-Platform
Supports both Unix shells (bash) and Windows (cmd.exe).
API Endpoints
GET /health
Public health check endpoint returning {"ok": true}
POST /exec
Authenticated command execution endpoint
Request:
Response:
Configuration
| Environment Variable | Default | Description |
|---|---|---|
| SHELL_TOKEN | *required | Bearer token for authentication |
| PORT | 3000 | Server port |
| CMD_TIMEOUT_MS | 20000 | Command timeout in milliseconds |
| MAX_OUTPUT | 60000 | Maximum output size in bytes |
| RATE_LIMIT_PER_MIN | 30 | Requests per minute per IP |
Tech Stack
- Runtime Node.js 20+ (pure ESM)
- Container Alpine Linux with bash
- Security Crypto-based authentication, process isolation
- Deployment Docker container running as unprivileged user
Quick Start
# Set authentication token export SHELL_TOKEN=****** # Start server npm start # Or with Docker docker build -t agent-exec-api . docker run -e SHELL_TOKEN=****** -p 3000:3000 agent-exec-api