Skip to content

Tunnels & Relay

mcpr includes a built-in tunnel that gives your local MCP server a public HTTPS URL. Tunnels are a development convenience — they let remote AI clients (ChatGPT, Claude) reach your local machine without a public IP, port forwarding, or ngrok.

For production, use direct HTTP mode instead.

ScenarioWhy you need a tunnel
Local developmentYour laptop doesn’t have a public IP, but ChatGPT needs one
NAT / firewallCan’t open inbound ports on your network
Quick sharingGive a colleague or AI client a URL that works immediately
Testing with remote AI clientsChatGPT and Claude need a public HTTPS endpoint

You do not need a tunnel for local clients like Claude Desktop, VS Code, or Cursor — use --port 3000 instead.

Terminal window
mcpr --mcp http://localhost:9000
# → Tunnel: https://abc123.tunnel.mcpr.app

Use the tunnel URL in ChatGPT, Claude, or any MCP client. mcpr routes all traffic through the proxy core — routing, structured events, and CSP handling all work the same as direct HTTP mode.

mcpr opens a persistent WebSocket connection to a relay server. When an AI client sends a request to your tunnel URL, the relay forwards it through the WebSocket to mcpr on your machine. mcpr processes it and sends the response back.

AI Client → relay (tunnel.mcpr.app) → WebSocket → mcpr (your machine) → MCP Server

The AI client never connects to your machine directly. All traffic flows through the relay.

On first run, mcpr generates a tunnel token and saves it to mcpr.toml. Your URL stays the same across restarts:

# mcpr.toml (auto-generated on first run)
mcp = "http://localhost:9000"
tunnel_token = "tok_abc123..."

Configure your AI client once, keep developing. The URL doesn’t change unless you delete the token.

mcpr Cloud adds managed tunnel infrastructure on top:

  • Persistent URLs — your URL survives across machines, not just restarts
  • Custom subdomains — claim yourapp.tunnel.mcpr.app instead of a random hash
  • Token management — rotate tokens, manage subdomains from a dashboard

See Custom Subdomains and Tunnel Tokens.

Run your own relay server instead of using tunnel.mcpr.app.

Terminal window
docker run -d \
-p 8080:8080 \
ghcr.io/cptrodgers/mcpr:latest \
--relay --port 8080 --relay-domain tunnel.yourdomain.com

With auth provider (production):

Terminal window
docker run -d \
-p 8080:8080 \
-e MCPR_AUTH_PROVIDER=https://api.yourdomain.com \
-e MCPR_AUTH_PROVIDER_SECRET=your-secret \
ghcr.io/cptrodgers/mcpr:latest \
--relay --port 8080 --relay-domain tunnel.yourdomain.com

With a config file:

Terminal window
docker run -d \
-p 8080:8080 \
-v /path/to/mcpr.toml:/app/mcpr.toml \
ghcr.io/cptrodgers/mcpr:latest \
--relay --port 8080
Terminal window
mcpr --relay --relay-domain tunnel.yourdomain.com --port 8080

Then point your proxy at it:

Terminal window
mcpr --mcp http://localhost:9000 --relay-url https://tunnel.yourdomain.com
  • A VPS or server with a public IP
  • Wildcard DNS (*.tunnel.yourdomain.com → your server)
  • TLS termination (Nginx, Caddy, or built-in)

The relay supports three auth modes:

ModeConfigWhen to use
OpenNo tokens, no auth_providerLocal dev, testing
Static tokens[[relay.tokens]] entriesSmall team, simple setup
Auth provider[relay].auth_provider URLDynamic token management at scale

See the relay deployment guide and auth provider spec for full setup instructions.