Architecture

Overview

+-----------------------------------------------------+
AI Agent (MCP Client)
+--------------------------+--------------------------+

| SSE (MCP Protocol)

v

+-----------------------------------------------------+

Butt-Dial MCP Server
+----------+ +----------+ +-----------------+
MCP ToolsWebhooksAdmin UI
(15 tools)(6 routes)Setup/Dashboard
+-----+----+ +-----+----+ +-----------------+
+-----+--------------+---------------------------+
Security Layer
AuthSanitizerRate LimiterCompliance
+-----+--------------------------------------+---+
+-----+--------------------------------------+---+
Provider Interfaces
TelephonyEmailWhatsAppTTSSTTDB
+-----+--------------------------------------+---+
+-----+--------------------------------------+---+
Provider Adapters
TwilioResendElevenLabsSQLiteS3
+-------------------------------------------------+
+-----------------------------------------------------+

Tech Stack

Data Flows

Outbound Message

Agent -> comms_send_message -> Auth -> Sanitize -> Compliance Check

-> Rate Limit -> Provider.send() -> Log Usage -> Return Result

Inbound Message

Provider Webhook -> Signature Verify -> Replay Check -> Channel Block Check

-> Parse -> Forward to Agent (or store in dead_letters if offline)

Live Voice Call

Inbound Call -> Webhook -> ConversationRelay TwiML -> WebSocket

-> Human speaks -> STT (by Twilio) -> Text to Agent (MCP sampling)

-> Agent responds -> Text to Twilio -> TTS (by Twilio) -> Human hears

Answering Machine Fallback

Inbound Call -> WebSocket -> Agent not connected

-> Built-in Anthropic LLM as answering machine

-> Collects message -> Stores in dead_letters

-> Agent reconnects -> Dead letters dispatched

Key Components

ComponentDescription
MCP ServerRegisters tools, handles SSE transport
Provider FactoryResolves config to adapter instances
Auth GuardrequireAgent() / requireAdmin()
Token ManagerToken generation, hashing, verification
SanitizerInput validation (SQL injection, XSS, etc.)
Rate LimiterPer-agent action and spending limits
ComplianceContent filter, DNC, TCPA, CAN-SPAM, GDPR
Voice SessionsIn-memory store for active call configs
Voice WebSocketWebSocket handler (setup/prompt/interrupt/dtmf)
Agent RegistryMaps agentId to MCP Server session
Message DispatcherDispatches dead letters on agent reconnect
Channel BlockerPer-channel blocking without deprovisioning
MetricsPrometheus counters and gauges
Audit LogSHA-256 hash-chained event log
Alert ManagerSeverity-routed alerts
Anomaly DetectorVolume spikes, brute force, rapid rotation

Concurrency Model

Scaling path: single-process SQLite -> multi-process Postgres -> horizontal stateless workers.

Configuration Modes

Identity Model

ModeDescription
Dedicated (default)Each agent gets own phone, WhatsApp, email
Shared PoolAgents share a pool of numbers
HybridShared by default, dedicated as upgrade

Tenant Isolation

ModeDescription
Single Account + DB RoutingOne provider account, isolation in DB
Subaccount per AgentEach agent gets own provider subaccount
Subaccount per CustomerEach tenant gets a subaccount
← Home