How to Connect a Local MCP Server to ChatGPT (and Claude)
ChatGPT can't reach an MCP server on localhost. Four ways to fix it, compared: OpenAI's tunnel, Anthropic's tunnels, ngrok or Cloudflare, and a hosted relay.
By Sandeep Kumar Saini, founder of Shellway · Published 28 Nov 2026 · Updated 28 Nov 2026
Short answer: ChatGPT cannot use an MCP server at localhost, because ChatGPT calls connectors from OpenAI's servers, not from your computer. You need a bridge that your machine opens outward: OpenAI's Secure MCP Tunnel, a tunnel such as ngrok or Cloudflare Tunnel with your own sign-in check, or a hosted relay like Shellway, which brings its own file and terminal tools so you write no server at all.
Shellway is our product. Facts about the other options come from their own documentation, linked under Sources, checked 28 November 2026. Tunnel products are new and change often.
Why ChatGPT rejects localhost
When you add a custom MCP server in ChatGPT, the request to that URL is made from OpenAI's cloud. From there, http://localhost:3001/mcp means OpenAI's own machine, not yours, so the connector fails; developers on OpenAI's forum report an "Unsafe URL" error when they try. Claude works the same way: Anthropic's help article says custom connectors are reached from Anthropic's cloud, and servers on a private network, behind a VPN or a firewall will not connect. The fix is never "allow localhost"; it is to give the cloud a safe way back to your machine.
Option 1: OpenAI Secure MCP Tunnel
OpenAI's own answer. You run a small program, tunnel-client, inside the network that can reach your server. It opens an outgoing HTTPS connection to OpenAI, picks up queued MCP requests, passes them to your server and returns the answers, so no inbound port is opened. It supports both stdio servers (a local command) and HTTP servers (a URL). Setup from OpenAI's guide:
export CONTROL_PLANE_API_KEY="sk-..."
tunnel-client init --sample sample_mcp_stdio_local --profile local-stdio \
--tunnel-id tunnel_<id> --mcp-command "python /path/to/server.py"
tunnel-client doctor --profile local-stdio --explain
tunnel-client run --profile local-stdio
You need a tunnel ID from the OpenAI Platform settings, a runtime API key and the right tunnel roles. In ChatGPT you then add a custom MCP server with the connection set to Tunnel; the Responses API and Codex can use it too. Limits to know: OpenAI says it does not support public plugin submission or distribution, the guide lists default limits such as 600 requests a minute and a 120-second request deadline, and plans and price are not stated.
Option 2: Anthropic MCP tunnels (for the Claude API)
Anthropic offers MCP tunnels as a research preview, "as-is", with access by request. Two pieces run in your network: Cloudflare's open-source cloudflared connector and Anthropic's proxy, deployed with a Helm chart on Kubernetes or Docker Compose on a VM. They work with the Messages API and Managed Agents. Important: Anthropic says tunnels created in the Console are not available as connectors in claude.ai, and you still set up sign-in (OAuth or a token) on each MCP server yourself. This fits teams building on the Claude API, not someone who wants their own PC in the Claude app.
Option 3: ngrok or Cloudflare Tunnel in front of your server
A tunnel gives your local server a public HTTPS address. Two things to know first:
- stdio servers do not work directly. The cloud cannot start a process on your machine; run the server in HTTP mode (Streamable HTTP) or put a stdio-to-HTTP bridge in front of it.
- You must add the access check. A public URL can be called by anyone who finds it.
With ngrok (a free account works; the dev address stays the same across restarts):
ngrok config add-authtoken <YOUR_AUTHTOKEN>
ngrok http 3001 --traffic-policy-file policy.yml
ngrok's guide explains the catch for ChatGPT: a bearer-token header works for Claude Code and Cursor, but ChatGPT and claude.ai cannot send one. For those it suggests a long secret path (a shared secret, not an identity), limiting traffic to the provider's network, or proper OAuth in your server. Cloudflare's Quick Tunnel (cloudflared tunnel --url http://localhost:8080) needs no account, but Cloudflare says it is for testing only, its address changes every time, and it does not support Server-Sent Events; for anything lasting, create a named Cloudflare Tunnel.
Option 4: a hosted relay (no MCP server to write)
If what you actually want is for ChatGPT or Claude to work with files and the terminal on your computer, you may not need your own MCP server. Shellway runs a small app on Windows, Mac or Linux that connects outward to Shellway's relay; ChatGPT and Claude connect to https://mcp.getshellway.com/mcp with a normal sign-in. It comes with file, search, terminal and process tools (tools page). Trade-offs to weigh: a third party sits in the path (it passes requests and does not store file contents or command output), the agent is not open-source licensed, and you cannot add your own custom tools to it.
The four options compared
| OpenAI Secure MCP Tunnel | Anthropic MCP tunnels | ngrok / Cloudflare + your server | Shellway (relay) | |
|---|---|---|---|---|
| Made by the AI vendor | Yes | Yes | No | No |
| Stage | Documented, stage not labelled | Research preview, access by request | Generally available products | Live product |
| No inbound ports | Yes | Yes | Yes, but you publish a public URL | Yes |
| Your own MCP server | Required (stdio or HTTP) | Required | Required, HTTP only | Not needed: tools included |
| Works in ChatGPT | Yes, private connectors; not for public plugins | No | Yes, custom connector | Yes |
| Works in claude.ai | No | No (Claude API only) | Yes, custom connector | Yes |
| Setup needs | Platform tunnel, API key, roles | Console, certificates, Kubernetes or Docker | Tunnel account; your own access check | Sign in, one command on the computer |
| Cost | Not stated | Not stated | Free tiers exist; check current limits | Free 50 actions a day after a 7-day trial; from $5/month |
| Open-source parts | Not stated | cloudflared | cloudflared | No (plugin files MIT) |
Which one should you use?
- You built an MCP server and want it in ChatGPT privately: OpenAI Secure MCP Tunnel.
- You build on the Claude API inside a company network: Anthropic MCP tunnels, if you get access.
- Quick test in ChatGPT, claude.ai, Claude Code or Cursor: ngrok with a secret path or OAuth; stop the tunnel when you are done.
- You want a public ChatGPT app: host the server on a real public HTTPS address; tunnels are not for that.
- You only want ChatGPT or Claude to use your PC or server: a hosted relay like Shellway; see connect ChatGPT to your computer.
Security checklist before you expose a local MCP server
- Require a real access check: OAuth, or at least a long secret path. Never an open URL.
- Run the server as a normal user with access only to what it needs, never as root or administrator.
- Keep write and delete tools off until you trust the setup; start read-only.
- Do not leave a public tunnel running when you are not using it.
- Watch for prompt injection: text in a web page, email or file can try to give the AI instructions. Read what the AI plans before you approve it.
- Log every call so you can see what happened. More: safety rules for AI on your computer and how Shellway handles security.
Common questions
Can ChatGPT connect to localhost?
No. ChatGPT calls MCP servers from OpenAI's cloud, so localhost points at OpenAI's machine. Use a tunnel or a relay that your computer opens outward.
What is OpenAI Secure MCP Tunnel?
A program, tunnel-client, that you run next to your MCP server. It connects outward to OpenAI and passes requests from ChatGPT, the Responses API or Codex to your server, without opening a port.
Can I use a tunnel for a public ChatGPT app?
Not OpenAI's tunnel: OpenAI says it does not support public plugin submission. A public app needs a publicly reachable HTTPS endpoint.
Does this work with Claude.ai custom connectors?
claude.ai needs a server it can reach from the public internet; sign-in can be OAuth or none, and Free plans can add one custom connector. ngrok, Cloudflare Tunnel or a relay like Shellway work; Anthropic's own MCP tunnels do not appear in claude.ai. Setup for Claude: Claude remote MCP setup.
Is ngrok safe for MCP?
It can be, if you add an access check and limit what the server can do. Without one, anyone who finds the URL can call your tools.
Do I need a VPN?
No. All four options use an outgoing connection from your side. A VPN would actually stop ChatGPT or Claude from reaching a server, because they connect from the public internet.
New to MCP? Start with what an MCP server is and the ChatGPT MCP server setup guide.
Sources
Checked on 28 November 2026. These products change often; tell us via contact if something here is out of date.