Skip to main content
Glama
Live Disposable API Gate & MCP Server

Live Disposable API Gate & MCP Server

CryptGate

Disposable scoped API gates and Streamable HTTP MCP endpoints for AI agents, packaged as a Kiro Crew app and zero-secret containment workbench.

Mint a temporary, path-locked proxy URL (/g/<id>/...) and matching Streamable HTTP MCP endpoint (/g/<id>/mcp) for an API key—give an agent, contractor, or Kiro Crew worker 15 minutes and 10 read-only calls without handing over the raw secret, pause real incoming HTTP/MCP requests for live human approval, and revoke access in one click.

What is in this repo

  • Live Disposable API Gate & MCP Server (POST /api/gates, POST /g/:id/mcp, ALL /g/:id/*) — Runs on Cloudflare Workers with a SQLite-backed GateCoordinator Durable Object (worker/src/index.ts + wrangler.jsonc), the local Vite dev/preview server, or self-hosted via cryptgate serve:

    • Issues path-locked, read-only, quota-capped, TTL-expiring HTTP proxy URLs (/g/:id/*) and live Streamable HTTP MCP (2025-03-26) servers (/g/:id/mcp) usable from curl, SDK baseURL overrides, or .kiro/settings/mcp.json

    • Operator-locked control plane: each gate returns a one-time 256-bit operatorToken required for polling, approvals, revocation, and receipt export—preventing untrusted agents holding /g/:id/* from self-approving or enumerating other sessions' gates

    • SSRF guard blocking RFC1918 private networks, loopback hosts, and cloud metadata IPs (169.254.169.254, metadata.google.internal)

    • Live blocking operator approval & ECDSA receipts: holds real incoming HTTP and MCP tools/call requests open on the server until approved or denied, signs every live request into an ECDSA P-256 hash chain (GET /api/gates/:id/receipt), persists active gates and signing keys to Durable Object SQLite across hibernation, strips hostile headers, blocks 3xx redirects, scrubs 7 secret encodings, and revokes instantly (410 GATE_REVOKED)

  • packages/engine (@cryptgate/engine) — Pure TypeScript security kernel with zero runtime dependencies (runs in Cloudflare Workers, Node 22, and browsers):

    • HTTPS and host allowlist enforcement (blocks suffix spoofing and non-loopback bridges)

    • Iterative percent-decoding and POSIX path canonicalization (catches .., %2e%2e, %252e%252e, null bytes, and backslashes)

    • Hostile client header stripping and hard stop on 301/302/303/307/308 redirects

    • Multi-encoding response redaction (raw, Base64, Base64URL, lower/upper hex, URL-encoded, HTTP Basic)

    • Interactive operator approval gate (per-use, 15m session, deny, and stop-all kill-switch)

    • WebCrypto RFC 6238 TOTP (ephemeral 6-digit codes without exposing Base32 seeds)

    • WebCrypto ECDSA P-256 hash-chained audit ledger (prevHash + SHA-256 + verifySignedReceipt())

    • Offline .env/log secret scanner (sanitizeEnvText()) and live public GitHub repo auditor (api.github.com)

    • Interactive prompt-injection hijack lab (hijack-lab.ts) and Kiro/Passhold config forge

  • web (@cryptgate/web) — Browser console (Paper and Ink archival themes):

    • 01 Live Gate: mint disposable HTTP + MCP gates, copy curl or Kiro MCP JSON snippets, approve/deny paused calls live, inspect scrubbed wire output, and fire real traversal/mutation/revoke tests

    • 02 Arena: 7 adversarial cases (ATK-01–ATK-07), interactive SVG airlock schematic, Prompt Hijack Lab, live RFC 6238 countdown, ECDSA audit chain verification/tamper check, and server-isolated POST /api/gate verification

    • 03 Scanner: live public GitHub repository secret auditor + offline .env dropzone with sanitized .env and .sh setup export

    • 04 Crew & Bridge: Kiro Crew package inspector and loopback (127.0.0.1) MCP/proxy bridge tester

  • worker/src/index.ts & wrangler.jsonc — Cloudflare Worker + SQLite-backed GateCoordinator Durable Object serving /api/gates/*, /g/:id/mcp, /g/:id/*, stateless /api/gate signed receipts, and web/dist static assets.

  • app.json, agents/, skills/, crons/, ui/ — Kiro Crew app package (secret-exorcist and gatekeeper-ops agents, zero-secret-ritual skill, nightly audit cron, and /apps/cryptgate UI bundle).

  • bin/cryptgate.mjs — Unified CLI (cryptgate serve, cryptgate verify-audit <receipt.json>, cryptgate scan, cryptgate mcp, cryptgate proxy, cryptgate wire).

  • scripts/cryptgate-mcp.mjs & scripts/live-proxy-demo.mjs — Local stdio MCP demo server (npm run mcp:demo) and 127.0.0.1 TCP proxy + hostile echo/302 test rig (npm run demo:live).

Related MCP server: nice

Test cases in the browser workbench

Code

Case

What it verifies

ATK-01

Prompt Injection Exfiltration

Off-host exfiltration blocked (403 HOST_NOT_ALLOWED)

ATK-02

302 Redirect Credential Smuggling

Upstream 302 halted before auth crosses origins (502 REDIRECT_BLOCKED)

ATK-03

Gzip & Multi-Encoding Echo Bypass

Accept-Encoding stripped; raw/Base64/hex/URL/Basic echoes scrubbed

ATK-04

Double-Encoded Path Traversal

/v1/customers/%252e%252e/payouts blocked after canonicalization

ATK-05

Human-in-the-Loop Mutation Seal

POST /v1/refunds pauses until operator approves once, approves 15m, or denies

ATK-06

Ephemeral 2FA TOTP Isolation

Per-use approval returns live 30s RFC 6238 6-digit code; Base32 seed stays scrubbed

ATK-07

Subprocess Stdout/Stderr Env Dump

run_command runs shell: false, strips PASSHOLD_SESSION, scrubs raw/Base64/hex from stdout & stderr

Commands

npm install
npm test            # Vitest suite (Worker Durable Object, Live Gates, Streamable HTTP MCP, SSRF, invariants, RFC 6238, ECDSA, CLI)
npm run typecheck   # TypeScript strict check across engine, web, Crew UI, and Worker
npm run scan:self   # Repository secret audit (wired to .kiro/hooks)
npm run build       # Build engine, web workbench, and Kiro Crew UI bundle
npm run dev         # Start web workbench + live /g/:id/* and /g/:id/mcp middleware at http://localhost:4173

Self-hosted server & local demos (no account required)

# Self-host the built web console + live /g/:id/* proxy + /g/:id/mcp Streamable HTTP server on 127.0.0.1:4173
node bin/cryptgate.mjs serve --port 4173

# Standalone stdio JSON-RPC 2.0 MCP server backed by synthetic demo grants
npm run mcp:demo

# Real 127.0.0.1 TCP zero-secret proxy (8787) + hostile echo/302 upstream (8788)
npm run demo:live

Using real secrets with Passhold Agents

CryptGate wires to the public open-source CLI @keyrook/passhold-cli for real agent vaults:

npm install -g @keyrook/passhold-cli
npm run wire:kiro -- --apply
passhold mcp --http --port 8765 --expires 8h

Workspace .kiro/ layout

  • .kiro/specs/cryptgate/ — requirements, design, and implementation tasks

  • .kiro/steering/ — security invariants and TypeScript conventions

  • .kiro/hooks/ — save-time repository secret scan (npm run scan:self) and engine test gate (npm test)

  • .kiro/settings/mcp.json — workspace MCP server configuration for @keyrook/passhold-cli

Credits & external tools

All source code in this repository was written from scratch for CryptGate. Production secret storage and real loopback proxying integrate with the open-source @keyrook/passhold-cli package from Keyrook. The browser workbench, built-in hostile echo target, and npm run mcp:demo use synthetic cg_demo_* fixtures so everything runs cleanly with zero setup.

License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A security-hardened MCP gateway that enables AI agents to call LLM APIs (Gemini, OpenAI, Claude, etc.) using ephemeral proxy tokens, eliminating exposure of real API keys.
      49 npm
      6
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a secure MCP gateway for AI agents to access APIs without exposing raw credentials, with scoped access, audit logging, and OAuth support.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables governed agent access to tools by routing and authorizing MCP requests through configurable policies, credential-bound upstream connections, human approval workflows, and an administration console.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to access remote and local MCP servers plus HTTP APIs through a single MCP endpoint, with per-consumer scoped tokens, tool-level permissions, and encrypted secret management.
      10
      AGPL 3.0