Skip to content

Configuration and Flags

Mcdavid Obioha edited this page Dec 1, 2026 · 3 revisions

Configuration and Flags

Kera is configured at process startup with CLI flags and KERA_* environment variables. Flags take precedence over environment variables, which take precedence over defaults.

  • Use --flag value or --flag=value.
  • Unknown flags are rejected.
  • Numeric values are parsed as decimal integers and must fit JavaScript's safe integer range.
  • Kera does not load .env files automatically. Set variables in your shell, process manager, or MCP client env block.

The table lists shared settings. See Terminal CLI for command-specific options and Local Dashboard for browser setup.


Complete flag reference

Flag Environment variable Default Accepted values
--target <url> KERA_TARGET_URL Required Absolute http: or https: URL without credentials
--host <addr> KERA_LISTEN_HOST 127.0.0.1 Hostname or IP address; IPv6 literals may be bracketed
--port <number> KERA_LISTEN_PORT 4000 Integer 1–65535
--tunnel KERA_TUNNEL false Boolean flag; env accepts only true or false
— KERA_CLOUDFLARED_PATH Auto Path to a cloudflared executable
--ui-port KERA_UI_PORT 4040 Integer 1–65535; kera ui also accepts --port
--data-dir <path> KERA_DATA_DIR ~/.kera Non-empty directory path; ~/ expands to home
--max-requests <n> KERA_MAX_STORED_REQUESTS 1000 Positive integer; all retained rows count
--max-body-bytes <n> KERA_MAX_BODY_BYTES 1048576 (1 MiB) Positive integer; per request or response body
--log-level <level> KERA_LOG_LEVEL info error, warn, info, debug
— KERA_REDACTION_POLICY redact redact or allow-unredacted-raw (environment-only)

--data-dir, --max-requests, --max-body-bytes, and --log-level are MCP startup flags (kera-mcp or kera mcp). Set the corresponding environment variables for terminal commands.


--target / KERA_TARGET_URL (required)

The local application Kera forwards to and the only destination replay may use in Phase 1.

npx -y kera-mcp --target http://127.0.0.1:3000

Rules:

  • Must be an absolute HTTP or HTTPS URL.
  • Must include a hostname.
  • Must not include a username or password.
  • An explicit port must be 1–65535.
  • Only the target's origin is used. Incoming paths and raw queries are forwarded as received.
  • Startup fails if the target resolves to Kera's own listener on the same port. localhost, IPv4 loopback, and ::1 are treated as equivalent for this check.
  • If a hostname needed for the self-loop check cannot be resolved, startup fails before creating the data directory.

Using a hostname that requires local DNS is supported. For a local app, http://127.0.0.1:3000 or http://localhost:3000 is typical.


--host / KERA_LISTEN_HOST

The address Kera binds to. Default: 127.0.0.1.

# Default: localhost only
--host 127.0.0.1

# IPv6 loopback
--host '::1'
# or bracketed
--host '[::1]'

# Exposes the listener to your network — use deliberately
--host 0.0.0.0

Kera defaults to loopback on purpose. Binding to 0.0.0.0 or a LAN address exposes a proxy that can forward traffic to your local app. See Security and Privacy before changing it.

EADDRINUSE at startup means another process owns the port. Stop it or change --port.


--port / KERA_LISTEN_PORT

Local port for the Kera HTTP listener. Default: 4000.

--port 4000

Send application/webhook traffic here instead of directly to your app:

POST http://127.0.0.1:4000/webhooks/stripe   ← Kera
                     │
                     ▼
POST http://127.0.0.1:3000/webhooks/stripe   ← your app

Run one Kera instance per capture port.


Tunnel mode: --tunnel / KERA_TUNNEL

Start an opt-in Cloudflare Quick Tunnel that forwards public HTTPS traffic to Kera's loopback listener. Default: false (off).

# CLI flag (boolean, no value)
npx -y kera-mcp --target http://127.0.0.1:3000 --tunnel

# Environment
KERA_TUNNEL=true npx -y kera-mcp --target http://127.0.0.1:3000

# Explicitly disabled
KERA_TUNNEL=false npx -y kera-mcp --target http://127.0.0.1:3000

Rules and behavior:

  • Current npm releases check KERA_CLOUDFLARED_PATH first, then system PATH, then the included cloudflared wrapper. If necessary, the wrapper downloads and caches the native executable in KERA_DATA_DIR after you enable tunneling.
  • For kera listen, opt in with --tunnel; KERA_TUNNEL applies to the MCP server.
  • Requires listenHost to be exactly 127.0.0.1. localhost, ::1, 0.0.0.0, and LAN addresses are rejected when tunneling is enabled.
  • The environment value accepts only true or false; other values fail configuration parsing.
  • Kera launches cloudflared with the local origin forced to http://127.0.0.1:<listenPort>, named-tunnel config disabled, --no-autoupdate, a loopback-only metrics address, and --loglevel info.
  • Kera filters TUNNEL_*, CLOUDFLARED_*, and NO_TLS_VERIFY from the child environment.
  • After the executable is ready, startup waits up to 30 seconds for a valid https://…trycloudflare.com URL and the first registered edge connection.
  • The URL is public, unauthenticated, random, and changes every session.
  • Both cloudflared streams are logged to Kera's stderr; recognized URL credentials and query secrets are redacted. Nothing goes to MCP stdout.
  • On failure, local capture and the other MCP tools remain available. Use get_tunnel_url for status.
  • On shutdown, Kera sends SIGTERM and escalates to SIGKILL after 2 seconds.

A tunnel exposes every route served by your configured upstream through Kera. Read Security and Privacy before enabling it.


--data-dir / KERA_DATA_DIR

Directory for the local SQLite database. Default: ~/.kera.

--data-dir ~/.kera
--data-dir /Users/you/dev/kera-data

Behavior:

  • ~ and ~/... expand to the user's home directory.
  • Relative paths are resolved from the process working directory.
  • loadConfig() returns an absolute path.
  • The directory is created recursively with mode 0700 on POSIX.
  • An existing directory must already be 0700; otherwise startup fails with an actionable error.
  • Symbolic links are rejected for the data directory, database, and SQLite sidecars.
  • The database file is <dataDir>/traffic.db.

Files written:

~/.kera/
├── traffic.db        # SQLite database, mode 0600
├── traffic.db-wal    # WAL sidecar, mode 0600
└── traffic.db-shm    # shared-memory sidecar, mode 0600

POSIX modes are not applied on Windows.


--max-requests / KERA_MAX_STORED_REQUESTS

Ring-buffer size for stored captures. Default: 1000.

  • Must be a positive integer.
  • Every persisted row counts: completed exchanges, replay captures, proxy failures, timeouts, and interrupted exchanges.
  • After an insert, the oldest rows are pruned so at most this many remain.
  • The newest timestamps are retained; later inserts win timestamp ties.
  • Insert and prune commit in one transaction.
  • Setting a smaller value prunes immediately on the next insert (or when prune() is called by a library caller).

This limit is about row count, not disk size. Body storage is additionally bounded per body by --max-body-bytes.


--max-body-bytes / KERA_MAX_BODY_BYTES

Per-body capture limit. Default: 1048576 bytes (1 MiB).

  • Applies independently to each request body and each response body.
  • The proxy keeps up to this many bytes per body while still counting all observed bytes.
  • If the limit is exceeded, the capture is marked truncated and the original size is retained in metadata.
  • An empty body is stored as NULL with size zero.
  • Replay uses min(maxBodyBytes, 8 MiB) as its request/response cap.
  • Raising this increases local storage and the amount of sensitive data that may be stored.

The proxy streams with backpressure; it does not buffer an unbounded body in memory just to capture it.


--log-level / KERA_LOG_LEVEL

Diagnostic verbosity. Default: info.

Value Behavior
error Errors only. Suppresses the readiness line.
warn Warnings and errors. Suppresses the readiness line.
info Readiness line plus normal diagnostics.
debug Debug diagnostics; same readiness behavior as info.

All diagnostics go to stderr. stdout is reserved exclusively for MCP JSON-RPC messages. Kera never prints banners, progress indicators, or startup text to stdout.

Logs avoid full request bodies and secrets by default.


KERA_REDACTION_POLICY (environment-only)

Controls whether raw inspection may expose unredacted values. Default: redact.

Value Effect
redact Always mask recognized sensitive headers, query/form fields, and JSON fields.
allow-unredacted-raw inspect_request with raw: true may return unredacted detail. Compressed output still redacts.

There is no CLI flag for this option. Set it in the environment that launches the MCP process:

{
  "mcpServers": {
    "kera": {
      "command": "npx",
      "args": ["-y", "kera-mcp", "--target", "http://127.0.0.1:3000"],
      "env": {
        "KERA_REDACTION_POLICY": "allow-unredacted-raw"
      }
    }
  }
}

Warnings:

  • This can expose live credentials to any MCP caller that requests raw: true.
  • Inspection callers cannot override the startup policy.
  • Payload diffs always mask sensitive JSON, independent of this setting.
  • Prefer redact unless there is a specific, temporary debugging need.

See Security and Privacy.


Precedence and examples

# Flags only
npx -y kera-mcp \
  --target http://127.0.0.1:3000 \
  --port 4000 \
  --data-dir ~/.kera

# Environment only
KERA_TARGET_URL=http://127.0.0.1:3000 \
KERA_LISTEN_PORT=4000 \
KERA_LOG_LEVEL=debug \
npx -y kera-mcp

# Flag wins over environment
KERA_LISTEN_PORT=5000 npx -y kera-mcp --target http://127.0.0.1:3000 --port 4000
# Kera listens on 4000

# Frozen install from a checkout
pnpm install --frozen-lockfile
pnpm run build
node packages/mcp/dist/index.js --target http://127.0.0.1:3000

Client env alternative:

{
  "mcpServers": {
    "kera": {
      "command": "npx",
      "args": ["-y", "kera-mcp"],
      "env": {
        "KERA_TARGET_URL": "http://127.0.0.1:3000",
        "KERA_LISTEN_PORT": "4000",
        "KERA_DATA_DIR": "/Users/you/.kera",
        "KERA_MAX_STORED_REQUESTS": "1000",
        "KERA_MAX_BODY_BYTES": "1048576",
        "KERA_LOG_LEVEL": "info"
      }
    }
  }
}

Defaults at a glance

Setting Default
Listen address 127.0.0.1
Listen port 4000
Dashboard address and port 127.0.0.1:4040
Data directory ~/.kera
Database ~/.kera/traffic.db
Stored request ring buffer 1000 rows
Capture limit per body 1048576 bytes (1 MiB)
Replay cap min(maxBodyBytes, 8 MiB)
Replay timeout 30 seconds
Redaction policy redact
Tunnel false (off)
Tunnel provider Cloudflare Quick Tunnel (cloudflared)
Log level info
Log destination stderr
MCP transport stdio

Validation and startup failures

Kera fails fast with a safe stderr message rather than starting in a broken state.

Failure Result
Missing/invalid target Startup error; check KERA_TARGET_URL / --target
Target contains credentials Rejected
Target overlaps Kera's listener Startup error; change target or port
Target/listen host cannot resolve for loop check Startup error before data-dir creation
Invalid host, port, or numeric value Configuration error naming the field
Data directory not private Startup error explaining 0700
Data directory or DB is a symlink Rejected
Port already bound EADDRINUSE diagnostic; stop the other process or change --port
Tunnel enabled with non-loopback host Startup error; tunnel mode requires listenHost=127.0.0.1
cloudflared missing or offline Tunnel fails, but local proxy/capture/MCP stay available; check get_tunnel_url and stderr
SQLite open/migration failure Startup error; check permissions and database health

See Terminal CLI and Local Dashboard for workflows, or Roadmap for release status.

Clone this wiki locally