CONNECTORS / tunnel-local-mcp-server-for-grok-connectors

Connectors

Tunnel a local MCP server for Grok connectors

Tunnel a local MCP server for Grok connectors

Grok’s servers must reach your MCP URL over the public internet. localhost, 127.0.0.1, and private ranges (10.x, 172.16.x, 192.168.x) are rejected. A tunnel gives you a public HTTPS URL that forwards to the port on your machine. Official guide: Custom MCP Server Tunneling.

Your MCP code stays unchanged — only the URL you paste into Grok changes.

Grok → https://your-tunnel.example.com → tunnel provider → localhost:3001

Consumer path: Add a custom MCP connector on grok.com. Business/Enterprise admins still provision first: Provision connectors as a team admin.

ngrok

ngrok is a third-party service (not affiliated with xAI). Free accounts need an auth token.

# macOS
brew install ngrok

# Windows
winget install ngrok -s msstore

ngrok config add-authtoken YOUR_AUTH_TOKEN
ngrok http 3001

Copy the Forwarding URL (for example https://a1b2c3d4.ngrok-free.app) into Grok’s custom connector dialog as the server URL.

Cloudflare Tunnel (quick)

No account required for a quick tunnel:

# macOS
brew install cloudflared

# Windows
winget install --id Cloudflare.cloudflared

cloudflared tunnel --url http://localhost:3001

Copy the generated *.trycloudflare.com URL into the connector dialog.

SSE caveat: Cloudflare quick tunnels do not support Server-Sent Events. If your MCP server uses SSE transport, use ngrok. Streamable HTTP works with Cloudflare.

After the tunnel is up

  1. Keep both the MCP process and the tunnel running while you chat — Grok calls the server on demand.
  2. Paste the public URL into New Connector → Custom on grok.com/connectors (or Other on the Business console after admin provisioning).
  3. Finish OAuth or API-key auth if the server requires it. The tunnel only solves reachability.

Pitfalls

  • Free-tier tunnel URLs usually change on restart. Remove the old connector and add a new one with the updated URL.
  • Stopping the tunnel or the local process makes tool calls fail mid-conversation.
  • Do not paste http://localhost:… into Grok — it will be rejected before auth starts.