Skip to main content

Configuration

Two files, by intent:

  • .env — secrets, tokens, channel-enable flags, and the provider choice. Never committed. Bun loads it into process.env automatically at start.
  • data/config.json — non-secret runtime config (bot name, allow-lists, timezone, capability flags, budgets, runtime mode). Generated by bun run setup, edited by bun run path, bun run container enable|disable, and by hand.

Precedence (lowest → highest):

  1. Defaults baked into src/lib/config.ts
  2. data/config.json
  3. process.env (MARSCLAW_* / AGENT_PROVIDER overrides — 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 setup and bun run provider write AGENT_PROVIDER=… to .env, not agent_provider to data/config.json. Because env wins, editing agent_provider in config.json has no effect while .env has an AGENT_PROVIDER line.

Fail-closed config. If data/config.json exists 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​

KeyRequiredNotes
TELEGRAM_BOT_TOKENper-channelFrom @BotFather. Channel is on when this is set (uncommented).
SLACK_BOT_TOKENper-channelxoxb-…. Slack is on only when both Slack tokens are set.
SLACK_APP_TOKENper-channelxapp-…, needs connections:write
MARSCLAW_WHATSAPPper-channelSet to 1; QR-scan auth on first run

Provider auth​

KeyRequiredNotes
AGENT_PROVIDERwritten by setupgemini or claude. Overrides agent_provider in config.json.
ANTHROPIC_API_KEYoptionalMetered 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_TOKENoptionalLong-lived OAuth token (claude setup-token). Written by bun run container login; held by the LLM proxy in container mode.
GEMINI_API_KEYoptionalMakes 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_MODELoptionalDefault gemini-2.5-flash
GOOGLE_OAUTH_CLIENT_IDoptionalFor Gmail/Drive/etc. via MCP — desktop OAuth client
GOOGLE_OAUTH_CLIENT_SECREToptionalPairs with GOOGLE_OAUTH_CLIENT_ID

Voice​

KeyNotes
MARSCLAW_VOICESet to 1 to enable Whisper STT (equivalent to voice_enabled: true)
WHISPER_URLDefault http://127.0.0.1:9000
WHISPER_MODELRead by tools/setup-voice.sh and the Whisper sidecar: tiny / base / small / medium / large (+ .en variants). Default base
KOKORO_URLDefault http://127.0.0.1:9001
KOKORO_VOICEDefault voice (af_heart, af_bella, am_adam, …)
KOKORO_FORMATogg (voice note, default) / mp3 / wav

YouTube transcripts​

KeyNotes
MARSCLAW_YTDLP_PATHAbsolute 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_VERSIONVersion setup installs via pip (default 2025.09.05). Homebrew installs ignore it.

Behavior overrides (shadow a data/config.json field)​

Keyconfig.json fieldNotes
AGENT_PROVIDERagent_providergemini or claude
MARSCLAW_BOT_NAMEbot_nameName the agent uses for itself
MARSCLAW_OWNER_NAMEowner_nameWhat the agent calls you
MARSCLAW_OWNER_PHONEowner_phoneYour WhatsApp number; non-digits are stripped
MARSCLAW_TIMEZONEtimezoneIANA tz, e.g. Asia/Colombo
MARSCLAW_LOCATIONlocationFree-text, e.g. Colombo, Sri Lanka
MARSCLAW_VOICEvoice_enabled1/true
MARSCLAW_WHATSAPP_ALLOWED_JIDSallowed_jidsComma-list; empty allows all
MARSCLAW_TELEGRAM_ALLOWED_CHATSallowed_telegram_chatsComma-list of chat ids; empty allows all
MARSCLAW_SLACK_ALLOWED_USERSallowed_slack_usersComma-list of Slack user ids; empty allows all
MARSCLAW_ALLOWED_PATHSallowed_pathsComma-list; default = cwd
MARSCLAW_ALLOW_SHELLallow_shell1 to expose the Bash tool (default 0) — see security.md
MARSCLAW_ALLOW_WEBallow_web1 to expose WebFetch/WebSearch (default 0)
MARSCLAW_ALLOWED_WEB_DOMAINSallowed_web_domainsComma-list of hosts WebFetch may hit (e.g. wikipedia.org,*.gov)
MARSCLAW_ALLOW_MUTATING_TOOLSallow_mutating_tools1 to let the agent send mail / write Sheets / etc. (default 0)
MARSCLAW_MUTATION_APPROVALmutation_approvaloff (default) or all (per-call operator approval)
MARSCLAW_EGRESS_MODEegress_modeoff (default) or gateway
MARSCLAW_RUNTIMEruntimein-process (default) or container
MARSCLAW_CONTAINER_TURN_URLcontainer_turn_urlDefault http://127.0.0.1:8770
MARSCLAW_MAX_SESSIONSmax_sessionsLRU cap on Claude SDK sessions (default 20)
MARSCLAW_CLAUDE_IDLE_MSidle_msRecycle idle sessions after N ms (default 15 min)
MARSCLAW_CLAUDE_MAX_SESSION_AGE_MSmax_session_age_msHard cap on session lifetime (default 4 h; 0 disables)
MARSCLAW_RATE_LIMIT_PER_MINUTErate_limit_per_minuteInbound per-sender (default 10; 0 disables)
MARSCLAW_RATE_LIMIT_PER_HOURrate_limit_per_hourInbound per-sender (default 60; 0 disables)
MARSCLAW_DAILY_USD_BUDGETdaily_usd_budgetAnthropic spend cap (0 disables; metered keys only)

Env-only knobs​

KeyDefaultNotes
MARSCLAW_AGENT_TIMEOUT_MS300000Per-turn timeout
MARSCLAW_AUDIT_LOGlogs/audit.logAppend-only security audit log
MARSCLAW_ALERT_THREADautoThread 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_PORTunset (off)Enables the 127.0.0.1 health endpoint on this port
MARSCLAW_EGRESS_ENFORCEDunset1 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_TOKENunsetIn-process credential isolation: when both are set, the Claude subprocess gets the proxy URL + session token instead of the real credential
MARSCLAW_WHATSAPP_VERBOSEunset1 for Baileys protocol logs
MARSCLAW_LOG_FILEunsetTee the structured log to this file (the launchd plist sets logs/marsclaw.log)
MARSCLAW_LOG_MAX_BYTES / MARSCLAW_LOG_ROTATIONS10 MB / 5In-process rotation of MARSCLAW_LOG_FILE
MARSCLAW_LOG_RING_SIZE200Lines kept in memory for crash dumps
MARSCLAW_BACKUP_DIR / MARSCLAW_BACKUP_KEEPdata/backups / 7Backup location and retention
MARSCLAW_TOOL_PERMISSIONS—Removed. Setting it to bypass only logs a warning; the tool gate is always on.
LOG_LEVELinfodebug / info / warn / error / fatal

Container runtime​

Only read when runtime: container. See container-runtime.md.

KeyDefaultNotes
LLM_PROXY_SESSION_TOKENminted by container loginRotatable token the container holds instead of the real credential
MARSCLAW_MCP_TOKENminted by container enableBearer token for the host HTTP MCP server. If unset, the HTTP MCP accepts unauthenticated requests.
EGRESS_PROXY_TOKENunsetOpt-in auth for the egress gateway. Not minted automatically.
MARSCLAW_DOCKER_BINfirst of /opt/homebrew/bin/docker, /usr/local/bin/docker, /usr/bin/docker, dockerContainer CLI
MARSCLAW_AGENT_IMAGE / MARSCLAW_AGENT_CONTAINERmarsclaw-agent:latest / marsclaw-agentImage and container name
MARSCLAW_CONTAINER_IDLE_MS15 minStop the container after this much inactivity
MARSCLAW_TURN_PORT, LLM_PROXY_PORT, MARSCLAW_MCP_HTTP_PORT, EGRESS_GATEWAY_PORT8770, 8765, 8766, 8775Ports
MARSCLAW_SHARED_MEDIA / MARSCLAW_AGENT_HOMEdata/shared / data/agent-homeShared media dir (same path on both sides) and the container's ~/.claude store

Paths​

KeyDefault
MARSCLAW_DBdata/marsclaw.db
MARSCLAW_CONFIGdata/config.json
MARSCLAW_WHATSAPP_AUTHdata/whatsapp-auth
MARSCLAW_WHATSAPP_MEDIAdata/shared/whatsapp-media (runtime)
MARSCLAW_TELEGRAM_MEDIAdata/shared/telegram-media
MARSCLAW_SLACK_MEDIAdata/shared/slack-media
MARSCLAW_VOICE_OUTdata/voice-out
MARSCLAW_HEARTBEATdata/heartbeat
MARSCLAW_USAGEdata/usage.jsonl
MARSCLAW_CONVERSATIONSconversations
MARSCLAW_CIRCUIT_BREAKERdata/circuit-breaker.json
MARSCLAW_WHATSAPP_REAUTH_MARKERdata/whatsapp-needs-reauth
MARSCLAW_MIGRATIONS_DIRmigrations
MARSCLAW_ENV_FILE.env (used by bun run container)
GEMINI_BIN / CLAUDE_BINgemini / 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.

FlagDefaultWhat it gates
allow_shellfalseThe Bash tool. A denylist can't make shell safe; removal is the only sound posture.
allow_webfalseWebFetch 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_toolsfalseOutbound/mutating MCP tools: gmail_send, sheets_write, calendar_create_event, write-style *_raw calls.
mutation_approvaloffall = 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_modeoffgateway 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​

FilePurpose
CLAUDE.mdPersona 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.mdPersona for Gemini, loaded via @google/gemini-cli-core's memory loader and prepended to every turn
skills/*.mdSub-instructions referenced from a persona via @skills/<name>.md
MEMORY.mdThe agent's own long-term notes. Local-only, gitignored
MEMORY.template.mdSeed copied to MEMORY.md on boot if it's missing; setup appends an ## Owner section
wiki/*.mdOptional, 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.