Skip to content

How the MCP Tower proxy works

MCP Tower is a reverse proxy in front of your remote MCP server. It runs as a Cloudflare Worker on Cloudflare’s global edge, which these docs call the middleware. You publish a hostname on your own domain that points at MCP Tower; the middleware forwards every request to your server, returns the answer, and records what happened.

In short:

  • Request and response bodies stream through byte for byte, except the few messages listed in What the middleware changes.
  • Your origin receives each request with forwarding headers and the origin secret.
  • Events are recorded after the response, so recording never blocks or changes a request.
  • Uptime checks, scans and Inspect calls also reach your origin, and none of them count as tool calls.
AI agent ──► https://mcp.example.com/ (MCP Tower, on Cloudflare's edge)
│
├─► your origin: https://mcp-origin.example.com/mcp
│
└─► after the response: the event, to MCP Tower's analytics
  1. The agent connects to your public MCP URL. Your CNAME sends the hostname to MCP Tower, and the request runs on Cloudflare’s edge.
  2. The middleware looks up the hostname. An unknown hostname, or a server that is turned off, answers 404 Not found.
  3. It forwards the request to your origin URL, with the method, body and headers as they came, and streams the answer back. Streamable HTTP responses, JSON and SSE alike, reach the agent as your server produces them.
  4. After the answer is on its way, it records the event.

Your server keeps its own hostname, separate from the public one: once the public hostname points at MCP Tower, it can no longer reach your server directly.

HeaderValue
HostYour origin’s host
X-Forwarded-HostThe public hostname, if your server builds public URLs
X-Forwarded-Protohttps
X-Forwarded-ForThe address of the client that connected, as Cloudflare saw it. A client’s own X-Forwarded-For, Forwarded, X-Real-IP, True-Client-IP, X-Client-IP and X-Cluster-Client-IP are removed
X-MCP-Tower-Origin-SecretYour server’s origin secret, on every request
X-MCP-Tower-Internal: 1Only on calls made from Inspect

Authorization, cookies and the other headers pass through untouched, except hop-by-hop headers such as Connection, which apply to one connection only. Any X-MCP-Tower-* header an agent sends is removed before the request leaves the middleware, so the origin secret can’t be forged. See Protect your origin with the origin secret.

Redirects from your origin go back to the agent. When your public path differs from your origin path, MCP Tower maps one onto the other; see Publish a different path.

Your server may build absolute URLs from its own host: a tool’s icon, a link in a tool result, a widget’s image, an MCP elicitation URL, a redirect. The middleware puts each one on the public hostname before the agent sees it, in every MCP message it relays and in Location headers. A URL keeps its path, query and fragment (mapped like requests when your public path differs from your origin path); links to other hosts are left alone. So honouring X-Forwarded-Host is optional.

A few values are never changed, because your server must recognise them when they come back: resource uri and uriTemplate values and an elicitation’s requestState. HTML pages, files and images your server serves are passed through as they are. A path the public hostname can’t reach (outside your public path’s mapping) stays on your origin host.

The middleware records the event after the response has been returned. If recording fails, the failure is caught and logged; the agent still gets your server’s answer. Analytics problems never delay, block or change a proxied request.

When your origin can’t be reached (DNS, connection or certificate failure), the agent gets 502 Bad gateway: the MCP server could not be reached., and the event records the error class.

When recording is off for a server (tracking paused, the tool-call quota reached, or a payment overdue), traffic still flows; only the recording stops.

MCP Tower has not published a measured latency figure yet. Requests are handled on Cloudflare’s edge, and bodies stream through without waiting for the full answer. The middleware reads a message in full only when it changes it (below): a request body up to 1 MB, a JSON answer up to 4 MB, or one SSE event up to 4 MB. A larger message passes through unchanged.

  • Your public hostname must be a subdomain (mcp.example.com). A domain’s apex can’t be a CNAME.
  • It belongs to one MCP server across all of MCP Tower, and can’t change once the server is connected. To use another hostname, remove the server and add it again.
  • MCP Tower uses Cloudflare for SaaS custom hostnames. Cloudflare issues a domain-validated certificate for your hostname, ECDSA and RSA, once the CNAME is in place: it validates the certificate over HTTP and answers the validation URLs itself. The certificate needs no TXT record.
  • Before MCP Tower creates a hostname, your organization proves it controls the domain with a TXT record, mcp-tower-verification=<token>, on the domain itself (example.com for mcp.example.com). You add it once per domain; it covers every server of your organization on that domain. See Verify your domain.
  • MCP Tower checks those URLs while you connect. If something in front of it blocks /.well-known/acme-challenge/, it switches the certificate to delegated validation and asks for a second CNAME, _acme-challenge.<hostname>, which Cloudflare also uses for every renewal.
  • Your origin must serve HTTPS with a valid certificate.

Most traffic passes through byte for byte. The middleware edits only these messages, and only when the feature is in use for your server:

WhatChangeTurned on by
tools/list, prompts/list, prompts/get, resources/list, resources/templates/listTitles and descriptions you overrodeOverrides
prompts/list, prompts/getMCP Tower prompts listed on the last page and answered by the middlewareMCP Tower prompts
resources/list, resources/readMCP Tower resources listed and answered by the middleware; resource texts you replacedInspect
initialize, server/discoverDeclares prompts or resources when your server declares none and MCP Tower adds someMCP Tower prompts and resources
tools/listAdds the _track_event tool on the last page, for widgets to report eventsTrack widget interactions
resources/read of HTML widgetsAdds the tracker script, and two invisible images for load pixelsTrack widget interactions, Widget load pixels
tools/call resultsRewrites https:// links to https://<your hostname>/_mcptower/goto/…, which redirect to the originalTrack links
/.well-known/oauth-protected-resource and WWW-Authenticateresource and resource_metadata that name your origin host now name the public hostnameAlways

Two more additions, to _meta:

  • While any recording switch is on, every tools/call result gets _meta["mcptower/analytics"] with a render_id, which joins the call to its widget’s events and link clicks. Your other _meta keys are kept.
  • With Widget load pixels on, your public hostname is added to the widget’s allowed image domains (_meta.ui.csp.resourceDomains, and openai/widgetCSP when present), so the pixels can load.

Never changed: tool, prompt and resource names, input and output schemas, required arguments, annotations (hints), the _meta of tools, status codes, and authorization server metadata (issuer, endpoints, jwks_uri).

With widget tracking on, agents see one extra tool, _track_event. Its description tells the model not to call it; widgets call it to report loads, clicks and errors. The middleware answers it itself and your server never receives it, only a ping that asks whether your server lets the caller in (a 401 or 403 is passed on and nothing is recorded). A model that calls it anyway gets a harmless answer, recorded as a misfire.

Link rewriting covers every https:// link in a tool result, in text and structured content, except links to your public hostname, up to 200 per result. A click goes to your own hostname, is counted, and redirects to the original URL. The redirect is signed, so it can’t be used to send people elsewhere. If a widget loads images or data from links in a tool result, those loads go through the redirect too and count as clicks. See Widgets and links.

Requests under /.well-known/ go to your origin like any other path. The middleware rewrites only the resource of your protected resource metadata (JSON up to 64 KB) and the resource_metadata URL in WWW-Authenticate, and only when they name your origin’s scheme, host and port. Agents check that resource equals the URL they connected to. See Accept the public audience.

Three domain verification files are answered by the middleware when you saved them in Distribute: /.well-known/openai-apps-challenge, /.well-known/google-connected-apps and /.well-known/mcp-registry-auth. Without a saved file these paths go to your origin.

Cloudflare answers certificate validation requests (/.well-known/acme-challenge/) itself.

Paths under /_mcptower/ on your public hostname belong to the middleware (link redirects and widget pixels) and never reach your origin.

MCP Tower publishes your server’s configuration to the middleware whenever it changes: a new origin URL, an override, a prompt, a tracking switch. The change reaches every Cloudflare location within seconds. Agents that cached a list see it the next time they load it, which for most hosts is a new conversation.

Besides agents, three kinds of requests from MCP Tower reach your origin. Once your server has an origin secret (from the Connect step on), all of them carry it.

SourcePathIdentified byWhen
Uptime checksThrough the middlewareUser-Agent: MCP-Tower-Uptime/1Every minute; see Uptime
ScansFrom MCP Tower’s applicationUser-Agent: MCP-Tower-Scanner/1During setup, daily, and when you scan again; see Scans and change alerts
Inspect callsThrough the middlewareX-MCP-Tower-Internal: 1When a member runs a tool or prompt in Inspect

Uptime checks list your tools the way an agent would, with a 15-second deadline. Scans come from MCP Tower’s application at 98.87.134.168, not from Cloudflare, so don’t limit your origin to Cloudflare’s IP ranges: check the origin secret instead. Every MCP Tower User-Agent ends with (+https://mcptower.com/docs/bot); see MCP Tower’s bot. None of these requests count as tool calls in Measure or toward your quota.