Sealed Transport for MCP: End-to-End Encrypted MCP Through Untrusted Relays

Working draft (Specification Enhancement Proposal, not yet submitted). See About ‘WIP’. This is the sealed stream that Garage Door has used since November 12, 2026 to connect Garage Remote on iOS, Android and the desktop to a person’s own nodes, restated as an extension to the Model Context Protocol so that any client, server or relay could implement it. The extension identifier below is a proposal; the MCP project has not adopted it.

Field Value
Title Sealed transport: end-to-end encrypted MCP through untrusted relays
Author Rick Mark-Penwell
Status Draft
Type Extensions Track (a transport extension; MCP’s messages do not change)
Created 2026-11-24
Extension identifier io.modelcontextprotocol/sealed (proposed)

Abstract

The sealed transport carries MCP’s JSON-RPC messages between a client and a server that cannot reach each other directly. They connect through a relay that forwards opaque bytes and holds no key able to read or alter them.

Each session is a Noise Protocol Framework handshake (Noise_IK_25519_ChaChaPoly_SHA256 for a known device, Noise_XX_25519_ChaChaPoly_SHA256 to enroll one), run over WebSocket binary messages. After the handshake, every MCP message travels as encrypted chunks.

Trust is anchored in a trust anchor, an Ed25519 key held only by the servers. The anchor certifies each server’s and each client device’s static keys. Enrolling a new device needs a person’s approval, either by comparing a short code on both screens or by scanning a QR code that carries a one-time secret.

The relay can route sessions, deny service and observe sizes and timing. It cannot read requests, results or tool names, and it cannot forge or reorder them.

Motivation

MCP defines two transports: stdio, for a server the client launches, and Streamable HTTP, for a server the client reaches by URL. Neither fits a common deployment: a personal or company server behind NAT or a firewall that opens no listener, reached from a phone or a laptop elsewhere.

Today the usual answer is a hosted gateway. The server dials out to the gateway, the client speaks Streamable HTTP to the gateway, and the gateway terminates TLS. The gateway therefore sees every query and every excerpt in the clear. For MCP servers that front private corpora (mail, documents, code), that is the very data the deployment exists to protect. Keys derived from an OAuth token do not help, because the authorization server that issues the token is usually the gateway itself, and the token reaches it on every request.

When the client can run the implementer’s code (a native app, a desktop bridge launched over stdio, an IDE plugin), the two ends can encrypt to each other and use the gateway only as a relay. This proposal standardizes how they do that, so that:

Terminology

The key words MUST, SHOULD and MAY are used as in RFC 2119 and RFC 8174.

Specification

1. Layers

MCP JSON-RPC message (UTF-8 JSON)
  └─ chunked into Noise transport messages (section 5)
       └─ Noise handshake and transport (section 4)
            └─ WebSocket binary messages: device ⇄ relay (section 3)
                 └─ relay ⇄ server: the relay's own tunnel, out of scope

The relay-to-server leg is out of scope. A relay MUST deliver each binary message from the device to the server, and each from the server back to the device, unmodified and in order, for the life of one WebSocket. It MUST NOT merge or split messages.

2. Discovery and the directory

A device needs a node id, an endpoint for it, and the anchor key. It learns them from one of:

{
  "extension": "io.modelcontextprotocol/sealed",
  "profile": "mcp",
  "anchor_key": "<b64u Ed25519 public key>",
  "servers": [
    {
      "node_id": "<opaque, section 2.1>",
      "endpoint": "<opaque wss:// URL>",
      "identity_key": "<b64u Ed25519>",
      "agreement_key": "<b64u X25519>",
      "certificate": "<b64u signature, section 6.1>",
      "online": true
    }
  ],
  "device_certificates": [ { "...": "section 6.2" } ],
  "revocations": [ { "device_id": "<b64u>", "signature": "<b64u>" } ]
}

A device MUST verify each server’s certificate against the anchor key and MUST ignore a server whose certificate fails. A device that has already pinned an anchor key MUST stop if a directory lists a different one.

A directory reached through a server’s MCP Protected Resource Metadata or server card MAY advertise the extension under its identifier. The exact field is left to the MCP project’s general extension-negotiation mechanism.

2.1 Node ids and endpoints

The proposal fixes no address format. A node id is an opaque string of 1 to 128 characters from the base64url alphabet. An endpoint is an opaque wss:// URL. Clients MUST NOT parse, build or derive either one. They take both from the directory or a pairing link, and compare node ids only for equality.

3. The WebSocket

4. Handshake

IK (an enrolled device).

Message Direction Payload
1 device → server {"certificate": <device certificate>}
2 server → device {"node_id": <node id>}, plus "renewed": <device certificate> when section 6.5 applies

The server MUST check that the certificate verifies under the anchor key, that it has not expired, that its agreement_key equals the static key the handshake revealed, and that the device has not been revoked. If any check fails, the server MUST close the session without replying.

XX (a device enrolling).

Message Direction Payload
1 device → server empty
2 server → device {"node_id", "identity_key", "certificate"}: the server’s node certificate
3 device → server {"identity_key", "name"}, plus "pairing": <proof> for QR pairing (6.4)

After message 2, the device MUST verify the node certificate under the anchor key it holds, against the agreement key the handshake revealed, and MUST stop if verification fails. A server that takes no new devices MUST close the session when it receives an XX message 1.

When Split() completes, the server’s first transport message (section 5) in an XX session is the enrollment result: {"enrolled": <device certificate>} or {"refused": "<reason>"}. After a refusal, the server closes the session. After enrolled, the session carries MCP like any IK session.

5. Transport framing

After Split(), every MCP message (one JSON-RPC request, response or notification, or a JSON-RPC batch where the negotiated MCP version allows one) is sent as one or more chunks:

plaintext chunk = flag (1 byte) || up to 65,518 bytes of the message
flag            = 0x01 for the message's last chunk, 0x00 when more follow
binary message  = Noise transport encryption of the plaintext chunk (adds a 16-byte tag)

Within a session, MCP runs unchanged. Either side MAY send requests and notifications, so server-to-client requests (sampling, elicitation) work as they do over stdio. Mcp-Session-Id, SSE and resumability belong to Streamable HTTP and do not apply.

6. Trust anchor, certificates and enrollment

6.1 Node certificate

The node certificate is the anchor’s Ed25519 signature, in b64u, over:

P + " node certificate v1\n" + node_id + "\n" + identity_key + "\n" + agreement_key

identity_key and agreement_key are the server’s keys in b64u.

6.2 Device certificate

The device certificate is a JSON object:

Member Value
device_id equal to identity_key
identity_key the device’s Ed25519 public key, b64u
agreement_key the device’s X25519 public key, b64u
name at most 80 characters, no newline
scope an opaque string the servers interpret (6.6)
expires_at an integer, Unix seconds
signature the anchor’s Ed25519 signature, b64u, over the payload below
P + " device certificate v1\n" + device_id + "\n" + identity_key + "\n" + agreement_key + "\n"
  + name + "\n" + scope + "\n" + decimal(expires_at)

Certificates SHOULD last no more than 90 days.

6.3 Enrolling by short code

The default way to enroll is for the person to compare a short code on both screens:

  1. The device runs XX (section 4). Both ends then compute a code from the final handshake hash h: d = SHA-256(P + " enroll code v1" || h). Take the first 4 bytes of d as a big-endian unsigned integer, shift it right by 2, and read the top 30 bits as six 5-bit groups, most significant first. Map each group through Crockford’s base32 alphabet 0123456789ABCDEFGHJKMNPQRSTVWXYZ, and show the result as XXX-XXX.
  2. The server shows the device’s name and the code, and asks the person to approve. It SHOULD also ask which scope to grant. The device shows the same code.
  3. If the person approves, a server that holds the anchor’s private key signs a device certificate and returns it as {"enrolled": ...}. The device MUST verify that certificate under its anchor key, for its own agreement key, before it keeps it.

The comparison is what defeats a relay in the middle. A relay that substitutes its own keys runs two separate handshakes, one with each end, and the two have different hashes, so the codes differ.

6.4 Enrolling by QR code

A server that holds the anchor’s private key MAY show a pairing link as a QR code:

<scheme>://join?endpoint=<endpoint>&node=<node id>&anchor=<anchor key>&secret=<b64u of 32 random bytes>

The secret is single-use and SHOULD expire within 10 minutes. The device pins the anchor key from the link, not from the directory. In XX message 3 it adds:

"pairing": b64u(HMAC-SHA256(secret, P + " pairing v1\n" || h3))

Here h3 is the handshake hash just before message 3 is written. A server that finds a matching, unused, unexpired secret approves the device at once, with the scope chosen when the code was shown, and then discards the secret. A proof that matches no pending secret MUST be refused, not offered to the person for approval.

6.5 Renewal

When an enrolled device’s certificate expires within 30 days, a server holding the anchor’s private key MAY add "renewed" to its IK message 2: a new certificate for the same device_id and keys, with a later expires_at. The device MUST keep it only if it verifies under the pinned anchor key for the device’s own agreement key and lasts longer than the certificate it replaces. Otherwise the device MUST ignore it.

6.6 Scope

scope is decided by the server. Servers MUST apply it to everything a session may do, and SHOULD leave out of tools/list the tools the scope does not allow. Garage uses search (read tools only) and ask (also the server’s own model). A server MAY narrow a scope further by local policy, but MUST NOT widen it.

6.7 Revocation

A revocation is the anchor’s signature over P + " device revocation v1\n" + device_id. Servers MUST refuse a revoked device at its next handshake, and SHOULD share revocations through the directory so that every server learns of them.

7. Errors and closing

A server that refuses a handshake closes the WebSocket. The relay MAY tell the device that the server is offline by closing with code 1013 (Try Again Later). Errors at the MCP level are ordinary JSON-RPC errors inside the session. Close reasons MUST NOT carry anything confidential, because the relay reads them.

Rationale

Alternatives considered:

Security considerations

Backward compatibility

This proposal adds a transport. MCP’s messages, its lifecycle and its other transports do not change. A client or server that does not implement the transport is unaffected.

Reference implementation

Garage Door runs this protocol with P = garage: a Ruby relay, reference server end and desktop bridge, a Swift server end on macOS with iOS and macOS clients, and a Kotlin client for Android. Each is tested against the published Noise test vectors, and an end-to-end test checks that no plaintext crosses the relay. Garage Door’s code is closed source; the protocol described here is open for anyone to implement.

Garage’s deployment differs from this text in a few names and shapes, none of which touches the cryptography, so it can align without re-enrolling any device:

  1. It sends no WebSocket subprotocol yet; mcp.sealed.v1 is a one-line change on each end.
  2. Its node id is the door id, a short slug, and the device builds the endpoint itself. The proposal’s node id is opaque and its endpoint comes from the directory.
  3. Its pairing link names the parameters gateway, door and account.
  4. Its directory carries the same facts in its own shape behind Door’s sign-in, rather than as the public document in section 2.
  5. Its server end only answers requests; nothing Garage serves needs server-to-client requests today.

Open items