SPB Git

Repository Public

custom-mcp-tunneling.md 3.1 KB 75 lines markdown

1<!-- source: https://docs.x.ai/grok/connectors/custom-mcp-tunneling (from https://docs.x.ai/llms-full.txt, retrieved 2026-09-19T05:28:55Z) -->2#### Connectors34# Custom MCP Server Tunneling56When you add a [custom MCP connector](/grok/connectors#custom-mcp-connectors), Grok's servers need to reach your MCP server over the public internet. Servers running on `localhost` or a private network address (such as `127.0.0.1`, `10.x.x.x`, `172.16.x.x`, or `192.168.x.x`) are not directly reachable, and Grok will reject these URLs.78A **tunneling service** solves this by exposing your local server through a public URL that Grok can connect to.910## How tunneling works1112A tunnel creates a secure, temporary public URL that forwards traffic to a port on your machine. When Grok calls your MCP server, the request travels through the tunnel provider's infrastructure and arrives at your local process as if it were a local request.1314```text15Grok ──► https://your-tunnel.example.com ──► tunnel provider ──► localhost:300116```1718Your MCP server code requires no changes; only the URL you provide to Grok differs.1920## Setting up a tunnel2122Several tunneling services work well with MCP servers. Below are two popular options.2324### ngrok2526[ngrok](https://ngrok.com) provides stable URLs and a dashboard for inspecting traffic. ngrok is a third-party service and is not affiliated with xAI or Grok.27281. Install ngrok and authenticate:2930```bash customLanguage="bash"31# macOS32brew install ngrok3334# Windows35winget install ngrok -s msstore3637# Authenticate (free account required)38ngrok config add-authtoken YOUR_AUTH_TOKEN39```40412. Start a tunnel pointing to your MCP server's port:4243```bash customLanguage="bash"44ngrok http 300145```46473. Copy the `Forwarding` URL from the output (e.g., `https://a1b2c3d4.ngrok-free.app`) and use it as the server URL in Grok's custom connector dialog.4849### Cloudflare Tunnel5051[Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/) is a free alternative that does not require account signup for quick tunnels.5253```bash customLanguage="bash"54# macOS55brew install cloudflared5657# Windows58winget install --id Cloudflare.cloudflared5960# Start a quick tunnel61cloudflared tunnel --url http://localhost:300162```6364Copy the generated `*.trycloudflare.com` URL and use it as the server URL in Grok.6566> [!CAUTION]67>68> &#x20;Cloudflare quick tunnels do not support Server-Sent Events (SSE). If your MCP server uses the SSE transport, use ngrok instead. Servers using the newer Streamable HTTP transport work fine with Cloudflare.6970## Things to keep in mind7172* **Tunnels are temporary.** Most free-tier tunnel URLs change each time you restart the tunnel. If you restart, you will need to remove the old connector in Grok and add a new one with the updated URL.73* **Keep your MCP server running.** Grok calls your server on demand during conversations. If the tunnel or the local server is stopped, tool calls will fail.74* **Authentication still applies.** If your MCP server requires OAuth or API keys, you will still complete that flow in Grok after providing the tunnel URL. The tunnel only handles network reachability.75
Files main
Menu

Theme