# HDTP Gateway

> The self-hosted HDTP node: one Go binary that runs a personal, permission-gated MCP server.

## The problem

Two people each have an assistant. Today those assistants cannot talk to each
other unless both people chose the same product — and then that product sits in
the middle of every word.

The fix is not another chat app. It is what email already proved: **everyone runs
their own endpoint, and addresses are portable.** HDTP is that idea for agents,
and `hdtp-gateway` is the endpoint you run.

```mermaid
graph LR
    AA["Alice's agent"] -->|"owner MCP<br/>bearer token"| AN["Alice's node"]
    AN -->|"mTLS + sealed envelope"| BN["Bob's node"]
    BN -->|"owner MCP"| BA["Bob's agent"]
    AN -.->|"vCard: endpoint + key"| BN
```

No server in that picture has to be trusted by both parties. Bob's node decides
what Alice's agent may do, Alice's decides what Bob's may do, and each holds its
own keys.

## What makes it different

- **You are a keypair, not an account.** Your identity is the SHA-256 of your
  public key. Nothing to sign up for, no username, no provider to be locked out of.
- **Every capability is an MCP tool behind a per-contact switchboard.** A close
  friend can book time. A stranger who redeemed a one-time invite can send one
  message and discover nothing else — `tools/list` is filtered per caller.
- **Sealed end to end.** Payloads are HPKE-sealed and signed, so tunnels and edges
  carry ciphertext. They learn which key a message is for and when — never who sent
  it, and never what it says.
- **It works from behind CGNAT.** Direct, Tailscale, frp, ngrok, Cloudflare, or your
  own domain. With no inbound path at all you need one of those tunnels — or a host:
  there is no store-and-forward relay, because one would see every sender, recipient
  and timestamp for its trouble (HDTP §9).
- **One binary, SQLite by default.** No cluster, no broker, no queue. Postgres
  when you want it.

## What a contact actually is

A **vCard** — the format your phone already understands, plus two fields.
Sharing your agent's address is sharing a contact.

![Your card: a vCard carrying the HDTP certificate and seal policy](/images/gateway/card.png)

`X-HDTP-CERT` is one certificate — the **leaf** your own root issued this host —
and it carries everything: where to reach you, the key to seal to, the
fingerprint of the root that is your identity, and how long it is good for. What
a contact pins is that root, never the host's key, which is what lets you change
hosts without changing who you are. `X-HDTP-SEAL` says whether to seal. That is
the whole address book.
