AI Focus

custodian narrow mcp gateway

Why this matters

Connecting an automated tool directly to a wide REST catalog or handing it a static provider API key floods its context with dozens of schemas and lets a single prompt injection call arbitrary URLs or leak credentials in tool outputs. Putting a narrow 4-tool MCP gateway in front of fixed allowlisted operations keeps upstream secrets inside edge custody.

What this opens up

Browser-hosted agents can discover and invoke typed backend operations through just 4 fixed Model Context Protocol tools (search_capabilities, describe_operation, connection_status, invoke_operation)—with human-approved call budgets, byte-bound per-call agent signatures, instant epoch revocation, and zero raw credentials in the client.

How the tests work

  1. Click 1. Create Dual Keys & Enroll Grant to generate two separate non-extractable ECDSA P-256 keypairs (HumanApprovalKey and AgentSessionKey), confirm the browser Worker’s locked CSP self-check, and record the human-signed delegation in SQLite.
  2. Click 2. Call repo.release.list@v1 via MCP to sign the exact request arguments inside /workers/secret-custodian.js and send invoke_operation to POST /mcp, returning schema-projected output while UPSTREAM_CANARY_TOKEN stays server-side.
  3. Click 3. Run All 6 Exploits & Leak Scan to fire URL/header injection (403), nonce replay (409), 1-byte argument tampering (401), stale-epoch post-revocation calls (401), single-key collapse (403), and a permissive Worker CSP probe (unfit) while scanning every response and audit row for canary leaks.
  4. Use the Narrow 4-Tool MCP Gateway Console and DO SQLite Ledger Inspector to call each of the 4 MCP tools individually and inspect the recorded audit table and raw P-256 proof envelopes.
Replace wide agent API catalogs and raw secrets with a narrow 4-tool MCP gateway enforcing separate human and agent ECDSA P-256 proofs, instant SQLite epoch revocation, 6 live red-team attacks, and a browser Worker CSP self-check. Open custodian narrow mcp gateway full screen ↗

Hypothesis

Placing a narrow 4-tool Streamable HTTP MCP gateway in front of fixed allowlisted operations—gated by distinct HumanApprovalKey and AgentSessionKey ECDSA P-256 proofs, a SQLite Durable Object nonce/epoch ledger, and a browser Worker CSP self-check—blocks arbitrary target injection, key collapse, nonce replay, tampering, and revoked-epoch calls with zero upstream credential leakage.

What confirms it: Authorized invocations return 200 OK while UPSTREAM_CANARY_TOKEN never appears in any response, header, or audit row; all 6 live red-team attacks fail closed in CustodianLedger; and /workers/secret-custodian.js verifies securitypolicyviolation.originalPolicy before holding AgentSessionKey.

What bounds or disproves it: If a browser fails to enforce Worker script CSP headers (letting the blocked probe succeed), the custodian Worker refuses key admission rather than running with silent egress exposure, and narrowing operations behind 4 generic MCP tools adds discovery round-trips compared to static tool lists.

Under the hood

Custodian Narrow MCP Gateway (source on GitHub) combines a narrow 4-tool Streamable HTTP MCP endpoint (/mcp) with edge credential custody and browser-side Worker verification:

  • Dual ECDSA P-256 WebCrypto proofs: HumanApprovalKey signs { agentJwkThumbprint, allowedOps, maxCalls, epoch, exp } while AgentSessionKey signs the SHA-256 digest of { opId, argsJson, nonce, epoch, ts }. Submitting the same key for both roles fails closed with 403 KEY_COLLAPSE_FORBIDDEN, and altering even 1 byte of argsJson fails with 401 PROOF_DIGEST_MISMATCH.
  • SQLite Durable Object CustodianLedger: enforces a monotonic revocationEpoch (401 EPOCH_REVOKED), atomic single-use consumed_nonces (409 NONCE_REPLAYED), fixed operation allowlists (403 ARBITRARY_TARGET_FORBIDDEN), and server-only injection of UPSTREAM_CANARY_TOKEN (exposed only as a non-reversible SHA-256 fingerprint).
  • Dedicated Worker CSP self-check: /workers/secret-custodian.js fetches a blocked cross-origin URL and inspects securitypolicyviolation.originalPolicy (default-src 'none'; script-src 'self'; connect-src 'self') before accepting AgentSessionKey. A second permissive Worker (/workers/secret-custodian-permissive.js) demonstrates how an unverified runtime marks itself unfit and refuses key custody.

Key terms & further reading

Model Context Protocol (Streamable HTTP) ↗
A JSON-RPC 2.0 protocol over HTTP for exposing structured tools; narrowing it to 4 fixed tools keeps schemas compact and blocks arbitrary URL routing.
SubtleCrypto ECDSA P-256 ↗
The browser’s built-in asymmetric cryptography API, used to create separate non-extractable keys for human delegation and per-call agent possession.
RFC 7638 JWK Thumbprints ↗
A canonical SHA-256 hash of a public JSON Web Key used here to prove HumanApprovalKey and AgentSessionKey are distinct keys.
securitypolicyviolation event ↗
A browser event fired when Content Security Policy blocks a fetch, letting the Dedicated Worker verify its own connect-src 'self' policy before accepting keys.
Cloudflare Durable Objects (CustodianLedger) ↗
A single-threaded SQLite edge store enforcing monotonic revocation epochs, single-use nonces, and server-only injection of the upstream canary secret.

Open questions

  • How many allowlisted operations can live behind search_capabilities + describe_operation before retrieval precision drops for smaller local models?
  • How should epoch revocation propagate offline across cached Worker delegates without requiring a synchronous ledger round-trip on read-only operations?

Iteration log

  • — Deployed Streamable HTTP 4-tool MCP gateway (/mcp, 2025-03-26), dual non-extractable WebCrypto ECDSA P-256 proofs (HumanApprovalKey + AgentSessionKey with RFC 7638 thumbprint separation), SQLite Durable Object CustodianLedger, 6 live red-team attacks, and /workers/secret-custodian.js runtime securitypolicyviolation.originalPolicy self-check.

Primitives tested: Streamable HTTP MCP (4-Tool Surface), crypto.subtle ECDSA P-256 (Dual Proofs), RFC 7638 JWK Thumbprints, Dedicated Worker CSP Self-Check, Durable Object SQLite (CustodianLedger).

This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.

More in delegated authority & keyless execution

Connected labs

← delegated authority & keyless execution · All labs