An agent-first MCP SDK and backend stack for Rust, built on rmcp — the official Rust MCP SDK (created by Anthropic's Model Context Protocol team).
Architecture overview & diagrams: mstack.mext.at · Internal MCP App Store:
mstack-hub· Flagship CMS: Headcode CMS
- Starts in milliseconds — ~14 ms boot including database migrations.
- Memory in MB, not GB — ~7 MiB RAM per service; run 100+ isolated internal MCP services on one €4 ARM server.
- Built for agents — coding agents scaffold, deploy, back up, move services across hosts, and patch CVEs from Linux to app code.
- Copy, own, adapt — like
shadcn/ui,mstackcopies small, readable Rust files into your repo. No black-box library, no lock-in. - No Kubernetes, no Postgres clusters, no $200/mo PaaS bills.
| Old stack | mstack |
|
|---|---|---|
| Orchestration | Kubernetes or heavy PaaS UIs (1–2 GB RAM just idling) | Standard containers + Uncloud (~70 MiB RAM for Caddy + WireGuard mesh) |
| Deployments | Manual SSH scripts, click-ops dashboards, slow x86 builds | 100 % CLI/agent-driven (uc, gh, vercel dns, Blacksmith ARM64 → GHCR) |
| Database | One shared Postgres cluster, tenant_id/project_id in every query |
One embedded Turso Rust DB file per service (~7 MiB RAM, zero network hop) |
| Backups | Complex cluster dumps, broken volume snapshots | Single-file VACUUM INTO snapshot → encrypted restic to S3 |
| Scaling / Moves | Re-architect DB + wait on DNS propagation | Move one container + .db file over WireGuard mesh, zero DNS wait |
| Security patching | Months of OS/DB/runtime drift | unattended-upgrades + daily cargo audit/trivy + agent PRs via mstack.json |
| Docs & Setup | 40-page human tutorials | This README for humans; skills/ for coding agents |
- Copy, own, adapt (
registry/): Plain Rust modules (audit.rs,mcp.rs,auth.rs,db.rs,events.rs,members.rs,skills.rs,storage.rs) — no traits, no hidden framework magic. Single-tenant by design: one container, one.dbfile, routes at/mcpand/health(notenant_id, noproject_id). - Rust +
rmcp 3.11: Stateless by default, optional stateful sessions for MCP Elicitation & Tasks, built-in MCP Skills (skills-fs) served straight from your server with SHA-256 verification. Rule of thumb: deterministic, service-local jobs belong inside the MCP service as MCP Tasks; cross-service LLM workflows belong in the orchestrator/agent. - Zero-PII Tool Audit Log & Explicit Role Guards (
audit.rs): Every MCP tool call emits one flat structured JSON event (target: "mstack::audit") tostdoutwithevent_id(UUID v7), W3Ctrace_id,(actor_iss, actor_sub, actor_role, client_id),tool_name,access_kind, optionaltarget_id, canonical SHA-256args_hash,decision,approval_mode,status, andduration_ms— never emails, names, or raw payloads. Zero Turso write-lock, zero extra RAM; Vector ships events directly to OpenObserve (DataFusion/Parquet) or any SIEM. - Native Turso (
0.9): Embedded Rust SQLite rewrite with MVCC (BEGIN CONCURRENT+ automatic conflict retry),PRAGMA user_versionmigrations, and onlineVACUUM INTObackups — nosqlxlayer needed. Unless a single service needs 100+ tables, 100M+ rows, or Postgres-only extensions, an embedded.dbfile beats a shared database cluster on speed, isolation, and cost. - Zero-PII Auth (
services/auth): Powered by Better Auth — magic links by default, plus email/password, social login, OAuth 2.1 (@better-auth/mcp,@better-auth/cimd,@better-auth/agent-auth), and enterprise SSO when needed. Services verify RFC 9068 JWTs via multi-issuer JWKS (with optionalissuer|jwks_urloverrides for Docker Compose or Microsoft Entra ID / Keycloak) and only ever seesub+client_id(never emails or secrets). - Pub/Sub Event Outbox: Services write domain events (e.g.
headcode.published,analytics.dataset.updated,user.notify) with a CloudEventssourceinside the same DB transaction. A background worker delivers HMAC-SHA256-signed webhooks to Vercel Eve, Mastra, or any HTTP endpoint. - Agent-First Observability & Provider-Neutral: Services log structured JSON via
tracingtostdout(uc logsby default, 0 MB overhead). When scaling to multiple services, add self-hosted OpenObserve (Rust + Apache DataFusion, ~200 MiB RAM on ARM64, built-in native MCP server at/api/default/mcpfor agent evals, debugging, and automated fix PRs) via Vector. Hetzner ARM64, Kiri, Vercel DNS, and OpenObserve are the defaults — swap any piece without touching app code.
No manual patching, no SSH maintenance weekends — agents detect, audit, test, and roll out updates automatically across every layer:
| Layer | Mechanism | Typical downtime |
|---|---|---|
| OS (Linux / Docker) | unattended-upgrades daily; critical kernel CVE → agent spins up fresh host, moves services via Uncloud, deletes old host |
0 s / ~2 s |
Infra (uncloudd, caddy) |
uncloudd updates don't restart apps; agent rolls proxy via uc caddy deploy |
0–2 s |
| Libs & Base Image | Daily cargo audit + trivy → agent opens PR → Blacksmith ARM64 build (~45 s) → GHCR → uc deploy |
0 s (stateless) / ~1–2 s (stateful) |
Database (turso) |
Compiled into the binary — patched like any Rust crate, with pre-deploy VACUUM INTO backup |
~1–2 s |
| Auth / Web | Vercel frontend switches atomically; Better Auth rolls via uc deploy with SIGTERM shutdown |
0 s / ~1–2 s |
Single-writer embedded DBs intentionally trade 1–2 seconds on container swap (stop-first + SIGTERM + 14 ms Rust boot) for massive simplicity and isolation. Cached frontends never notice.
Run the reference Rust MCP service + Better Auth OAuth 2.1 server locally — no domain, no email API key, and no external database required:
git clone https://github.com/markustripp/mstack.git && cd mstack
docker compose up -d --build
node services/template/scripts/smoke.mjsThe smoke script runs the full MCP OAuth 2.1 flow (401 RFC 9728 discovery → Dynamic Client Registration → dev magic-link sign-in → PKCE → EdDSA at+jwt → note_create, notes_list, and online VACUUM INTO backup).
Inspect the emitted Zero-PII audit trail:
docker compose logs service | grep mstack::audit{"timestamp":"2026-12-06T09:47:33.063017Z","level":"INFO","message":"mcp audit","event_id":"01a24ac0-6746-74d8-bc06-3cc2310fcaa8","event_type":"mcp.tool.call","trace_id":"775107b1735412bb235ff73cf158b305","actor_iss":"http://localhost:3081/api/auth","actor_sub":"h0nBxMH9YzXnZtzkcKYqAlKC6MXmjD8t","client_id":"mLdcbwSZImwejIhCQhUsxSdaWYlBmxjh","service":"mstack-service","tool_name":"note_create","access_kind":"write","target_id":"c9abdb47-d94f-493e-bd8a-3c00fc590825","args_hash":"sha256:5d845233...","decision":"allow","approval_mode":"none","status":"ok","duration_ms":1,"target":"mstack::audit"}Prefer native local dev (Node 26 + Rust)?
# Terminal 1 — Better Auth (logs dev magic links to /tmp/mstack-auth.log)
cd services/auth && npm install
BETTER_AUTH_SECRET=local-dev-secret-change-in-production-32bytes node server.mjs | tee /tmp/mstack-auth.log
# Terminal 2 — Rust MCP service (~14 ms boot)
cd services/template && cargo run
# Terminal 3 — End-to-end OAuth 2.1 + MCP smoke test
SMOKE_AUTH_LOG=/tmp/mstack-auth.log node services/template/scripts/smoke.mjsmstack is not meant to be set up manually. Point Claude Code, Codex, Cursor, or Antigravity at this repo:
"Use the skills in
markustripp/mstackto scaffold a new MCP service calledmy-serviceand deploy it."
- Agent instructions:
AGENTS.md - Registry manifest:
mstack.json - Agent playbooks:
skills/mstack-init,skills/mstack-deploy,skills/mstack-move,skills/mstack-sync,skills/mstack-audit
- mstack.mext.at — Architecture overview, diagrams, and walkthrough
markustripp/mstack-hub— Scalemstackservices into an internal MCP App Store (catalog, role bundles, zero-PII onboarding)- Headcode CMS (
headcodecms/headcodecms) — Single-tenant agentic web CMS built onmstack - mext.at — Articles and notes by Markus Tripp
MIT