Run Claude agents in isolated Docker containers with streaming output, filesystem IPC, and built-in MCP tools. Pure JavaScript. Zero dependencies.
The core primitives you need to orchestrate Claude agents in containers.
Spawn Docker, Podman, or Apple containers. Stream agent output in real-time via sentinel-delimited JSON over stdout.
Atomic JSON file-based communication between host and container. No sockets, no ports—just files. Simple and reliable.
Per-agent concurrency with configurable global limits. Exponential backoff retry. One container per agent, up to N in parallel.
Built-in MCP server exposes send_message, schedule_task, and task lifecycle tools to the agent inside the container.
Allowlist-based volume mount validation. Blocks sensitive paths (.ssh, .env, credentials) by default. Symlink-aware.
The host side uses only Node.js built-ins. No native modules, no build step. Pure JavaScript ESM that just works.
Three steps to running your first containerized Claude agent.
import { runContainerAgent, createConfig } from 'jsclaw'; const config = createConfig({ containerImage: 'jsclaw-agent:latest', dataDir: './data', agentsDir: './agents', }); const agent = { name: 'my-agent', folder: 'my-agent' }; const input = { prompt: 'Analyze the codebase and suggest improvements.', agentId: 'my-agent', chatJid: 'user-1', isMain: true, }; const result = await runContainerAgent( agent, input, (proc, name) => console.log(`Container ${name} started`), async (output) => console.log('Agent:', output.result), config, ); console.log('Done:', result.status);
Host process communicates with isolated containers via stdin/stdout and filesystem IPC.
Host Process (your app) Docker Container ┌─────────────────────────┐ ┌─────────────────────────┐ │ │ │ │ │ container-runner.js │──stdin──▶ │ agent-runner.js │ │ Spawns containers, │◀─stdout── │ Drives Claude SDK │ │ streams output │ │ │ │ │ │ mcp-server.js │ │ ipc.js │◀──files── │ send_message, │ │ Polls IPC directories │──files──▶ │ schedule_task, ... │ │ │ │ │ │ agent-queue.js │ │ /workspace/agent/ │ │ Concurrency control │ │ Isolated filesystem │ │ │ │ │ └─────────────────────────┘ └─────────────────────────┘ │ │ data/ipc/{agent}/ /workspace/ipc/ messages/ tasks/ input/ messages/ tasks/ input/
Granular ESM exports — import only what you need.
| Export | Description |
|---|---|
createConfig(overrides?) |
Create configuration with defaults, env vars, and overrides |
runContainerAgent(agent, input, ...) |
Spawn a container, run a Claude agent, stream results |
GroupQueue |
Per-agent concurrency queue with global container limit |
startIpcWatcher(deps, config?) |
Poll IPC directories for messages and task operations |
writeIpcFile(dir, data) |
Atomic JSON file write (temp + rename) |
drainIpcDir(dir, filter?) |
Read all JSON files from a directory, parse, and delete |
validateAdditionalMounts(...) |
Validate volume mounts against a security allowlist |
buildVolumeMounts(agent, config) |
Build Docker volume mount arguments for an agent |
parseContainerOutput(buffer) |
Parse sentinel-delimited JSON from container stdout |
createLogger(options?) |
Minimal JSON logger (no dependencies) |
Tools available to the Claude agent inside the container via the built-in MCP server.
| Tool | Description |
|---|---|
send_message |
Send a message to the user or agent immediately |
schedule_task |
Schedule a cron, interval, or one-shot task |
list_tasks |
List all scheduled tasks for the current agent |
pause_task |
Pause a scheduled task by ID |
resume_task |
Resume a paused task by ID |
cancel_task |
Cancel and delete a scheduled task |
Configure via createConfig() overrides or environment variables.
| Env Variable | Default | Description |
|---|---|---|
JSCLAW_CONTAINER_IMAGE |
jsclaw-agent:latest | Docker image for agent containers |
JSCLAW_CONTAINER_RUNTIME |
docker | docker, podman, or container |
JSCLAW_CONTAINER_TIMEOUT |
1800000 | Idle timeout in milliseconds |
JSCLAW_MAX_CONCURRENT |
5 | Maximum concurrent containers |
JSCLAW_DATA_DIR |
./data | IPC data directory |
JSCLAW_GROUPS_DIR |
./agents | Group workspace directory |
ANTHROPIC_API_KEY |
— | Required for Claude API access |