{"slug": "exposing-an-mcp-server-to-the-internet-tunneling-guide-for-claude-desktop-and", "title": "Exposing an MCP server to the internet — tunneling guide for Claude Desktop and Cursor", "summary": "A developer detailed a method for exposing Model Context Protocol (MCP) servers to the internet using tunnels, enabling hosted clients like Claude Desktop and Cursor to connect. The guide emphasizes using permanent subdomains to avoid breaking configs, configuring client files, and securing credentials by using scoped, short-lived keys instead of master tokens. It also recommends edge authentication for public endpoints.", "body_md": "MCP servers usually run on your localhost — which means hosted\n\nClaude, Cursor on another machine, or a teammate can't reach them.\n\nThe fix is a tunnel, but the details matter: which URL survives\n\nrestarts, how the config files actually look, and how to avoid\n\nhanding your AI tooling a credential it can burn down your account\n\nwith.\n\n```\n This is the full walkthrough.\n\n ## Why your MCP server is unreachable\n\n The Model Context Protocol server you just wrote listens on a\n```\n\nlocal port. That works beautifully when the client is on the same\n\nmachine. The moment the client is hosted Claude, a colleague's\n\nCursor, or anything off-box, localhost becomes a wall: NATs,\n\nfirewalls, and the simple fact that `localhost:8080`\n\nmeans\n\nsomething different on every machine.\n\n```\n A tunnel solves it by running an agent on your machine that\n```\n\nholds a persistent outbound connection to a public edge. Traffic\n\nto your public URL flows down that connection to your local port.\n\n```\nStep 1: Pick a URL that survives restarts\n\n This is the detail most guides skip, and the one that bites\n```\n\nfirst. MCP client configs hardcode the server URL. If your tunnel\n\nhands you a new random address on every restart, your config\n\nbreaks silently every morning.\n\n```\n Use a named subdomain so the address is permanent:\n``` bash\n mytunnel http 8080 --subdomain my-mcp\n # ✓ Tunnel active: https://my-mcp.21tunnel.com → 127.0.0.1:8080\n```\n\nThat URL is yours across restarts and reboots — paste it into\n\nconfigs once and stop thinking about it.\n\n```\n   Step 2: Wire up Claude Desktop\n\n   Edit claude_desktop_config.json:\n\n   ``` json\n     {\n       \"mcpServers\": {\n         \"my-server\": {\n           \"url\": \"https://my-mcp.21tunnel.com/sse\"\n         }\n       }\n     }\n```\n\nRestart Claude Desktop and the hosted client now talks to the MCP\n\nserver on your machine, through the tunnel.\n\nStep 3: Wire up Cursor\n\nSame shape in .cursor/mcp.json:\n\n```\n     {\n       \"mcpServers\": {\n         \"my-server\": {\n           \"url\": \"https://my-mcp.21tunnel.com/sse\"\n         }\n       }\n     }\n```\n\nNow Cursor on any machine — yours, a teammate's, a CI box — can\n\nreach the same server.\n\nStep 4: Don't hand the agent your master token\n\nIf an AI agent is the one opening tunnels, pause here. The default\n\nis exporting your tunnel service's account token into the agent's\n\nenvironment. That token can typically open unlimited tunnels,\n\nnever expires, and shows up in transcripts and logs.\n\nThe safer pattern: a master key that cannot open tunnels itself,\n\nwhich the agent uses to mint its own scoped, short-lived child key\n\nper project:\n\n```\n     eval \"$(mytunnel eval mint --project mcp --ttl 4h --output-env)\"\n     mytunnel http 8080 --subdomain my-mcp\n```\n\nThe agent works autonomously, the credential dies on schedule, and\n\none click cascade-revokes everything it ever created.\n\nStep 5: Gate it if it matters\n\nA public MCP endpoint is a public door. For anything beyond a\n\nquick test, enable edge auth so the URL only responds to signed-in\n\nteammates or an allowlisted domain. One toggle in the dashboard,\n\nno code changes.\n\nThat's the whole setup: permanent URL, two config files, scoped\n\ncredentials, access control. The full guide with more config\n\nvariants: [exposing an MCP server to the internet](https://21tunnel.com/blog/mcp-server-public-url-tunneling-guide/)", "url": "https://wpnews.pro/news/exposing-an-mcp-server-to-the-internet-tunneling-guide-for-claude-desktop-and", "canonical_source": "https://dev.to/gokulnh/exposing-an-mcp-server-to-the-internet-tunneling-guide-for-claude-desktop-and-cursor-3ehb", "published_at": "2026-08-10 11:02:22+00:00", "updated_at": "2026-08-10 11:18:35.955800+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-agents", "ai-infrastructure"], "entities": ["Claude Desktop", "Cursor", "MCP", "21tunnel"], "alternates": {"html": "https://wpnews.pro/news/exposing-an-mcp-server-to-the-internet-tunneling-guide-for-claude-desktop-and", "markdown": "https://wpnews.pro/news/exposing-an-mcp-server-to-the-internet-tunneling-guide-for-claude-desktop-and.md", "text": "https://wpnews.pro/news/exposing-an-mcp-server-to-the-internet-tunneling-guide-for-claude-desktop-and.txt", "jsonld": "https://wpnews.pro/news/exposing-an-mcp-server-to-the-internet-tunneling-guide-for-claude-desktop-and.jsonld"}}