feat(http): carry the edge's geography to the API and the tenant's home back to the edge - #100
Merged
Merged
Conversation
…me back to the edge The hosted gateway calls the API on the caller's behalf from its own address, so the API saw nothing about where the caller was, and the home the API named on those calls never reached the Cloudflare MCP gateway. The router's per-credential home memory therefore never filled for MCP traffic (two consecutive calls both answered "hint: none"), MCP-driven request rows carried no nearest region or country, and a tenant's MCP calls were placed by geography alone. - The transport reads X-ContextStream-Suggested-Home-Region and CF-IPCountry from the router, keeps only canonical values, and scopes them as EdgeGeography; request() and request_text() forward them on every API call. - Every API response's x-contextstream-tenant-home-region is captured in the request's scope and mirrored onto the transport's response. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: escott- <escott05@gmail.com>
escott-
force-pushed
the
feat/edge-geography-and-tenant-home
branch
from
September 13, 2026 16:10
35db826 to
66257e7
Compare
Signed-off-by: escott- <escott05@gmail.com>
contextstreamio
approved these changes
Sep 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The hosted gateway calls the API on the caller's behalf from its own address, so the API saw nothing about where the caller was, and the home the API named on those calls never reached the Cloudflare MCP gateway (
deploy/cloudflare/cloudflare-mcp-gatewayin the platform repo). Two consequences measured on 2026-09-13:tools/callrequests both answeredx-contextstream-tenant-home-hint: none, so a tenant's MCP calls were placed by geography alone and a traveling user, or a tenant whose home differs from its geography, paid a cross-region hop per statement.api_request_logscarried nonearest_regionand noclient_region, so MCP-heavy users are invisible to the state-level re-homing that decides where a tenant should live.What
X-ContextStream-Suggested-Home-RegionandCF-IPCountryfrom the router, keeps only canonical values (ovh-west|ovh-east|eu-ams, two ASCII letters), and scopes them per request asEdgeGeography;request()andrequest_text()forward them on every API call. Nothing else the caller sends can reach API telemetry through this path.x-contextstream-tenant-home-regionis captured in the request's scope and mirrored onto the transport's response, so the edge remembers the caller's home.Both are additive; older APIs ignore the request headers and never set the response header.
Verification
cargo test -p mcp-types -p mcp-client --lib: 272 + 91 pass.cargo test -p mcp-server --lib transport::http: includes a new assertion that the geography is parsed in canonical form and that forged values (amsterdam,NLD) are dropped.Rollout
Rides the next
mcp-http-gatewayimage (release tag); the platform'sdeploy-mcp-http.ymlrolls it. Until then the edge places MCP traffic by geography, which is right for tenants whose home matches their users' location.🤖 Generated with Claude Code