Jump to section
1. Quickstart & Cloudflare Deploy
Clavis runs inside your own Cloudflare account using a single Worker, 5 SQLite-backed
Durable Objects (AccountDO, IdentityDO,
VaultDO, GatewayDO, RealtimeDO), and one R2
bucket (clavis-mail). No manual API tokens or secrets are required for a
fresh deploy: wrapping keys and Web Push VAPID keys are generated inside isolated
Durable Object SQLite on first use.
Option A — One-Click Deploy to Cloudflare
Click
Deploy to Cloudflare
to clone Clavis into your GitHub/GitLab account, auto-provision R2 and all 5 Durable
Objects from root wrangler.jsonc, and deploy via Workers Builds on the
$0 Workers Free Tier.
Option B — Local Turnkey CLI
git clone https://github.com/veritaswiki/clavis.git
cd clavis
pnpm install
# Interactive deploy wizard (provisions R2, secrets, custom domain)
pnpm run deploy -- --domain clavis.example.com
# Preview changes safely without touching live Cloudflare
pnpm run deploy -- --domain clavis.example.com --dry-run --yes
First-Run Setup Checklist
-
Open
https://<your-worker-url>/setupimmediately after deploy. Owner initialization executes inside a single SQLite transaction and permanently locks after creation (409 Conflicton repeat calls). -
Enter your owner email, mail domain (e.g.
example.com), and master vault passphrase. Remember: the vault passphrase never leaves the browser and has no recovery path by design. - Optionally enroll a WebAuthn Passkey (Touch ID / Face ID / YubiKey) and bind a custom app domain under Settings → Custom app domain.
Optional: Cloudflare Secrets Store GATEWAY_KEK Hardening
To separate key-wrapping material from Durable Object storage, attach either a Worker
Secret (wrangler secret put GATEWAY_KEK, ≥ 32 random chars) or a
Cloudflare Secrets Store binding in wrangler.jsonc. Clavis transparently
re-wraps existing DO-managed keys on first access and fails closed if an active
external KEK is later removed.
{
"secrets_store_secrets": [
{
"binding": "GATEWAY_KEK",
"store_id": "<your-secrets-store-id>",
"secret_name": "clavis-gateway-kek"
}
]
}
2. Email Routing & Privacy
Clavis receives per-site alias mail directly through Cloudflare Email Routing and
parses messages inside the Worker with postal-mime.
-
Open Cloudflare Dashboard → Email → Email Routing and enable Email
Routing on your domain (
example.com). -
Under Routing rules → Catch-all address, set the action to
Send to a Worker →
clavisand enable the rule. - Unknown, paused, and revoked aliases are dropped silently with zero bounce backscatter.
Sender Trust & Sandboxed Rendering
-
Clavis evaluates only the first
Authentication-Resultsheader whose authserv-id ismx.cloudflare.net, preferring SPFsmtp.mailfromover HELO. Verified status requiresdmarc=pass; DKIM-only is surfaced as a warning and forged upstream headers yielduntrusted. -
Inbound HTML is stripped of scripts, forms, styles, SVG/MathML, and event handlers,
rewritten with inert
data-clavis-hreflinks, and rendered in asandbox=""iframe underdefault-src 'none'. Remote images stay blocked until you click Load remote images. -
Mail & R2 retention defaults to
0(keep forever). Enable automatic daily purge (Worker Cron0 3 * * *) under Settings → Mail & R2 retention.
Email preview
When onboarding a domain for outbound Cloudflare Email Sending
(SEND_EMAIL), Cloudflare enables Email preview
by default, retaining sent email bodies in Cloudflare logs for
7 days. For zero-retention outbound mail privacy, open
Cloudflare Dashboard → Email → Email Sending → Domain settings and
disable Email preview immediately after enabling your
sending domain.
Agent-created mail drafts send natively through Cloudflare’s SEND_EMAIL
binding (Workers Free allows verified destination addresses; Workers Paid includes
3,000 arbitrary-recipient emails/month), with optional Resend, Postmark, or SendGrid
fallback configured inside AI Gateway Services — or export as .eml.
3. Remote MCP Setup
Clavis exposes a single Streamable HTTP JSON-RPC 2.0 MCP endpoint at
https://clavis.example.com/mcp. Create a scoped agent connection in
AI Custody Gateway → Connect Agent to obtain a revocable Bearer
token with explicit expiration and default permission tier.
claude mcp add --transport http clavis https://clavis.example.com/mcp \
--header "Authorization: Bearer clv_agent_YOUR_TOKEN"
[mcp_servers.clavis]
url = "https://clavis.example.com/mcp"
bearer_token_env_var = "CLAVIS_TOKEN"
{
"mcpServers": {
"clavis": {
"type": "http",
"url": "https://clavis.example.com/mcp",
"headers": {
"Authorization": "Bearer clv_agent_YOUR_TOKEN"
}
}
}
}
{
"mcpServers": {
"clavis": {
"serverUrl": "https://clavis.example.com/mcp",
"headers": {
"Authorization": "Bearer clv_agent_YOUR_TOKEN"
}
}
}
}
Exposed MCP Tools
| Tool | Behavior |
|---|---|
clavis_list_services |
Lists services visible to the agent with masked fingerprints and allowed domains only — never plaintext keys. |
clavis_probe_service |
Executes a plaintext-free connectivity and auth health check (proxy_only). |
clavis_http_request |
Runs the full 4-step edge custody pipeline: SSRF/domain/path checks, quota & Touch ID approval, edge injection or WebCrypto signing, secret scrubbing, and immutable audit log. |
clavis_mail_read |
Lists alias identities or reads sanitized inbound messages when Mail Read tier is granted. |
clavis_mail_draft |
Creates outbound mail drafts for human review and sending via native SEND_EMAIL or configured SMTP API fallback. |
clavis_mail_manage |
Archives, marks read, or manages mail items under explicit Mail Manage policy. |
clavis_check_approval |
Polls status of a pending Touch ID / Face ID WebAuthn approval UUID. |
4. URL Path Policies & HMAC / SigV4 Edge Signing
Every credential stored in GatewayDO supports fine-grained URL path
rules alongside allowedDomains. CustodyAuthorizer evaluates
path policies before creating approvals, deducting daily quotas, or
unwrapping secret material.
-
Fail-closed canonicalization: Resolves
.and.., collapses repeated slashes, decodes unreserved percent-escapes, and rejects encoded separators (%2F,%5C), raw backslashes, control characters or whitespace, semicolon matrix parameters (;), and traversal escaping root. -
Deny-overrides-allow: Supports single-segment (
*) and multi-segment (**) globs. Any match indeniedPathsblocks the call even ifallowedPathsmatches.
// Example 1: Custom HMAC-SHA256 / HMAC-SHA512 signed webhook or exchange API
{
"authInjection": {
"mode": "hmac-sha256",
"signatureHeader": "X-Signature",
"timestampHeader": "X-Timestamp",
"timestampFormat": "unix-seconds",
"encoding": "hex",
"stringToSign": "{timestamp}.{method}.{pathWithQuery}.{body}"
}
}
// Example 2: Native AWS SigV4 (AWS APIs, Cloudflare R2 S3, MinIO, Backblaze B2)
{
"authInjection": {
"mode": "aws-sigv4",
"accessKeyId": "AKIA...",
"awsRegion": "auto",
"awsService": "s3"
}
}
Edge signing computes signatures purely with WebCrypto over the final canonical
outbound HTTPS request (cleartext http:// is refused outside localhost
dev/test), strips caller-supplied Authorization, signature, and
timestamp headers before signing, and scrubs secrets and derived auth values
(including Basic credentials) from responses.
5. Varlock Integration
Use Clavis as the personal, human-approved backend for repository
.env.schema files via clavis-varlock-plugin and
clavis-cli (npx clavis-cli varlock-schema). Generating a
schema queries only clavis_list_services metadata (never plaintext
values).
npx clavis-cli login --url https://clavis.example.com --token-stdin
npx clavis-cli varlock-schema --proxy --ttl 300 --wait --out .env.schema
varlock proxy run -- <your-command>
# @plugin(clavis-varlock-plugin)
# @initClavis(url=$CLAVIS_URL, token=$CLAVIS_TOKEN, ttl=300, waitForApproval=true)
# @proxyConfig={egress="strict"}
# ---
OPENAI_API_KEY=clavis("openai")
Override JIT lease TTLs per secret with clavis("openai", ttl=120), or
target multiple instances using @initClavis(id=prod, ...) paired with
clavis(prod, "openai"). Prefer Remote MCP or
npx clavis-cli tool http whenever possible so secrets never leave the
Cloudflare edge.
6. Chrome & Firefox Extensions
Download prebuilt signed/checksummed release archives from GitHub Releases, or build locally from source:
pnpm build:extension # Chromium MV3 -> apps/extension/dist
pnpm build:extension:firefox # Firefox MV3 (clavis@clavis.wiki, Gecko >= 121)
pnpm package:extension # Release zips + SHA256SUMS.txt -> dist-packages/
-
Chrome / Edge / Brave / Arc: Open
chrome://extensions, enable Developer mode, and loadapps/extension/dist(or install from the store). -
Firefox (Desktop & Android Nightly, Gecko ≥ 121): Open
about:debugging#/runtime/this-firefoxand loadapps/extension/dist-firefox/manifest.json(add-on IDclavis@clavis.wiki, declaringdata_collection_permissions: { "required": ["none"] }). -
Safari (macOS / iOS): Convert
apps/extension/distviaxcrun safari-web-extension-converteron macOS with Xcode. - Pairing & isolation: Generate a single-use 40-bit pairing code (10-minute expiry) in the Clavis console, paste it alongside your Worker URL in extension options, and grant optional host permission solely to your Worker origin. The content script never sees the extension token or vault key; the session vault key auto-locks after 15 minutes.
7. Bitwarden Mobile Sync & OIDC IdP
Bitwarden-Compatible Mobile Vault Sync
VaultDO implements a clean-room Bitwarden-compatible zero-knowledge sync
surface under /identity/*, /api/*, and
/notifications/* (with owner admin controls under
/api/v1/bitwarden/*). Point a compatible mobile client at your
self-hosted Clavis URL to unlock encrypted ciphers on iOS and Android without
exposing your master passphrase to the Worker. Mobile alias generation is also
supported via scoped SimpleLogin (/api/alias/*,
/api/v2/aliases) and Addy.io (/api/v1/aliases) endpoints.
Native OIDC Identity Provider
Connect self-hosted apps (Grafana, Gitea, Forgejo, Outline, Tailscale custom OIDC,
etc.) directly to your Clavis Worker with mandatory PKCE S256 and ES256
asymmetric signing keys managed in AccountDO:
| Endpoint | Purpose |
|---|---|
/.well-known/openid-configuration |
Standard OIDC Discovery metadata document. |
/oauth/jwks |
Public ES256 JSON Web Key Set for ID token verification. |
/oauth/authorize |
Authorization endpoint with interactive owner consent & mandatory PKCE S256. |
/oauth/token |
Authorization-code token exchange returning signed ES256 ID tokens. |
/oauth/userinfo |
Returns per-client isolated alias email and subject claims. |