Architecture
Three layers · tokens never touch the MCP
The MCP server forwards; it holds no secrets. That single rule unlocks OAuth-as-a-service later without rewriting a thing.
LAYER 1Agents & clients
ClaudeCursorClaude Coden8nYour app
Bearer mk_live_… over streamable HTTP↓
LAYER 2Modiva MCP · mcp.modiva.ai
Typed tools, grouped by resource. Validates, authorizes, forwards to connections. Holds no tokens.
accounts_posts_comments_messages_analytics_ads_queue_connect_
normalized schema · per-platform adapter↓
LAYER 3Backend engine
Token vault
app-level + KMS
Adapters
one per platform
Queue
rate-limit · retry
Webhook ingest
single envelope
Tenancy model
Four nested levels. Profile is the agency primitive — it lets one MCP key drive 80 client accounts without ambiguity.
ORG · billing account
WORKSPACE · project / team · holds the MCP key
PROFILE · a client or brand · geo metadata lives here
CONNECTION = 1 tokenCONNECTION = 1 tokenCONNECTION = 1 token
Postgres data model
Core tables and their foreign keys. Tokens are an encrypted blob, never a plain column.