β topics
---
title: Mission Control Architecture (v2)
updated: 2026-06-11
---
Mission Control Architecture (v2)
Overview
Mission Control (MC) provides a real-time dashboard for monitoring OpenClaw agent activity, session state, costs, and model health.
v2 redesign: MC now uses a database-backed backend instead of parsing JSONL files on every request. This eliminates the 40-80s startup hangs and crash loops.
Architecture
```
βββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ
β Browser UI ββββββΆβ mc-server.js βββββββ MUE DB β
β (port 5173) βββββββ (port 5173) ββββββΆβ (mue.db) β
βββββββββββββββ β Thin cache+proxy β ββββββββββββββββ
ββββββββββββββββββββ β²
β β
βΌ β
ββββββββββββββββ ββββββββββ΄ββββββββ
β MUE API β β mc-sync.py β
β (port 7710) β β (cron 30min) β
ββββββββββββββββ ββββββββββββββββββ
```
Components
mc-server.js (`ui/server.js`, ~400 lines)
- Thin HTTP server, Node.js stdlib only
- Serves static UI files
- Reads composite snapshot from `mc-query.py` (which reads MUE DB)
- Caches snapshot for 10s before rebuilding
- Proxies MUE model data from port 7710
- Startup time: <2 seconds (no file parsing)
- CPU at idle: 0-2%
mc-sync.py (`data/mc-sync.py`)
- Python3 script, stdlib only (sqlite3, json, os, sys, glob)
- Reads session JSONL files, writes to mc_ tables in MUE DB
- Called via cron every 30 minutes (not on UI requests)
- Run time: ~16ms for 100 files
- Excludes `.trajectory.`, `.deleted.` files
- Max 100 files per agent, hard 30s wall time limit
mc-query.py (`data/mc-query.py`)
- Python3 script that reads MC tables from MUE DB
- Outputs JSON on stdout
- Commands: `snapshot`, `agents`, `sessions`, `events`, `status`, `costs`
- Called by mc-server.js via `execSync`
mc-db-sync.sh
- Bash wrapper for cron scheduling
- Runs: mc-sync.py β costs_db.py --seed
- Logs to /tmp/mc-db-sync.log
Database
All tables live in the shared MUE database: `projects/model-usage-engine/data/mue.db`
MC Tables (mc_ prefix)
| `mc_agents` | Agent config + aggregated stats | openclaw.json + mc-sync.py |
| `mc_sessions` | Session metadata | JSONL files |
| `mc_events` | Timeline events | JSONL message parsing |
| `mc_scan_log` | Sync audit trail | mc-sync.py |
Shared Tables
| `models` | Model inventory + pricing | MUE API |
| `usage` | Raw usage records | MUE API |
| `daily_usage_rollup` | Aggregated daily usage | MUE API |
| `daily_model_costs` | Per-model daily costs | costs_db.py |
ER Diagram
The entity-relationship diagram is at: File
| `config.yaml` | MC server settings (ports, intervals) |
| `data/mc-schema.sql` | SQL schema for MC tables |
| `.mc-token` | Auth token for MUE API |
Service Management
| Service | Mechanism | Restart | Interval |
| MC Server | launchd (`com.mc.ui`) | KeepAlive=true | Always |
| MC Watchdog | launchd (`com.mc-watchdog`) | 120s check | 120s |
| DB Sync | crontab | Every 30 min | 30 min |
| Heartbeat | launchd (`com.randy.heartbeat-monitor`) | 60s check | 60s |
Related
- [[Heartbeat Monitor Architecture
- [[MC ER Diagram]]