Configuration
Two files, by intent:
.env— secrets, tokens, channel-enable flags, and the provider choice. Never committed. Bun loads it intoprocess.envautomatically at start.data/config.json— non-secret runtime config (bot name, allow-lists, timezone, capability flags, budgets, runtime mode). Generated bybun run setup, edited bybun run path,bun run container enable|disable, and by hand.
Precedence (lowest → highest):
- Defaults baked into src/lib/config.ts
data/config.jsonprocess.env(MARSCLAW_*/AGENT_PROVIDERoverrides — which includes anything in.env)
Env wins because existing users have .env muscle-memory and an upgrade must not silently change behaviour. Config is read once at boot and frozen — every change below needs a restart.
Provider gotcha. Both
bun run setupandbun run providerwriteAGENT_PROVIDER=…to.env, notagent_providertodata/config.json. Because env wins, editingagent_providerinconfig.jsonhas no effect while.envhas anAGENT_PROVIDERline.
Fail-closed config. If
data/config.jsonexists but can't be read or isn't a JSON object, the bot refuses to start rather than falling back to defaults (defaults have open allow-lists). Fix or delete the file.
.env reference
Channel tokens
| Key | Required | Notes |
|---|---|---|
TELEGRAM_BOT_TOKEN | per-channel | From @BotFather. Channel is on when this is set (uncommented). |
SLACK_BOT_TOKEN | per-channel | xoxb-…. Slack is on only when both Slack tokens are set. |
SLACK_APP_TOKEN | per-channel | xapp-…, needs connections:write |
MARSCLAW_WHATSAPP | per-channel | Set to 1; QR-scan auth on first run |
Provider auth
| Key | Required | Notes |
|---|---|---|
AGENT_PROVIDER | written by setup | gemini or claude. Overrides agent_provider in config.json. |
ANTHROPIC_API_KEY | optional | Metered API key. Only needed if not using Claude CLI's OAuth login. Its presence is what turns on the daily_usd_budget check. |
CLAUDE_CODE_OAUTH_TOKEN | optional | Long-lived OAuth token (claude setup-token). Written by bun run container login; held by the LLM proxy in container mode. |
GEMINI_API_KEY | optional | Makes the Gemini provider count as "authed" (for setup and failover), but the in-process Gemini path always authenticates with Google login OAuth (~/.gemini/oauth_creds.json); the key is not used for inference. |
GEMINI_MODEL | optional | Default gemini-2.5-flash |
GOOGLE_OAUTH_CLIENT_ID | optional | For Gmail/Drive/etc. via MCP — desktop OAuth client |
GOOGLE_OAUTH_CLIENT_SECRET | optional | Pairs with GOOGLE_OAUTH_CLIENT_ID |
Voice
| Key | Notes |
|---|---|
MARSCLAW_VOICE | Set to 1 to enable Whisper STT (equivalent to voice_enabled: true) |
WHISPER_URL | Default http://127.0.0.1:9000 |
WHISPER_MODEL | Read by tools/setup-voice.sh and the Whisper sidecar: tiny / base / small / medium / large (+ .en variants). Default base |
KOKORO_URL | Default http://127.0.0.1:9001 |
KOKORO_VOICE | Default voice (af_heart, af_bella, am_adam, …) |
KOKORO_FORMAT | ogg (voice note, default) / mp3 / wav |
YouTube transcripts
| Key | Notes |
|---|---|
MARSCLAW_YTDLP_PATH | Absolute path to yt-dlp. Setup pins this; the runtime falls back to common install dirs + a login-shell lookup if unset. See youtube.md |
MARSCLAW_YTDLP_VERSION | Version setup installs via pip (default 2025.09.05). Homebrew installs ignore it. |
Behavior overrides (shadow a data/config.json field)
| Key | config.json field | Notes |
|---|---|---|
AGENT_PROVIDER | agent_provider | gemini or claude |
MARSCLAW_BOT_NAME | bot_name | Name the agent uses for itself |
MARSCLAW_OWNER_NAME | owner_name | What the agent calls you |
MARSCLAW_OWNER_PHONE | owner_phone | Your WhatsApp number; non-digits are stripped |
MARSCLAW_TIMEZONE | timezone | IANA tz, e.g. Asia/Colombo |
MARSCLAW_LOCATION | location | Free-text, e.g. Colombo, Sri Lanka |
MARSCLAW_VOICE | voice_enabled | 1/true |
MARSCLAW_WHATSAPP_ALLOWED_JIDS | allowed_jids | Comma-list; empty allows all |
MARSCLAW_TELEGRAM_ALLOWED_CHATS | allowed_telegram_chats | Comma-list of chat ids; empty allows all |
MARSCLAW_SLACK_ALLOWED_USERS | allowed_slack_users | Comma-list of Slack user ids; empty allows all |
MARSCLAW_ALLOWED_PATHS | allowed_paths | Comma-list; default = cwd |
MARSCLAW_ALLOW_SHELL | allow_shell | 1 to expose the Bash tool (default 0) — see security.md |
MARSCLAW_ALLOW_WEB | allow_web | 1 to expose WebFetch/WebSearch (default 0) |
MARSCLAW_ALLOWED_WEB_DOMAINS | allowed_web_domains | Comma-list of hosts WebFetch may hit (e.g. wikipedia.org,*.gov) |
MARSCLAW_ALLOW_MUTATING_TOOLS | allow_mutating_tools | 1 to let the agent send mail / write Sheets / etc. (default 0) |
MARSCLAW_MUTATION_APPROVAL | mutation_approval | off (default) or all (per-call operator approval) |
MARSCLAW_EGRESS_MODE | egress_mode | off (default) or gateway |
MARSCLAW_RUNTIME | runtime | in-process (default) or container |
MARSCLAW_CONTAINER_TURN_URL | container_turn_url | Default http://127.0.0.1:8770 |
MARSCLAW_MAX_SESSIONS | max_sessions | LRU cap on Claude SDK sessions (default 20) |
MARSCLAW_CLAUDE_IDLE_MS | idle_ms | Recycle idle sessions after N ms (default 15 min) |
MARSCLAW_CLAUDE_MAX_SESSION_AGE_MS | max_session_age_ms | Hard cap on session lifetime (default 4 h; 0 disables) |
MARSCLAW_RATE_LIMIT_PER_MINUTE | rate_limit_per_minute | Inbound per-sender (default 10; 0 disables) |
MARSCLAW_RATE_LIMIT_PER_HOUR | rate_limit_per_hour | Inbound per-sender (default 60; 0 disables) |
MARSCLAW_DAILY_USD_BUDGET | daily_usd_budget | Anthropic spend cap (0 disables; metered keys only) |
Env-only knobs
| Key | Default | Notes |
|---|---|---|
MARSCLAW_AGENT_TIMEOUT_MS | 300000 | Per-turn timeout |
MARSCLAW_AUDIT_LOG | logs/audit.log | Append-only security audit log |
MARSCLAW_ALERT_THREAD | auto | Thread id (e.g. telegram:123) that receives audit-density alerts. Auto-picked only when WhatsApp or Telegram has exactly one allow-listed sender; Slack must be set explicitly. |
MARSCLAW_HEALTH_PORT | unset (off) | Enables the 127.0.0.1 health endpoint on this port |
MARSCLAW_EGRESS_ENFORCED | unset | 1 asserts kernel-level egress enforcement is in place; only then does egress_mode: gateway relax the URL allow-list. See security.md. |
MARSCLAW_LLM_PROXY_URL / MARSCLAW_LLM_PROXY_TOKEN | unset | In-process credential isolation: when both are set, the Claude subprocess gets the proxy URL + session token instead of the real credential |
MARSCLAW_WHATSAPP_VERBOSE | unset | 1 for Baileys protocol logs |
MARSCLAW_LOG_FILE | unset | Tee the structured log to this file (the launchd plist sets logs/marsclaw.log) |
MARSCLAW_LOG_MAX_BYTES / MARSCLAW_LOG_ROTATIONS | 10 MB / 5 | In-process rotation of MARSCLAW_LOG_FILE |
MARSCLAW_LOG_RING_SIZE | 200 | Lines kept in memory for crash dumps |
MARSCLAW_BACKUP_DIR / MARSCLAW_BACKUP_KEEP | data/backups / 7 | Backup location and retention |
MARSCLAW_TOOL_PERMISSIONS | — | Removed. Setting it to bypass only logs a warning; the tool gate is always on. |
LOG_LEVEL | info | debug / info / warn / error / fatal |
Container runtime
Only read when runtime: container. See container-runtime.md.
| Key | Default | Notes |
|---|---|---|
LLM_PROXY_SESSION_TOKEN | minted by container login | Rotatable token the container holds instead of the real credential |
MARSCLAW_MCP_TOKEN | minted by container enable | Bearer token for the host HTTP MCP server. If unset, the HTTP MCP accepts unauthenticated requests. |
EGRESS_PROXY_TOKEN | unset | Opt-in auth for the egress gateway. Not minted automatically. |
MARSCLAW_DOCKER_BIN | first of /opt/homebrew/bin/docker, /usr/local/bin/docker, /usr/bin/docker, docker | Container CLI |
MARSCLAW_AGENT_IMAGE / MARSCLAW_AGENT_CONTAINER | marsclaw-agent:latest / marsclaw-agent | Image and container name |
MARSCLAW_CONTAINER_IDLE_MS | 15 min | Stop the container after this much inactivity |
MARSCLAW_TURN_PORT, LLM_PROXY_PORT, MARSCLAW_MCP_HTTP_PORT, EGRESS_GATEWAY_PORT | 8770, 8765, 8766, 8775 | Ports |
MARSCLAW_SHARED_MEDIA / MARSCLAW_AGENT_HOME | data/shared / data/agent-home | Shared media dir (same path on both sides) and the container's ~/.claude store |
Paths
| Key | Default |
|---|---|
MARSCLAW_DB | data/marsclaw.db |
MARSCLAW_CONFIG | data/config.json |
MARSCLAW_WHATSAPP_AUTH | data/whatsapp-auth |
MARSCLAW_WHATSAPP_MEDIA | data/shared/whatsapp-media (runtime) |
MARSCLAW_TELEGRAM_MEDIA | data/shared/telegram-media |
MARSCLAW_SLACK_MEDIA | data/shared/slack-media |
MARSCLAW_VOICE_OUT | data/voice-out |
MARSCLAW_HEARTBEAT | data/heartbeat |
MARSCLAW_USAGE | data/usage.jsonl |
MARSCLAW_CONVERSATIONS | conversations |
MARSCLAW_CIRCUIT_BREAKER | data/circuit-breaker.json |
MARSCLAW_WHATSAPP_REAUTH_MARKER | data/whatsapp-needs-reauth |
MARSCLAW_MIGRATIONS_DIR | migrations |
MARSCLAW_ENV_FILE | .env (used by bun run container) |
GEMINI_BIN / CLAUDE_BIN | gemini / claude — used by setup/provider to check for and install the CLIs (the runtime uses the SDKs, not these binaries) |
data/config.json reference
Generated by setup; safe to edit while the bot is stopped. Shape mirrors src/lib/config.ts.
{
"bot_name": "Mars",
"owner_name": "Dimuthu",
"owner_phone": "94701234567",
// One-shot WhatsApp pairing. Setup sets these; the bot clears them once paired.
"whatsapp_pair_owner": false,
"whatsapp_pair_code": "",
"whatsapp_pair_expires_at": 0, // epoch ms; setup sets now + 5 min. 0 = no expiry
// Inbound allow-lists. Empty = allow all (with a per-sender warning).
"allowed_jids": ["94701234567@s.whatsapp.net"],
"allowed_telegram_chats": ["123456789"],
"allowed_slack_users": ["U01ABC23DEF"],
// Filesystem sandbox for the agent's Read/Write/Edit/MultiEdit/NotebookEdit/
// Glob/Grep tools and for send_file. Defaults to [cwd].
// Sensitive files (.env, data/secrets, data/config.json, data/whatsapp-auth,
// data/marsclaw.db, ~/.claude.json, ~/.claude, ~/.gemini) are blocked
// regardless of what's listed here. See docs/security.md.
"allowed_paths": ["/Users/you/marsclaw", "/Users/you/Documents/notes"],
// Capability flags — all off by default. See docs/security.md.
"allow_shell": false, // expose the Bash tool?
"allow_web": false, // expose WebFetch/WebSearch?
"allowed_web_domains": [ // WebFetch host allow-list (entry covers apex + subdomains)
"wikipedia.org",
"developer.mozilla.org",
"github.com"
],
"allow_mutating_tools": false, // gmail_send, sheets_write, calendar_create_event, *_raw writes
"mutation_approval": "off", // "all" = per-call operator approval (supersedes the flag above)
"egress_mode": "off", // "gateway" = route via SSRF gateway (needs MARSCLAW_EGRESS_ENFORCED=1)
// Where the Claude agent runs. "container" = isolated box; see docs/container-runtime.md.
"runtime": "in-process",
"container_turn_url": "http://127.0.0.1:8770",
// Claude SDK session cap & lifetimes.
"max_sessions": 20,
"idle_ms": 900000,
"max_session_age_ms": 14400000,
"timezone": "Asia/Colombo",
"location": "Colombo, Sri Lanka",
"voice_enabled": true,
"agent_provider": "claude", // shadowed by AGENT_PROVIDER in .env (setup writes it there)
// Extra Bash patterns to deny (JS regex source), on top of the built-ins.
"extra_bash_denylist": [],
// Inbound rate-limits (per sender, sliding window). 0 disables.
"rate_limit_per_minute": 10,
"rate_limit_per_hour": 60,
// Anthropic spend cap in USD (UTC day). 0 disables. Only enforced with ANTHROPIC_API_KEY.
"daily_usd_budget": 0
}
Allowed paths
The agent's Read, Write, Edit, MultiEdit, NotebookEdit, Glob, and Grep tools are gated against allowed_paths. Default is just the project root. Glob/Grep without a path argument are treated as searching the bot's cwd and go through the same checks.
bun run path list
bun run path add /Users/you/Documents/notes
bun run path remove /Users/you/Documents/notes
bun run path reset # back to [cwd]
The same sandbox applies to MCP send_file — files outside allowed_paths cannot be delivered.
A separate sensitive-path list sits in front of allowed_paths and blocks .env, data/secrets/, data/config.json, data/whatsapp-auth/, data/marsclaw.db, ~/.claude.json, ~/.claude/, and ~/.gemini/ regardless of how allowed_paths is configured (symlinks are resolved first). Grep/Glob additionally refuse a search root that contains any sensitive subtree. See security.md.
There is no bypass switch. The old MARSCLAW_TOOL_PERMISSIONS=bypass escape hatch has been removed; setting it only logs a warning.
Capability flags (security defaults)
All are off by default; turning each one on reopens a specific attack surface that security.md walks through in detail. These apply to the in-process runtime — in container mode the box is the boundary and the first four are inert.
| Flag | Default | What it gates |
|---|---|---|
allow_shell | false | The Bash tool. A denylist can't make shell safe; removal is the only sound posture. |
allow_web | false | WebFetch and WebSearch. The persona tells the agent to delegate page reads to a researcher subagent. |
allowed_web_domains | [] | Host allow-list for WebFetch. An entry covers the apex and its subdomains; *.example.com is equivalent. |
allow_mutating_tools | false | Outbound/mutating MCP tools: gmail_send, sheets_write, calendar_create_event, write-style *_raw calls. |
mutation_approval | off | all = each mutating call blocks until you reply a one-time code in chat (120 s window). Forced to all for the container runtime's MCP sidecar unless MARSCLAW_MUTATION_APPROVAL is set. |
egress_mode | off | gateway relaxes the WebFetch allow-list only when MARSCLAW_EGRESS_ENFORCED=1. |
Bash denylist
extra_bash_denylist adds JavaScript regex source strings to the built-in patterns (rm -rf /, rm -rf ~, rm -rf *, chmod 000, dd of=, fork bombs, mkfs, shred, security find-generic-password, data/secrets). Only relevant when allow_shell is on — when shell is off, Bash isn't available regardless.
Persona & memory files
| File | Purpose |
|---|---|
CLAUDE.md | Persona for Claude. Loaded by the SDK (settingSources: ['project', 'user']) in-process; read explicitly (with @imports inlined) and appended to the system prompt in container mode. Also the project instructions for the claude CLI in this repo. |
GEMINI.md | Persona for Gemini, loaded via @google/gemini-cli-core's memory loader and prepended to every turn |
skills/*.md | Sub-instructions referenced from a persona via @skills/<name>.md |
MEMORY.md | The agent's own long-term notes. Local-only, gitignored |
MEMORY.template.md | Seed copied to MEMORY.md on boot if it's missing; setup appends an ## Owner section |
wiki/*.md | Optional, gitignored longer pages the agent can read on demand (mounted read-write in container mode) |
The two persona files are maintained by hand and have drifted: CLAUDE.md also documents send_file and the memory-size / no-infrastructure-speculation rules that GEMINI.md lacks. Mirror changes manually.
On top of CLAUDE.md, the in-process Claude path appends a fixed chat persona (bot name, owner name, "you are not in a coding session", and the researcher-delegation rule) from CHAT_PERSONA_APPEND in claude-sdk.ts.
Reset memory: rm MEMORY.md && bun run start.
Multiple Google accounts
Refresh tokens are stored in the macOS Keychain (service marsclaw) or 0600 files under data/secrets/ on Linux. bun run google login [alias] adds an account (alias defaults to default); bun run google use <alias> changes the default. The MCP tools accept an account argument; when omitted they use the default alias (or the only account, if there's just one). See google.md.