From 917d22e6313a58969e80b2d156973bd20c2014b1 Mon Sep 17 00:00:00 2001 From: Kartik4152 Date: Thu, 19 Nov 2026 17:39:30 +0530 Subject: [PATCH 1/2] docs: describe the cloudflare edge Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012KwNzhtVedRTmReq4zho5W --- README.md | 4 ++++ deploy/AWS.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/README.md b/README.md index f18ae83..c8141f3 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,10 @@ Run the same transport yourself with `peer mcp --transport http`. HTTP refuses the `cash` and `full` profiles; those authority-bearing profiles remain local stdio processes. +The hosted server sits behind Cloudflare. It returns plain JSON with no +long-lived stream, and a tool call must start its response within 100 s or +Cloudflare returns 524. See [Edge (Cloudflare)](deploy/AWS.md#edge-cloudflare). + ## Peer Cash The retired standalone `peer-cash-mcp` server now lives here. Its tool names and diff --git a/deploy/AWS.md b/deploy/AWS.md index f755b16..0102394 100644 --- a/deploy/AWS.md +++ b/deploy/AWS.md @@ -115,6 +115,42 @@ Caddy routing and network isolation. Caddy forwards to loopback with a loopback Host header to preserve MCP host validation. `/health` checks process readiness; it does not verify every tool's upstream provider integration. +## Edge (Cloudflare) + +`mcp.peer.xyz` is proxied by Cloudflare. The host's security group accepts +80/443 only from Cloudflare's ranges, plus 443 from Kohai, its one listed +internal caller, so a request to the host's public IP times out. Operator access +stays on SSM. Zones, DNS records and the WAF live in peer-infra +`stacks/cloudflare-edge`; the security group, private DNS and caller lists in +`stacks/edge-ingress/boxes.json`. + +- **Caddy.** peer-infra `tools/edge-origin` (SSM document `peer-edge-origin`) + owns the edge part of the Caddyfile. Caddy trusts only Cloudflare's ranges, + answers 403 to a Cloudflare connection without our origin-pull client + certificate, and writes a JSON access log to `/var/lib/caddy/logs/access.log` + without query strings. Never hand-edit those blocks; peer-deploy's upstream + rewrite keeps them, and the loopback Host header is unchanged. +- **Client IP.** The server never reads the caller's address and has no per-IP + limiter, so IPv6 callers need nothing special. +- **No streams.** `/mcp` is stateless JSON (`enableJsonResponse`, no sessions) + and `GET /mcp` answers 405, so there is no SSE stream to keep alive. Each tool + call answers once, when it finishes. Cloudflare returns 524 if that answer has + not started within 100 s, although the Node server allows 120 s + (`requestTimeout` in `src/mcp/server.ts`). Nothing is cached. +- **Calls out.** Inside the VPC, Peer hostnames resolve to private addresses, + so this host reaches another Peer box only when it is in that box's + `internal_callers`. It is listed for the prod indexer only, not for Curator + (`api.zkp2p.xyz`, used by the `quote` tool) or Pay API. Add a caller with a + peer-infra PR to `boxes.json` and a stack apply; never open a security group + by hand. +- **Errors.** 520–526 come from Cloudflare and mean an origin problem (526 is an + invalid origin certificate). A WAF block is Cloudflare's own 403 page + (`server: cloudflare`); it never reaches Caddy, so it is absent from the access + log. +- **TLS.** Cloudflare serves the edge certificate and connects in Full (strict) + mode; Caddy keeps renewing its Let's Encrypt certificate over HTTP-01 through + Cloudflare. + ## Monitoring and logs The host health collector is owned by peer-infra `hosts/mcp/` (see From f9dbe5de003a3bfaf37ce3e4274eff1056b7f105 Mon Sep 17 00:00:00 2001 From: Kartik4152 Date: Thu, 19 Nov 2026 17:42:48 +0530 Subject: [PATCH 2/2] docs: correct the waf and origin timeout notes Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012KwNzhtVedRTmReq4zho5W --- README.md | 5 +++-- deploy/AWS.md | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c8141f3..aed47a0 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,9 @@ the `cash` and `full` profiles; those authority-bearing profiles remain local stdio processes. The hosted server sits behind Cloudflare. It returns plain JSON with no -long-lived stream, and a tool call must start its response within 100 s or -Cloudflare returns 524. See [Edge (Cloudflare)](deploy/AWS.md#edge-cloudflare). +long-lived stream. Plan for a tool call to start its response within 100 +seconds; past Cloudflare's origin timeout the call gets a 524. See +[Edge (Cloudflare)](deploy/AWS.md#edge-cloudflare). ## Peer Cash diff --git a/deploy/AWS.md b/deploy/AWS.md index 0102394..3d00246 100644 --- a/deploy/AWS.md +++ b/deploy/AWS.md @@ -134,9 +134,10 @@ stays on SSM. Zones, DNS records and the WAF live in peer-infra limiter, so IPv6 callers need nothing special. - **No streams.** `/mcp` is stateless JSON (`enableJsonResponse`, no sessions) and `GET /mcp` answers 405, so there is no SSE stream to keep alive. Each tool - call answers once, when it finishes. Cloudflare returns 524 if that answer has - not started within 100 s, although the Node server allows 120 s - (`requestTimeout` in `src/mcp/server.ts`). Nothing is cached. + call answers once, when it finishes. Plan for 100 seconds: Cloudflare returns + 524 if that answer has not started by its origin timeout, although the Node + server allows 120 s (`requestTimeout` in `src/mcp/server.ts`). Nothing is + cached. - **Calls out.** Inside the VPC, Peer hostnames resolve to private addresses, so this host reaches another Peer box only when it is in that box's `internal_callers`. It is listed for the prod indexer only, not for Curator @@ -144,9 +145,11 @@ stays on SSM. Zones, DNS records and the WAF live in peer-infra peer-infra PR to `boxes.json` and a stack apply; never open a security group by hand. - **Errors.** 520–526 come from Cloudflare and mean an origin problem (526 is an - invalid origin certificate). A WAF block is Cloudflare's own 403 page - (`server: cloudflare`); it never reaches Caddy, so it is absent from the access - log. + invalid origin certificate). A WAF block is Cloudflare's own HTML block page + ("Sorry, you have been blocked", with a Cloudflare Ray ID); it never reaches + Caddy, so it is absent from the access log. A response from the server itself + is JSON. Every proxied response carries `server: cloudflare`, so that header + does not identify a block. - **TLS.** Cloudflare serves the edge certificate and connects in Full (strict) mode; Caddy keeps renewing its Let's Encrypt certificate over HTTP-01 through Cloudflare.