MASC - Multi-Agent Streaming Coordination in OCaml
Multi-Agent Streaming Coordination server built on OCaml 5.x + Eio. Keeps multiple coding agents coordinated inside one repository through shared namespace, task ownership, broadcasts, worktrees, supervisor-visible proof, and OAS-backed keeper execution.
Built for repo-local, single-machine, trusted-network workflows where several AI agents need shared coordination state instead of ad-hoc terminal coordination.
Current product posture:
Use masc-mcp when you need to reduce:
Do not start with masc-mcp if you need:
┌──────────────────────────────────────────────────┐
│ Consumer / Client │
│ (Claude, Gemini, Codex, Local Agent) │
└────────────────┬─────────────────────────────────┘
│ MCP (JSON-RPC)
┌────────────────▼─────────────────────────────────┐
│ MASC-MCP (coordination) │
│ │
│ Room/Board Keeper Team-Session Governance │
│ Tasks Command-Plane Dashboard │
│ │
│ ┌── OAS bridges ──┐ │
└─────────┤ ├───────────────────────┘
│ │
┌─────────▼─────────────────▼──────────────────────┐
│ OAS / agent_sdk (agent runtime) │
│ Agent.run Builder Hooks Checkpoint Memory │
│ Context_reducer Tool_selector Cascade │
└──────────────────────────────────────────────────┘MASC decides when, why, and which agent to run. OAS handles single-agent execution, tool dispatch, context management, and LLM provider cascading. MASC depends on OAS; OAS does not know about MASC.
All protocols run concurrently from a single Eio fiber pool:
| Protocol | Default | Notes |
|---|---|---|
| HTTP/1.1 + HTTP/2 | :8935 | Primary MCP endpoint at /mcp |
| SSE | :8935 | Unlimited streams per h2 connection |
| gRPC | :8936 | Keeper queries and subscriptions |
| WebSocket | :8937 | Standalone + discovery via /ws |
| WebRTC | :8935/webrtc | Signaling at /offer and /answer |
git clone https://github.com/jeong-sik/masc-mcp.git
cd masc-mcp
# Pin private dependencies (OAS, mcp_protocol, etc.)
scripts/opam-pin-external-deps.sh
opam install . --deps-only
dune build
scripts/run-local.sh --target-dir "$PWD"
PORT="$(scripts/run-local.sh --print-port --target-dir "$PWD")"
curl "http://127.0.0.1:${PORT}/health"Defaults:
9100-9999 range, deterministically derived from the target path127.0.0.1<target>/.masc/<target>/.masc/config<target>/.masc/config/personasNotes:
scripts/run-local.sh --print-port --target-dir /path/to/projectscripts/run-local.sh --target-dir /path/to/project --port 94xx./start-masc-mcp.sh --httpOther start modes:
| Mode | Command | Use case |
|---|---|---|
| Loopback | scripts/start-loopback.sh | Local dev, fixed port 8935, keepers off |
| Dir-local | scripts/run-local.sh --target-dir /path | Per-project isolation, auto port |
| Full runtime | ./start-masc-mcp.sh --http | All transports, keeper autoboot, dashboard |
| Direct binary | ./_build/default/bin/main_eio.exe --port 8935 --base-path . | Manual control |
If you bind to a non-loopback address such as 0.0.0.0, treat that as a remote exposure path and configure auth first. See docs/LOCAL-DASHBOARD-AUTH-RUNBOOK.md and docs/spec/09-server-transport.md.
{
"mcpServers": {
"masc": {
"type": "http",
"url": "http://127.0.0.1:8935/mcp"
}
}
}/mcp — full coordination surface (local-first)/mcp/operator — bearer-token only, remote-safe reduced surface8935 with the output of scripts/run-local.sh --print-port --target-dir ...Keepers are long-running autonomous agents that maintain repo continuity. They run as Eio fibers with heartbeat loops, checkpoint/resume, and supervised restart.
Keepers follow an 11-state deterministic state machine:
Offline → Running → [Failing|Compacting|HandingOff|Draining]
→ Paused/Stopped/Crashed → Restarting → DeadKeeper definitions live in config/keepers/*.toml. When MASC_KEEPER_BOOTSTRAP_ENABLED=true, the server discovers and starts all keepers on boot with staggered warmup delays.
Each keeper call to Agent.run is limited to MASC_KEEPER_OAS_MAX_TURNS_PER_CALL turns (default: 5). When exhausted, the keeper saves a checkpoint and resumes in the next heartbeat cycle. The keeper can call extend_turns to request more turns up to an absolute ceiling (200).
Adaptive OAS timeout: base 180s + 1.5s per 1K context tokens, capped at [30, 600]s.
| Variable | Default | Description |
|---|---|---|
MASC_KEEPER_BOOTSTRAP_ENABLED | false | Enable keeper autoboot |
MASC_KEEPER_HEARTBEAT_INTERVAL_SEC | 30 | Heartbeat cadence (5-300s) |
MASC_KEEPER_OAS_MAX_TURNS_PER_CALL | 5 | Turns per Agent.run call (1-50) |
MASC_KEEPER_OAS_TIMEOUT_SEC | adaptive | Override OAS timeout (30-600s) |
MASC_KEEPER_TURN_TIMEOUT_SEC | 1200 | Wall-clock turn guard (60-3600s) |
MASC_KEEPER_SUPERVISOR_MAX_RESTARTS | 5 | Restart attempts before Dead |
MASC_KEEPER_IDLE_SKIP_THRESHOLD | 4 | Consecutive idle calls before Skip |
Full list: lib/config/env_config_keeper.ml. Per-keeper config: config/keepers/*.toml.
config/cascade.json follows the OAS cascade contract.cascade_name in its TOML.provider:model_id labels instead of convenience labels.masc_start(path="/your/project", task_title="My first task")Canonical namespace/task hygiene:
masc_startmasc_statusmasc_transition(action="claim") or masc_claim_nextmasc_plan_set_task when neededmasc_heartbeatFor planner / implementer / supervisor separation:
/mcp/operator with masc_operator_snapshot, masc_operator_digest, masc_operator_action, masc_operator_confirmhttp://127.0.0.1:<PORT>/dashboard#monitoring/sessionshttp://127.0.0.1:<PORT>/dashboard#command/intervenehttp://127.0.0.1:<PORT>/dashboard#workspace/boardhttp://127.0.0.1:<PORT>/dashboard#lab/toolsThe dashboard is a read-heavy UI for repo coordination and keeper/runtime visibility. Canonical write paths remain MCP tools.
For external channel adapters, treat the Channel Gate as the boundary owner:
/api/v1/gate/message/api/v1/gate/connectors/api/v1/gate/statusThe dashboard should learn connector type and status from the gate descriptor
surface instead of hardcoding vendor-specific assumptions.
scripts/run-local.sh does not build the dashboard automatically. Append --build-dashboard only when needed.start-masc-mcp.sh automatically builds the dashboard SPA if pnpm or corepack pnpm is available.PORT="$(scripts/run-local.sh --print-port --target-dir "$PWD")"
cd dashboard && MASC_DASHBOARD_PROXY_TARGET="http://127.0.0.1:${PORT}" pnpm run devcd dashboard && pnpm run build.make test # Unit tests (no server needed)
make ci # Full CI suiteSmoke checks (with running server):
curl -sS http://127.0.0.1:8935/health
grpcurl -plaintext 127.0.0.1:8936 grpc.health.v1.Health/CheckTo reproduce CI-style test output with heartbeat logs locally:
CI_TEST_TIMEOUT_SEC=1200 CI_TEST_HEARTBEAT_SEC=30 \
scripts/ci-run-tests.sh "opam exec -- dune test --root ."POST /mcp expects Accept: application/json, text/event-stream./sse and /messages endpoints are deprecated.0.0.0.0 or :: enables strict auth; local /mcp fails closed unless require_token=true./mcp/operator is bearer-token only with a remote-safe surface. Do not expose full /mcp externally.| Document | Description |
|---|---|
| docs/PRODUCT-OPERATING-PLAN.md | Product promise, GitHub operating model, 6-8 week execution tracks |
| ROADMAP.md | Current package version, latest release truth, active tracks |
| docs/PRODUCT-REVIEW.md | Current product posture by promise level |
| docs/design/keeper-continuity-product-rfc.md | Bounded keeper continuity contract and promise level |
| docs/KEEPER-CONTINUITY-PRODUCTION-RUNBOOK.md | Release gate, evidence, monitoring, and rollback for keeper continuity |
| Document | Description |
|---|---|
| docs/QUICK-START.md | Install, health check, first workflow |
| docs/MCP-TEMPLATE.md | HTTP / stdio MCP config templates |
| docs/BENCHMARK-RUNBOOK.md | Benchmark and comparison harnesses |
| docs/KEEPER-USER-MANUAL.md | Keeper lifecycle and troubleshooting |
| docs/SUPERVISOR-MODE.md | Supervised execution / operator workflow |
| docs/SWARM-DELIVERY-RUNBOOK.md | Single-agent vs swarm delivery |
| docs/OAS-MASC-BOUNDARY.md | OAS/MASC ownership boundary |
| docs/COMMAND-PLANE-RUNBOOK.md | Historical compatibility / command-plane details |
| docs/LOCAL-DASHBOARD-AUTH-RUNBOOK.md | Dashboard auth bootstrap |
| docs/spec/SPEC-INDEX.md | Spec suite (19 specs) |
| ROADMAP.md | Version, release truth, active tracks |
| docs/PRODUCT-OPERATING-PLAN.md | Product promise, execution tracks |
| llms.txt / llms-full.txt | Compressed front door for language models |
Historical and archived documents remain in the repository, but the front-door SSOT is the README, the product operating plan, the roadmap, and the current spec suite.
jeong-sik/masc-mcp
January 18, 2026
April 13, 2026
OCaml