q-ring
OS keychain secrets for AI coding agents, over MCP.
Website: qring.i4c.studio
Stop pasting API keys into plain-text .env files or wrestling with clunky secret managers. q-ring securely anchors your credentials to your OS's native vault (macOS Keychain, Linux Secret Service, Windows Credential Vault) and supercharges them with mechanics from quantum physics.
📖 View the Official Documentation for a complete CLI reference, MCP prompt cookbooks, and architecture details.
Why q-ring?
- Superposition: Store one key with multiple states (dev/staging/prod) that collapse based on context.
- Entanglement: Link keys across projects so rotating one automatically updates them all.
- Tunneling: Create ephemeral, in-memory secrets that self-destruct after a set time or read count.
- Teleportation: Securely pack and share AES-256-GCM encrypted secret bundles.
- Seamless AI Integration: 46 built-in MCP tools for native use in Cursor, Kiro, and Claude Code.
🚀 Installation
q-ring is designed to be installed globally so it's available anywhere in your terminal. Pick your favorite package manager:
# pnpm (recommended)
pnpm add -g @i4ctime/q-ring
# npm
npm install -g @i4ctime/q-ring
# yarn
yarn global add @i4ctime/q-ring
# Homebrew (macOS / Linux)
brew install i4ctime/tap/qring
Docker (MCP server)
The repo ships a Dockerfile that builds the MCP server and exposes it through mcp-proxy — useful for hosted MCP deployments (e.g. Glama) or keeping the server off the host entirely:
git clone https://github.com/I4cTime/q-ring.git
cd q-ring
docker build -t qring-mcp .
docker run --rm -p 8080:8080 qring-mcp
Note: inside a container there is no OS keychain (GNOME Keyring / macOS Keychain), so this path is for the MCP protocol surface, ephemeral use, and CI experiments — not for durable local secret storage. For day-to-day use install the CLI natively via one of the package managers above.
⚡ Quick Start
# 1️⃣ Store a secret (prompts securely if value is omitted)
qring set OPENAI_API_KEY sk-...
# 2️⃣ Retrieve it anytime
qring get OPENAI_API_KEY
# 3️⃣ List all keys (values are never shown)
qring list
# 4️⃣ Generate a cryptographic secret and save it
qring generate --format api-key --prefix "sk-" --save MY_KEY
# 5️⃣ Run a full health scan
qring health
# Something not working? Diagnose the install (keyring, audit, MCP wiring)
qring doctor
# Tab completion for your shell
qring completion zsh > ~/.zsh/completions/_qring # also: bash, fish
Quantum Features
Superposition — One Key, Multiple Environments
A single secret can hold different values for dev, staging, and prod simultaneously. The correct value resolves based on your current context.
# Set environment-specific values
qring set API_KEY "sk-dev-123" --env dev
qring set API_KEY "sk-stg-456" --env staging
qring set API_KEY "sk-prod-789" --env prod
# Value resolves based on context
QRING_ENV=prod qring get API_KEY # → sk-prod-789
QRING_ENV=dev qring get API_KEY # → sk-dev-123
# Inspect the quantum state
qring inspect API_KEY
Environment Promotion — Diff, Then Promote
Once a secret carries per-environment states, promotion replaces copy-paste: compare two environments key by key (statuses only, never values), then copy a value from one state to another. diff exits 1 on drift, so it doubles as a CI gate; promote refuses to overwrite a differing target unless you say so.
# What differs between staging and prod? (same / different / missing on one side)
qring diff staging prod
# Make prod match staging for one key (asks before overwriting a different value)
qring promote DATABASE_URL --from staging --to prod
# Non-interactive, e.g. in a release script
qring promote DATABASE_URL --from staging --to prod --force --json
MCP agents get the same two operations as diff_environments and promote_secret.
Wavefunction Collapse — Smart Environment Detection
q-ring auto-detects your environment without explicit flags. Resolution order:
--envflagQRING_ENVenvironment variableNODE_ENVenvironment variable- Git branch heuristics (
main/master→ prod,develop→ dev) .q-ring.jsonproject config- Default environment from the secret
# See what environment q-ring detects
qring env
# Project config (.q-ring.json)
echo '{"env": "staging", "branchMap": {"release/*": "staging"}}' > .q-ring.json
Quantum Decay — Secrets with TTL
Secrets can have a time-to-live. Expired secrets are blocked from reads. Stale secrets (75%+ lifetime) trigger warnings.
# Set a secret that expires in 1 hour
qring set SESSION_TOKEN "tok-..." --ttl 3600
# Set with explicit expiry
qring set CERT_KEY "..." --expires "2026-06-01T00:00:00Z"
# Health check shows decay status
qring health
Observer Effect — Audit Everything
Every secret read, write, and delete is logged with a tamper-evident hash chain. Access patterns are tracked for anomaly detection.
# View audit log
qring audit
qring audit --key OPENAI_KEY --limit 50
# Detect anomalies (burst access, unusual hours, chain tampering)
qring audit --anomalies
# Verify audit chain integrity
qring audit:verify
# Export audit log
qring audit:export --format json --since 2026-03-01
qring audit:export --format csv --output audit-report.csv
Quantum Noise — Secret Generation
Generate cryptographically strong secrets in common formats.
qring generate # API key (default)
qring generate --format password -l 32 # Strong password
qring generate --format uuid # UUID v4
qring generate --format token # Base64url token
qring generate --format hex -l 64 # 64-byte hex
qring generate --format api-key --prefix "sk-live-" --save STRIPE_KEY
Entanglement — Linked Secrets
Link secrets across projects. When you rotate one, all entangled copies update automatically.
# Entangle two secrets
qring entangle API_KEY API_KEY_BACKUP
# Now updating API_KEY also updates API_KEY_BACKUP
qring set API_KEY "new-value"
# Unlink entangled secrets
qring disentangle API_KEY API_KEY_BACKUP
Tunneling — Ephemeral Secrets
Create secrets that exist only in memory. They never touch disk. Optional TTL and max-read self-destruction.
# Create an ephemeral secret (returns tunnel ID)
qring tunnel create "temporary-token-xyz" --ttl 300 --max-reads 1
# Read it (self-destructs after this read)
qring tunnel read tun_abc123
# List active tunnels
qring tunnel list
Teleportation — Encrypted Sharing
Pack secrets into AES-256-GCM encrypted bundles for secure transfer between machines. Two ways to lock a bundle:
- Passphrase (v1): keys derived with PBKDF2-HMAC-SHA512 (210 000 iterations); each bundle records its iteration count, so old bundles still unpack.
- Recipients (v2, 0.18): each teammate runs
qring teleport keygenonce and shares their recipient string (qring1…, an X25519 public key; the private half lives in their OS keyring).pack --toencrypts a fresh content key to every recipient — HKDF-SHA256 over an ephemeral X25519 agreement, AES-256-GCM throughout,node:cryptoonly — so nothing secret travels beside the bundle and nobody has to whisper a passphrase.
# Passphrase bundle (prompts)
qring teleport pack --keys "API_KEY,DB_PASS" > bundle.txt
cat bundle.txt | qring teleport unpack
# Recipient bundle: teammates publish their recipient once…
qring teleport keygen # → qring1a3F… (share this; keep the keyring)
qring teleport identity # print it again later
# …then you address the pack to them (repeatable or comma-separated)
qring teleport pack --keys "API_KEY,DB_PASS" --to qring1a3F… --to qring1Zz9… > bundle.txt
# They unpack with the identity in their keyring — no passphrase
cat bundle.txt | qring teleport unpack
# Preview: who it's addressed to, whether that's you, and what's inside
qring teleport unpack <bundle> --dry-run
Import — Bulk Secret Ingestion
Import secrets from .env files directly into q-ring. Supports standard dotenv syntax including comments, quoted values, and escape sequences. The CLI accepts either a file path or raw content; the import_dotenv MCP tool only accepts raw content (it never reads files from disk) so an agent can't coerce it into reading arbitrary local files.
# Import all secrets from a .env file
qring import .env
# Import to project scope, skipping existing keys
qring import .env --project --skip-existing
# Preview what would be imported
qring import .env --dry-run
Selective Export
Export only the secrets you need using key names or tag filters.
# Export specific keys
qring export --keys "API_KEY,DB_PASS,REDIS_URL"
# Export by tag
qring export --tags "backend"
# Combine with format
qring export --keys "API_KEY,DB_PASS" --format json
Secret Search and Filtering
Filter qring list output by tag, expiry state, or key pattern.
# Filter by tag
qring list --tag backend
# Show only expired secrets
qring list --expired
# Show only stale secrets (75%+ decay)
qring list --stale
# Glob pattern on key name
qring list --filter "API_*"
# Script-friendly existence check (exit 0 if present, 1 if not; decay-aware)
qring has OPENAI_API_KEY --quiet && echo "configured"
Project Secret Manifest
Declare required secrets in .q-ring.json and validate project readiness with a single command.
# Validate project secrets against the manifest
qring check
# See which secrets are present, missing, expired, or stale
qring check --project-path /path/to/project
Env File Sync
Generate a .env file from the project manifest, resolving each key from q-ring with environment-aware superposition collapse.
# Generate to stdout
qring env:generate
# Write to a file
qring env:generate --output .env
# Force a specific environment
qring env:generate --env staging --output .env.staging
Secret References & Least-Privilege Run
A qring:// reference is a committable pointer to a secret — it goes in your .env file instead of the value. qring run resolves references and manifest keys at spawn time, injecting only what the project declares (unlike exec, which injects the whole scope). Output is auto-redacted.
# .env — safe to commit: these are references, not values
DATABASE_URL=qring://project/DATABASE_URL
OPENAI_API_KEY=qring://global/OPENAI_API_KEY
STRIPE_KEY=qring:///STRIPE_KEY # auto scope: project, then global
SESSION_TTL=3600 # plain values pass through
# Run with declared secrets injected (manifest + .env refs)
qring run -- pnpm dev
# Preview what would be injected, without running
qring run --dry-run -- pnpm dev
# Pin an environment, use a specific env file, or skip the manifest
qring run --env prod --env-file .env.prod --no-manifest -- ./deploy.sh
The key lives in the path, never the host (qring://project/KEY, not qring://KEY) — URL hosts are case-insensitive, and env-var keys are not. Malformed references fail loudly instead of leaking a literal qring://… string into the child. A reference pinned to an environment: qring://project/DATABASE_URL?env=prod.
Editor Setup
Wire the q-ring MCP server into an editor's MCP config with one command. Merges non-destructively — other servers are preserved, and an existing q-ring entry is only replaced with --force.
qring setup cursor # .cursor/mcp.json (project) or --global for ~/.cursor
qring setup kiro # .kiro/settings/mcp.json, with read-only autoApprove list
qring setup claude # .mcp.json (project scope)
# Preview without writing
qring setup cursor --dry-run
Push to Deployment Platforms
Push manifest secrets to GitHub Actions, Vercel, Cloudflare Workers, fly.io, Railway, or Netlify through each platform's own authenticated CLI (gh / vercel / wrangler / flyctl / railway / netlify) — q-ring never holds platform tokens, and values travel over stdin (or, for Netlify's import-only CLI, a 0600 temp file that is removed immediately), never argv. Every push is recorded in the audit chain.
# Push the .q-ring.json manifest keys to GitHub Actions secrets
qring push github --repo you/your-app
# Push to Vercel environments
qring push vercel --vercel-env production,preview
# Push to Cloudflare Workers secrets
qring push cloudflare
# fly.io (flyctl secrets import over stdin — note flyctl deploys per import), Railway, Netlify
qring push fly --app my-app
qring push railway --service api --railway-env production
qring push netlify --site 1234-abcd
# Explicit keys, preview first
qring push github --keys DATABASE_URL,API_KEY --dry-run
Canaries can ride along: qring canary plant KEY --format aws --push github plants a honeytoken locally and seeds it into the platform without reading it back (see Canary Honeytokens).
Secret Liveness Validation
Test if a secret is actually valid with its target service. q-ring auto-detects the provider from key prefixes (sk- → OpenAI, ghp_ → GitHub, etc.) or accepts an explicit provider name.
# Validate a single secret
qring validate OPENAI_API_KEY
# Force a specific provider
qring validate SOME_KEY --provider stripe
# Validate all secrets with detectable providers
qring validate --all
# Only validate manifest-declared secrets
qring validate --all --manifest
# List available providers
qring validate --list-providers
Built-in providers: OpenAI, Anthropic, OpenRouter, Google AI (Gemini), Groq, Hugging Face, ElevenLabs*, Vercel*, Stripe, GitHub, AWS (format check), Generic HTTP. Keys are only ever sent in headers, never URLs. (*no safe public prefix — select explicitly with --provider or the manifest provider field.)
Output:
✓ OPENAI_API_KEY valid (openai, 342ms)
✗ STRIPE_KEY invalid (stripe, 128ms) — API key has been revoked
⚠ AWS_ACCESS_KEY error (aws, 10002ms) — network timeout
○ DATABASE_URL unknown — no provider detected
Hooks — Callbacks on Secret Change
Register webhooks, shell commands, or process signals that fire when secrets are created, updated, or deleted. Supports key matching, glob patterns, tag filtering, and scope constraints.
# Run a shell command when a secret changes
qring hook add --key DB_PASS --exec "docker restart app"
# POST to a webhook on any write/delete
qring hook add --key API_KEY --url "https://hooks.example.com/rotate"
# Trigger on all secrets tagged "backend"
qring hook add --tag backend --exec "pm2 restart all"
# Signal a process when DB secrets change
qring hook add --key-pattern "DB_*" --signal-target "node"
# List all hooks
qring hook list
# Remove a hook
qring hook remove <id>
# Enable/disable
qring hook enable <id>
qring hook disable <id>
# Dry-run test a hook
qring hook test <id>
Hooks are fire-and-forget: a failing hook never blocks secret operations. The hook registry is stored at ~/.config/q-ring/hooks.json.
SSRF protection: HTTP hook URLs targeting private/loopback IP ranges (127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, ::1, fc00::/7) are blocked by default. DNS is checked up front and re-validated at connect time, so a hostname can't pass the check then rebind to a private address before the socket opens. To allow hooks targeting local services (e.g. during development), set the environment variable Q_RING_ALLOW_PRIVATE_HOOKS=1.
Configurable Rotation
Set a rotation format per secret so the agent auto-rotates with the correct value shape, and a rotation interval so q-ring reminds you before a credential goes stale. Every secret remembers when its value last changed (rotatedAt); with --rotate-every it becomes due soon inside the last 20% of the interval (or the last 7 days, whichever is shorter) and overdue past it — in qring inspect, qring rotate:due, the dashboard's "Rotate soon" card and the inspect_secret tool.
# Store a secret with rotation format metadata
qring set STRIPE_KEY "sk-..." --rotation-format api-key --rotation-prefix "sk-"
# Store a password with password rotation format
qring set DB_PASS "..." --rotation-format password
# Remind me every 90 days
qring set STRIPE_KEY "sk-..." --rotate-every 90
# What needs rotating? (most overdue first; --all lists every scheduled secret)
qring rotate:due
qring rotate:due --json
Secure Execution & Auto-Redaction
Run commands with secrets securely injected into the environment. All known secret values are automatically redacted from stdout and stderr to prevent leaking into terminal logs or agent transcripts. Exec profiles restrict which commands may be run.
# Execute a deployment script with secrets injected
qring exec -- npm run deploy
# Inject only specific tags
qring exec --tags backend -- node server.js
# Run with a restricted profile (blocks network tools and interpreters/shells, 30s timeout)
qring exec --profile restricted -- npm test
Codebase Secret Scanner
Migrating a legacy codebase? Quickly scan directories for hardcoded credentials using regex heuristics and Shannon entropy analysis.
# Scan current directory
qring scan .
Output:
✗ src/db/connection.js:12
Key: DB_PASSWORD
Entropy: 4.23
Context: const DB_PASSWORD = "..."
Composite / Templated Secrets
Store complex connection strings that dynamically resolve other secrets. If DB_PASS rotates, DB_URL is automatically correct without manual updates.
qring set DB_USER "admin"
qring set DB_PASS "supersecret"
qring set DB_URL "postgres://{{DB_USER}}:{{DB_PASS}}@localhost/mydb"
# Resolves embedded templates automatically
qring get DB_URL
# Output: postgres://admin:supersecret@localhost/mydb
User Approvals (Zero-Trust Agent)
Protect sensitive production secrets from being read autonomously by the MCP server without explicit user approval. Each approval token is HMAC-verified, scoped, reasoned, and time-limited. The gate applies to bulk r
