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.
The request path
Section titled “The request path”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- The agent connects to your public MCP URL. Your
CNAMEsends the hostname to MCP Tower, and the request runs on Cloudflare’s edge. - The middleware looks up the hostname. An unknown hostname, or a server that is turned off,
answers
404 Not found. - 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.
- 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.
What your origin receives
Section titled “What your origin receives”| Header | Value |
|---|---|
Host | Your origin’s host |
X-Forwarded-Host | The public hostname, if your server builds public URLs |
X-Forwarded-Proto | https |
X-Forwarded-For | The 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-Secret | Your server’s origin secret, on every request |
X-MCP-Tower-Internal: 1 | Only 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.
Links to your origin host
Section titled “Links to your origin host”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.
Recording never blocks the request
Section titled “Recording never blocks the request”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.
Latency and message size limits
Section titled “Latency and message size limits”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.
Hostnames and certificates
Section titled “Hostnames and certificates”- Your public hostname must be a subdomain (
mcp.example.com). A domain’s apex can’t be aCNAME. - 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
CNAMEis in place: it validates the certificate over HTTP and answers the validation URLs itself. The certificate needs noTXTrecord. - Before MCP Tower creates a hostname, your organization proves it controls the domain with a
TXTrecord,mcp-tower-verification=<token>, on the domain itself (example.comformcp.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 secondCNAME,_acme-challenge.<hostname>, which Cloudflare also uses for every renewal. - Your origin must serve HTTPS with a valid certificate.
What the middleware changes
Section titled “What the middleware changes”Most traffic passes through byte for byte. The middleware edits only these messages, and only when the feature is in use for your server:
| What | Change | Turned on by |
|---|---|---|
tools/list, prompts/list, prompts/get, resources/list, resources/templates/list | Titles and descriptions you overrode | Overrides |
prompts/list, prompts/get | MCP Tower prompts listed on the last page and answered by the middleware | MCP Tower prompts |
resources/list, resources/read | MCP Tower resources listed and answered by the middleware; resource texts you replaced | Inspect |
initialize, server/discover | Declares prompts or resources when your server declares none and MCP Tower adds some | MCP Tower prompts and resources |
tools/list | Adds the _track_event tool on the last page, for widgets to report events | Track widget interactions |
resources/read of HTML widgets | Adds the tracker script, and two invisible images for load pixels | Track widget interactions, Widget load pixels |
tools/call results | Rewrites https:// links to https://<your hostname>/_mcptower/goto/…, which redirect to the original | Track links |
/.well-known/oauth-protected-resource and WWW-Authenticate | resource and resource_metadata that name your origin host now name the public hostname | Always |
Two more additions, to _meta:
- While any recording switch is on, every
tools/callresult gets_meta["mcptower/analytics"]with arender_id, which joins the call to its widget’s events and link clicks. Your other_metakeys are kept. - With Widget load pixels on, your public hostname is added to the widget’s allowed image
domains (
_meta.ui.csp.resourceDomains, andopenai/widgetCSPwhen 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).
_track_event
Section titled “_track_event”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.
.well-known paths
Section titled “.well-known paths”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.
Reserved paths
Section titled “Reserved paths”Paths under /_mcptower/ on your public hostname belong to the middleware (link redirects and
widget pixels) and never reach your origin.
When changes take effect
Section titled “When changes take effect”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.
Other traffic to your origin
Section titled “Other traffic to your origin”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.
| Source | Path | Identified by | When |
|---|---|---|---|
| Uptime checks | Through the middleware | User-Agent: MCP-Tower-Uptime/1 | Every minute; see Uptime |
| Scans | From MCP Tower’s application | User-Agent: MCP-Tower-Scanner/1 | During setup, daily, and when you scan again; see Scans and change alerts |
| Inspect calls | Through the middleware | X-MCP-Tower-Internal: 1 | When 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.