Skip to content

Deployment Guide

Anvil Agent ships a stdlib-only Python 3.11+ backend (server/) and hardened Docker Compose stack (deploy/) so anyone can deploy the complete voice agent gateway, MCP glasses bridge, and real-time STT/LLM router end to end.

Architecture

MemoMind One Glasses / Phone UI       MCP Agents (Hermes, Pi, Claude Code, Codex)
        │  HTTPS or loopback HTTP              │  POST /mcp (Streamable HTTP)
        ▼                                      ▼
             Anvil Agent Gateway (:8792)  ── Stateless turns, /v1/memos/preview, event ring
                 │                 │
     STT audio   │                 │  Agent turns
                 ▼                 ▼
   Real-Time Router (:8000)   Agent Backends (openai-chat, hermes-api, pi-web)
      ├── /v1/audio/transcriptions  ──► STT Engine (Parakeet, Whisper, Speaches)
      └── /v1/chat/completions      ──► LLM Engine (Ollama, vLLM, llama.cpp, OpenAI)

If you already operate an Anvil Serving gateway, you can skip the bundled realtime-router container and point agent.router_url directly at your Anvil Serving router (http://127.0.0.1:8000).

  1. Copy router.example.toml, agent.example.toml, and env.example into ~/.config/anvil-agent/ (chmod 700 on the directory, chmod 600 on runtime.env).
  2. Update router.toml with your STT and LLM upstream URLs, and optionally uncomment the hermes-api or pi-web sections in agent.toml.
  3. Launch the stack:
    AGENT_ROUTER_CONFIG=~/.config/anvil-agent/router.toml \
    AGENT_CONFIG=~/.config/anvil-agent/agent.toml \
      docker compose -f deploy/docker-compose.yml --env-file ~/.config/anvil-agent/runtime.env up --build -d
    
    By default, anvil-agent binds 127.0.0.1:8792 on the host, realtime-router stays private on the Compose bridge network, and both containers include host.docker.internal:host-gateway so host-local STT/LLM/Hermes/Pi services work on both Linux and macOS.

Built-in HTTPS with Caddy

MemoMind iOS plugins require https:// for non-loopback servers. Set AGENT_DOMAIN in runtime.env and enable the tls profile (deploy/Caddyfile strips incoming Tailscale-User-Login headers and enforces a 32 MB body cap):

AGENT_ROUTER_CONFIG=~/.config/anvil-agent/router.toml \
AGENT_CONFIG=~/.config/anvil-agent/agent.toml \
  docker compose -f deploy/docker-compose.yml --profile tls --env-file ~/.config/anvil-agent/runtime.env up --build -d

Option B: Native Python (Bare Metal / Tailscale Serve)

Requires Python 3.11+ and ffmpeg on PATH. When adapting deploy/*.example.toml for bare metal, switch Docker hostnames (realtime-router, host.docker.internal) to 127.0.0.1 and set listen_host = "127.0.0.1" / allow_container_bind = false. Export your runtime env file first because anvil-agent-server reads process environment variables directly:

pip install -e ./server
set -a && . ~/.config/anvil-agent/runtime.env && set +a

# Validate configs offline before binding
anvil-agent-server router validate --config ~/.config/anvil-agent/router.toml
anvil-agent-server agent validate --config ~/.config/anvil-agent/agent.toml

# Run both services
anvil-agent-server router run --config ~/.config/anvil-agent/router.toml
anvil-agent-server agent run --config ~/.config/anvil-agent/agent.toml

Tailscale Serve Authentication

When exposing Anvil Agent over a tailnet with tailscale serve:

  • Keep listen_host = "127.0.0.1" (never combine allowed_logins_env with allow_container_bind = true).
  • Set allowed_logins_env = "ANVIL_AGENT_LOGINS" to a comma-separated list of authorized tailnet logins.
  • Optionally also set client_token_env (or client_token_file) so local or remote MCP clients can authenticate with Bearer tokens.

Configuring Agent Backends

Declare 1 to 8 backends under [agent.backends.<id>] in agent.toml (order sets the picker order in the glasses UI):

  • kind = "openai-chat" — Any OpenAI-compatible /v1/chat/completions server (including realtime-router, Ollama, vLLM, llama.cpp, SGLang, or OpenAI). Requires url and model; supports key_env/key_file or auth = "none" for local unauthenticated servers.
  • kind = "hermes-api" — Hermes API server (/v1/chat/completions with persistent server-side X-Hermes-Session-Id state). Requires url and key_env/key_file; optional session (default "anvil-agent") and optional model.
  • kind = "pi-web" — Pi mobile session bridge (/api/mobile-pi/sessions/<session>). Requires url, key_env/key_file, and session.