Skip to main content

Willow Tunnels

A Willow Tunnel turns the hybrid deployment inside out. Instead of you publishing run on a hostname that Willow connects to, your run opens long-lived, outbound-only WebSockets to Willow and keeps them open. MCP clients keep using your organization's normal MCP URL, https://<org>.withwillow.ai/mcp. Whenever one of them calls a tool on an MCP server that runs on the tunnel gateway, Willow relays that call down the tunnel to your run, which executes it inside your network.

There is no third-party service, agent or account involved. The connector is built into run, the tunnel terminates on Willow's own gateway, and the only credential is the same gateway AUTH_SECRET a hybrid install already has.

Use it when any of these is true:

  • You cannot, or would rather not, publish a hostname for run, allow-list Willow's NAT IPs on an inbound firewall, or manage a TLS certificate.
  • Your cluster has no ingress controller or load balancer (air-gapped-ish environments, dev clusters, kind/k3s on a laptop).
  • You want the whole of Phase 1 of the hybrid guide to go away.
Who this is for

Tunnels are a SaaS feature managed from Settings > Gateway Settings > Add Gateway > Willow Tunnel. They are not relevant to a full on-prem deployment, where Willow already runs inside your network.

Components​

ComponentWhere it runsOwned byWhat it does
Tunnel gatewayWillowWillowAn External Run Service gateway with a Tunnel badge. Willow mints its id, its run service URL (https://<org host>/mcp/tunnel/<id>) and its AUTH_SECRET; you never type a URL. Pin MCP servers to it, or make it the default gateway, like any other gateway. MCP clients never see its URL: connection instructions keep showing your organization's MCP URL.
Tunnel endpointWillow's hosted runWillowTerminates the WebSockets at wss://<org host>/mcp/tunnel/_connect, authenticates each connector by AUTH_SECRET, and relays requests for the gateway over them. Spreads requests round-robin over every attached socket and skips one that is gone. Scales horizontally; a request landing on a Willow replica that does not hold the chosen socket is handed to the one that does.
ConnectorInside your network, inside the run processYou run it; Willow issues its secretStarts automatically when run boots with a tunnel-shaped BASE_URL. Dials out over HTTPS (port 443) with two sockets by default, authenticates with AUTH_SECRET, and serves each relayed request against its own local HTTP listener. Redials any socket that drops. Never listens on an external port.
CredentialYour secret storeSharedThe gateway AUTH_SECRET. It is what the connector presents to Willow, what Willow presents to your run for service-to-service calls, and what run uses to call the SaaS db-service. One secret, shown once.

Connection model​

┌──────────────────────────────────────────────┐
│ Willow SaaS │
│ │
│ MCP clients ──▶ <org>.withwillow.ai/mcp │
│ (hosted run: auth, tool │
│ list, routing) │
│ │ tool calls for MCP │
│ │ servers on the │
│ Willow app ──┐ │ tunnel gateway │
│ db-service ──┴───────▼ │
│ hosted run: tunnel endpoint │
│ (holds the WebSockets) │
└──────────────────────────────┬───────────────┘
│ wss://<org>.withwillow.ai/mcp/tunnel/_connect
│ opened BY your run, outbound only,
│ authenticated with AUTH_SECRET
│
┌──────────────────────────────┴───────────────┐
│ Your network │
│ │
│ run (hybrid) ── executes relayed calls │
│ against 127.0.0.1:PORT │
│ │ │
│ └──▶ db-service via connect │
│ (ordinary outbound HTTPS, │
│ unchanged from hybrid) │
└──────────────────────────────────────────────┘

Three things to notice:

  1. Every connection is outbound from your side. The tunnel sockets, and run's own calls to the SaaS db-service, both leave your network over 443. Nothing is accepted from the internet.
  2. MCP clients don't change. They connect to your organization's MCP URL, https://<org>.withwillow.ai/mcp, as they would without a tunnel. One connection can mix MCP servers on Willow-hosted gateways with MCP servers on the tunnel: each tool call is routed to the gateway its MCP server is assigned to. The tunnel URL is only your run's BASE_URL.
  3. Your run still does the work. For a tool call on the tunnel gateway, your run checks the caller's token, decrypts credentials, applies guards and approvals, calls the MCP server, and writes the audit log, exactly as it does behind an ingress. The tunnel is transport, not trust.

What happens on a tool call​

  1. A client calls a tool through https://<org>.withwillow.ai/mcp. Willow's hosted run authenticates the client and finds the gateway the tool's MCP server is assigned to: its own gateway setting, or else the organization's default.
  2. If that gateway is a tunnel, the hosted run relays the call to your run's /call endpoint over the tunnel, forwarding the client's Willow access token. Calls for MCP servers on Willow-hosted gateways are served by Willow as usual.
  3. Willow picks one of the gateway's attached sockets, round-robin over every socket from every run replica you run. If the chosen socket is gone, or the Willow replica holding it is unreachable, it tries the next one. It only does that while the call provably never reached your run, so a tool never runs twice. If no connector is attached, the client gets a TUNNEL_NOT_CONNECTED tool error immediately; nothing is queued.
  4. Your run replays the request against its own listener (127.0.0.1:PORT) and runs the tool.
  5. The result comes back over the same socket. Your run has 290 seconds to answer; after that the call fails with a timeout.
  6. If the socket drops before your run answers, the call fails with a tunnel error rather than hanging. Willow does not retry it, because the tool may already have run.

tools/list is answered by Willow from the tool catalog it has stored for each MCP server, so listing tools does not depend on the tunnel. The universal URL, https://mcp.withwillow.ai/mcp, works the same way.

Willow itself reaches your run through the tunnel URL for dashboard features: tool tests, discovery, guard evaluation and health checks.

Connection lifecycle​

  • Start. The connector starts once run is already listening, so the first relayed request has somewhere to land. It runs only on a single-organization run (the chart always sets ORG from global.org) that has an AUTH_SECRET. If either is missing, run starts normally but never dials out, and logs nothing about the tunnel.
  • Keepalive. Willow pings the connector every 30 seconds and drops the connection if a ping goes unanswered for 10 seconds. The connector, in turn, reconnects if it hears nothing from Willow for 90 seconds, which catches sockets a middlebox has silently killed.
  • Several sockets per replica. Each run replica keeps two sockets open by default (TUNNEL_CONNECTIONS, 1–8). Each socket redials on its own, so while one reconnects the other keeps serving, and the two usually land on different Willow replicas.
  • Reconnects. After a drop, a socket redials with exponential backoff, from 1 second up to a 30-second ceiling, with jitter. If Willow rejects the secret (HTTP 401 or 403), it waits 60 seconds between attempts instead, so a bad secret does not flood either side's logs.
  • Willow restarts. When a Willow replica shuts down, it closes the sockets it holds and stops accepting new ones, so your connectors redial straight away and land on a replica that stays up. The other socket on each of your replicas carries traffic in the meantime.
  • Shutdown. On SIGTERM, run closes its sockets before it stops its HTTP listener, so Willow stops routing to that pod first. Requests still in flight on that pod are cut, as described in step 6 above.
  • Multiple replicas. Each run replica opens its own sockets to the same gateway, and Willow spreads requests round-robin over all of them, so each replica takes an even share. A replica that goes away drops out of the rotation as soon as its sockets close. A rolling update with two or more replicas therefore keeps the gateway reachable throughout.
  • Version reporting. On connect, the connector tells Willow its run version (from the GIT_TAG or GIT_COMMIT_SHA baked into the image) and its pod hostname. Willow records both against the connection, which tells support which build is attached without access to your cluster. You do not set these variables yourself.

Setup​

The flow mirrors hybrid Phases 2–4 with Phase 1 removed. Budget about fifteen minutes.

Step 1 — Create the tunnel gateway​

Owner: Willow org admin (needs org:edit) · Produces: the gateway URL and the AUTH_SECRET

  1. Open the admin app, Settings > Gateway Settings.
  2. Click Add Gateway and choose Willow Tunnel. There is no URL field; Willow generates one on your organization's gateway domain.
  3. Click Add Gateway. A Gateway Auth Secret dialog appears with a one-time secret and a Next steps box listing the two values your run needs: BASE_URL (the generated tunnel URL) and AUTH_SECRET. Copy both now — the secret is not shown again.
  4. The new card shows a Tunnel badge and a health badge reading Connector not attached. That is expected until Step 3.

If the dialog is gone and you lost the secret, use Rotate Secret on the card to mint a new one. The tunnel URL is always visible on the card's Run service BASE_URL: line. The card's Run: line shows the MCP URL clients use, which is your organization's normal one.

Step 2 — Create values.yaml and the secret​

Owner: Platform engineer · Needs: Step 1 · Produces: the config Helm installs

Start from the hybrid guide's Step 6 values and make three changes: turn the run ingress off, set BASE_URL to the tunnel URL, and drop the TLS block.

Replace the placeholders:

  • <ORG_SLUG> — your organization slug
  • <TUNNEL_URL> — the BASE_URL value from the Step 1 dialog, e.g. https://<ORG_SLUG>.withwillow.ai/mcp/tunnel/gw_tun_…
global:
domain:
host: "unused.invalid" # nothing is published; the chart still wants a value
org: "<ORG_SLUG>"
OPENAI_API_KEY: ""

deployments:
app:
enabled: false
connect:
enabled: false
db-service:
enabled: false
run:
enabled: true
ingress:
enabled: false # no inbound path; run dials out instead
# The gateway auth secret from Step 1. See the hybrid guide for why it
# must not live in values.yaml.
secretName: "willow-secrets"
env:
PORT: "3000"
LOG_LEVEL: "info"
# The tunnel URL from Step 1. A tunnel-shaped BASE_URL is what tells run
# to open the tunnel on start — no other flag is needed.
BASE_URL: "<TUNNEL_URL>"
DB_SERVICE_URL: "https://<ORG_SLUG>.withwillow.ai/api/on-prem-db-service"
CONNECT_URL: "https://<ORG_SLUG>.withwillow.ai"
Use the host from your tunnel URL

As in the hybrid guide, <ORG_SLUG>.withwillow.ai is an example. Willow minted the tunnel URL on your organization's Connect host, which may be region-specific (<ORG_SLUG>.eu.withwillow.ai) or a custom domain. Copy the host from the tunnel card's Run service BASE_URL: line into DB_SERVICE_URL and CONNECT_URL as well, so all three use the same host. The tunnel card itself has no Connect: line, because it is an external gateway.

Create the namespace and the secret. Keep the single quotes:

kubectl create namespace <namespace> --dry-run=client -o yaml | kubectl apply -f -
kubectl create secret generic willow-secrets \
--namespace <namespace> \
--from-literal=AUTH_SECRET='<gateway-secret-from-step-1>'

Verify the rendered BASE_URL is your tunnel URL and no Ingress is produced, before installing anything:

helm template willow willow/webrix-helm -f values.yaml \
| grep -E "BASE_URL|CONNECT_URL|DB_SERVICE_URL|kind: Ingress"

The chart normally derives BASE_URL from the ingress host. If the output still shows https://willow.unused.invalid, your chart version does not let env.BASE_URL override the derived value; upgrade the chart, or set the value through extraEnv/a secret, whichever your version supports — the goal is simply that the run container starts with BASE_URL=<TUNNEL_URL>.

Optional variables​

None of these are needed for a standard install; a tunnel-shaped BASE_URL plus AUTH_SECRET is enough.

VariablePurpose
TUNNEL_ENABLEDtrue (or 1) forces the connector on; false (or 0) forces it off and always wins. Unset, it is inferred from BASE_URL: a URL whose path is /mcp/tunnel/<id> turns it on.
TUNNEL_URLThe WebSocket endpoint to dial. Default: BASE_URL with its last path segment replaced by _connect, i.e. wss://<org host>/mcp/tunnel/_connect. Set it if you front Willow's domain with something of your own, or if you force the connector on with TUNNEL_ENABLED=true while BASE_URL is not the tunnel URL. In that case the default would point at your own host, not Willow. https:// values are converted to wss://.
TUNNEL_CONNECTIONSHow many sockets each run replica keeps open to Willow, from 1 to 8. Default: 2. More than one keeps the replica reachable while a socket reconnects.
HTTPS_PROXY / HTTP_PROXY / NO_PROXYUpper- or lower-case, honoured for the tunnel connection as for every other outbound call run makes. A NO_PROXY entry exempts the Willow host when it matches exactly, matches as a domain suffix (withwillow.ai or .withwillow.ai), or is *.

GIT_TAG and GIT_COMMIT_SHA are set by the image build and reported to Willow on connect (see Connection lifecycle). Do not override them.

Step 3 — Install the chart​

Identical to the hybrid guide's Step 7:

helm repo add willow https://charts.withwillow.ai && helm repo update
helm upgrade --install willow willow/webrix-helm \
--namespace <namespace> \
-f values.yaml \
--wait --timeout 5m

Within a few seconds of the pod becoming ready the log shows the connector attach, once per socket:

[tunnel] connector starting; dialing Willow connections=2
[tunnel] connected to Willow; this run is now reachable at the tunnel URL socket=0 gatewayId=gw_tun_… publicUrl=https://<ORG_SLUG>.withwillow.ai/mcp/tunnel/gw_tun_…
[tunnel] connected to Willow; this run is now reachable at the tunnel URL socket=1 gatewayId=gw_tun_… publicUrl=https://<ORG_SLUG>.withwillow.ai/mcp/tunnel/gw_tun_…

Step 4 — Verify end to end​

  1. Gateway card. Back in Gateway Settings, click the re-check arrow on the tunnel card. It should read Healthy. The check asks Willow's tunnel endpoint whether a connector is attached, then calls /healthz and /healthz/validate through the tunnel, so a green badge proves the full path including AUTH_SECRET.

  2. The path into your run. From any machine:

    curl -sS https://<ORG_SLUG>.withwillow.ai/mcp/tunnel/<id>/.well-known/oauth-protected-resource

    An answer from your run proves the tunnel delivers requests. The resource field should be your tunnel URL (possibly with a trailing slash — run normalises it). This URL is only for checks like this one; don't give it to MCP clients.

  3. Assign MCP servers. Make the tunnel the Default Gateway, or pick it in an MCP server's gateway setting. If the tunnel is your only gateway, Willow already made it the default when you created it.

  4. An MCP client. Connect Cursor or Claude to your organization's MCP URL, https://<ORG_SLUG>.withwillow.ai/mcp, as shown in the dashboard's connection instructions, and sign in. Calls to tools on the tunnel's MCP servers now execute inside your cluster; the run logs and the audit log show them.

In Monitor > Logs, a tunnel call has a cable icon in the Gateway column. Its call flow draws the extra hop: Willow gateway (the host the client called), then a Willow Tunnel edge, then your Run service. The Device column shows the user's own IP address, not Willow's or the tunnel's. If Willow couldn't deliver the call (for example, no connector was connected), Willow writes the row itself and the edge reads not delivered.

Security model​

  • Zero inbound. Nothing in your network listens for Willow or for MCP clients. Remove the tunnel gateway in Willow, or stop run, and the path is gone.
  • One secret, mutual. The connector proves itself to Willow with AUTH_SECRET, and Willow proves itself to run on service calls with the same secret. Rotate it from the card like any gateway secret and roll the Kubernetes secret; the connector reconnects with the new value on restart.
  • The caller's own token. A relayed tool call carries the client's Willow access token (OAuth, or a Willow API token), and your run validates it before doing anything. Willow never sends its own service secret on these calls, and it doesn't relay older user-access-key credentials, which aren't scoped to one organization. Clients that still use them get a TUNNEL_CREDENTIAL_UNSUPPORTED error and need to sign in again with OAuth.
  • Scoped per gateway. A secret only attaches to its own gateway id. Willow also checks that the host a connector dials matches the organization that owns the gateway, so a secret cannot be replayed against another tenant's hostname.
  • Transport, not trust. Willow does not decrypt, cache or inspect relayed bodies beyond framing them; it forwards headers with hop-by-hop ones removed and X-Forwarded-For/Proto/Host set. Credential decryption, policies, guards, approvals and the audit log all execute on your run.
  • No tunnel-specific allow-listing. Nothing connects into your network, so the hybrid guide's NAT IP table and firewall steps do not apply. The only egress your run needs is HTTPS to your Connect host.
  • Backpressure and limits. Bodies are split into 64 KB frames so one large tool result cannot monopolise the socket. Either side pauses its source once 4 MB is queued on the WebSocket. A single client that falls more than 16 MB behind has its stream dropped rather than buffered further, so one slow client cannot stall every other session on the tunnel. Response headers must arrive within 290 seconds, just under the 5-minute idle limit on Willow's load balancer.

Switching an existing hybrid install to a tunnel​

You can run both side by side. Add a Willow Tunnel gateway, deploy a second run release (or point the existing one at the tunnel BASE_URL with its ingress disabled), confirm the tunnel card is Healthy, then Set as Default on the tunnel card and remove the old External Run Service gateway and its ingress/DNS/certificate at your leisure. MCP clients configured with the old gateway's own URL need to switch to your organization's MCP URL, which the dashboard's connection instructions now show.

Error responses​

These are the responses Willow itself returns on the tunnel URL. Anything else, including 401, comes from your run and means the tunnel delivered the request. MCP clients see the same conditions as tool errors whose code is the upper-cased error, for example TUNNEL_NOT_CONNECTED.

StatuserrorMeaning
503tunnel_not_connectedNo connector is attached to this gateway, or none of its sockets could be reached. Willow tries every attached socket before giving up.
502tunnel_disconnectedThe tunnel dropped before your run sent response headers.
502tunnel_upstream_errorThe connector is attached but your run's own listener did not answer, or the stream failed on your side. The message field carries the reason.
502tunnel_empty_response / tunnel_bad_responseYour run ended the stream without a valid response. Usually a pod restarting mid-request.
504tunnel_response_timeoutYour run did not send response headers within 290 seconds.

Troubleshooting​

SymptomLikely causeFix
Card reads Connector not attached; run log shows nothing about the tunnelBASE_URL is not the tunnel URL, TUNNEL_ENABLED=false is set, or AUTH_SECRET is empty in the pod. With no secret the connector does not start at all.kubectl exec into the pod and env | grep -E 'BASE_URL|TUNNEL|^ORG=', and confirm AUTH_SECRET is set (do not print it). Fix values.yaml or willow-secrets, re-run Helm.
run log: Willow refused the tunnel handshake with HTTP 400 Unsupported tunnel protocolThe connector's run image speaks a different tunnel protocol version than WillowUpgrade the run image to a current chart release.
run log: local run did not answer; clients get 502 tunnel_upstream_errorThe connector replays requests to 127.0.0.1:PORT, and nothing is listening thereMake sure PORT in the pod's environment is the port run actually listens on (the chart uses 3000).
run log: Willow rejected the connector's AUTH_SECRET (HTTP 401)AUTH_SECRET does not match any tunnel gateway — wrong value, rotated since, or the gateway was deleted and recreatedCompare the secret with the Step 1 value; Rotate Secret if unsure and roll willow-secrets.
run log: Willow rejected the connector's AUTH_SECRET (HTTP 403)The secret belongs to a plain External Run Service gateway, or the host in BASE_URL is another organization'sUse the secret from a Willow Tunnel card, and make sure the tunnel URL host is your own Connect host.
run log: connection errors with ECONNREFUSED/ENOTFOUND/proxy messagesEgress to the Connect host on 443 is blocked, or a corporate proxy is requiredAllow HTTPS egress to the Connect host; set HTTPS_PROXY/NO_PROXY on the run deployment.
Connector attaches, card says reachable but Auth issueThe pod has a different AUTH_SECRET than Willow stored (typically a stale Kubernetes secret after a rotate)Update willow-secrets, restart the deployment.
Clients get TUNNEL_NOT_CONNECTED intermittently; run log shows disconnected from Willow; reconnecting or no traffic from Willow for 90sEvery socket is flapping at once. Either the pod is restarting, or an egress firewall or proxy is killing idle sockets.Check pod restarts and events. Willow pings every 30 seconds, so any egress idle timeout on the path must be comfortably above 30 seconds. Keep TUNNEL_CONNECTIONS at 2 or more, and run two or more replicas.
Clients get TUNNEL_DISCONNECTED, or a stream ends abruptlyThe socket carrying the call dropped while it was running, typically a pod restart. Willow does not retry it, because the tool may already have run.Expected now and then during rollouts. New calls go to the sockets that are still attached; the client can retry the call.
A tool call fails with TUNNEL_CREDENTIAL_UNSUPPORTEDThe client authenticates with an older user access key, which Willow doesn't relayReconnect the client through the dashboard's connection instructions so it signs in with OAuth.
A background agent's tool call fails with TUNNEL_AGENT_GATEWAY_MISMATCHThe agent is set to a Willow-hosted gateway but uses an MCP server on the tunnelSet the agent's gateway to the tunnel, then sync it so its platform gets the new endpoint.
Clients get 504 tunnel_response_timeoutA request took more than 290 seconds to produce response headersFind the slow tool in your run logs. Long operations should stream their progress (SSE) so headers go out immediately.
Health card reports an auth or OAuth resource problemBASE_URL differs from the tunnel URL (trailing path, wrong host)BASE_URL must be exactly the card's Run service BASE_URL: value, with no suffix.
An MCP client lists the tunnel's tools but a new tool is missingWillow answers tools/list from its stored catalog, which refreshes when the MCP server is discoveredRefresh the MCP server's tools from the dashboard; discovery runs through the tunnel.

Limits​

  • One tunnel gateway serves one hybrid run deployment (any number of replicas). To tunnel a second, independent deployment, create a second tunnel gateway.
  • MCP clients reach tunnel MCP servers with OAuth or Willow API tokens. Older user-access-key credentials are not relayed.
  • Background agents aren't relayed per call. An agent that uses MCP servers on the tunnel must be set to the tunnel gateway itself; its endpoint is then served by your run through the tunnel.
  • The tunnel carries HTTP (including SSE). It does not carry raw TCP, so it cannot expose a database or an arbitrary internal MCP server on its own — point those at your run as you would in any hybrid install, and run reaches them from inside your network.
  • Request bodies and responses are streamed, but every request must produce response headers within 290 seconds. Very long-running operations should use the MCP streaming patterns they already use behind an ingress.