An army of agents. Run autonomous Claude bots in Docker containers with scheduling, webhooks, and bot-to-bot communication over Tailscale.
# Install
npm install -g mecha
# Initialize (builds Docker image)
mecha init
# Set your API key
export ANTHROPIC_API_KEY=sk-ant-...
# Or use a profile:
mecha auth add anthropic-main sk-ant-...
# Spawn a bot inline
mecha spawn --name greeter --system "You greet people warmly."
# Chat with it
mecha chat greeter "Hello!"
# List bots
mecha ls
# Stop / restart / remove
mecha stop greeter
mecha start greeter
mecha rm greetername: reviewer
system: |
You are a code reviewer. You review PRs for bugs,
security issues, and style violations.
model: sonnet
auth: anthropic-main
max_turns: 25
max_budget_usd: 1.00
schedule:
- cron: "*/30 * * * *"
prompt: "Check for new unreviewed PRs."
webhooks:
accept:
- "pull_request.opened"
- "pull_request.synchronize"
workspace: ./myproject
expose: 8080mecha spawn reviewer.yaml| Command | Description |
|---|---|
mecha init [--headscale] |
Initialize mecha, build Docker image |
mecha spawn <config> [--dir] [--expose] |
Spawn bot from config file |
mecha spawn --name X --system "..." [--model M] |
Spawn bot inline |
mecha start <name> |
Start a stopped bot |
mecha stop <name> |
Stop a running bot |
mecha rm <name> |
Remove a bot |
mecha ls |
List all bots |
mecha chat <name> "prompt" |
Send a prompt to a bot |
mecha logs <name> [-f] |
Show bot logs |
mecha auth add <profile> <key> |
Add auth profile |
mecha auth list |
List auth profiles |
mecha auth swap <bot> <profile> |
Swap auth for a bot |
mecha token |
Generate a bot token |
mecha dashboard [--port N] |
Start fleet dashboard |
Host (CLI) Container (Agent)
───────────────────────── ──────────────────────────
src/cli.ts agent/entry.ts
src/docker.ts (dockerode) agent/server.ts (Hono)
src/store.ts (~/.mecha/) agent/session.ts
src/config.ts agent/scheduler.ts (croner)
src/auth.ts agent/webhook.ts
src/dashboard-server.ts agent/costs.ts
agent/activity.ts
agent/tools/mecha-server.ts
agent/tools/mecha-call.ts
agent/tools/mecha-list.ts
Bots discover each other via Tailscale/Headscale and communicate using built-in MCP tools:
mecha_call— send a prompt to another botmecha_list— discover available bots on the networkmecha_new_session— start a fresh conversation
Bots run prompts on cron schedules with safety rails:
- Max 50 runs per day
- 10 minute timeout per run
- Auto-pause after 5 consecutive errors
- Skip if busy
mecha dashboard
# Opens http://localhost:7700Fleet dashboard shows all bots with status, costs, and a communication map. Click a bot to access its individual dashboard with chat, tasks, schedule, logs, and config views.
The dashboard now uses a local browser session on localhost so the SPA and proxied bot dashboards work without manually copying bearer tokens into browser requests.
Auth works via environment variable or named profiles:
# Environment variable (simplest)
export ANTHROPIC_API_KEY=sk-ant-...
# Named profile
mecha auth add anthropic-main sk-ant-...
mecha auth add tailscale-main tskey-auth-...Profiles are stored at ~/.mecha/auth/<name>.json.
- Workspace-mounted bots load project settings (
.claude/settings.json,CLAUDE.md, skills) from the mounted workspace. - Bots without a mounted workspace run from a stable state-backed working directory and only load user settings.
- Host Codex auth is not copied into containers by default. Opt in with
MECHA_COPY_HOST_CODEX_AUTH=1if you explicitly want that behavior.
# Fast local tests
npm test
# Docker-dependent suites
npm run test:docker
# Live SDK/API suite (costs money)
npm run test:live- Node.js 22+
- Docker (Colima, Docker Desktop, or any OCI runtime)
- Tailscale (optional, for multi-machine mesh)