Repository navigation
Reach iMCP from cloud apps: Tailscale Funnel and Cloudflare Tunnel with OAuth 2.1 - #376
Closed
oliverames wants to merge 19 commits into
Closed
oliverames wants to merge 19 commits into
oliverames wants to merge 19 commits into
Conversation
Clients on another device in the owner's tailnet can now use iMCP while the Mac keeps the data, permissions, and tool settings. iMCP listens on the Mac's tailnet address, accepts only untagged devices that belong to the Mac's Tailscale user, and requires a named access token on every request. Settings creates, edits, re-rolls, and deletes tokens, and a token can never use a service or tool that is off in iMCP.
Remote sessions pass a pre-approved ConnectionApprovalGate, because a valid access token takes the place of the approval dialog. The remote access test file moves to Tests/imcp-serverTests with the other tests.
Link TailscaleKit 0.2.0-imcp.1 from mattt/libtailscale into the app target, which embeds it like Sparkle. The framework is arm64-only and requires macOS 15.6, so the app target now builds only for arm64 with a deployment target of 15.6, and the app no longer runs on Intel Macs. The CLI, the helper, and the tests don't link the framework and keep their settings.
A sandboxed iMCP can't run the Tailscale command-line tool, and a listener on the Mac's shared tailnet address can be taken over by another local process. iMCP now runs an embedded Tailscale node with its own identity and address, and listens only on that address. The node keeps its state in the app's container and runs only while remote access is on. Settings shows the login link, the node's state, MagicDNS name, and tailnet address, and lets the owner log in with an auth key, rename the device, and log out. For each connection, the server asks the node who the peer is, and accepts only untagged devices of the node's own user. Access tokens, their permissions, and their binding to one device stay the same. The HTTP server reads and writes TailscaleKit connections, and runs their blocking calls on their own threads. The node is behind a small protocol, so the tests use a fake node to check authorization, Host and Origin validation, and the login states.
The README no longer asks for the Tailscale app on the Mac. It describes the login, auth keys, and logout, and says that WireGuard encrypts the plain HTTP traffic and that the node's address belongs only to iMCP. The download requirements now say macOS 15.6 on Apple silicon.
Link TailscaleKit 0.2.0-imcp.2 from mattt/libtailscale, which is universal (arm64 and x86_64) and requires macOS 15.1. The app target builds for the default architectures again, with a deployment target of macOS 15.1, as on main, and the README's download requirement is macOS 15.3 again. A later TailscaleKit release will drop the x86_64 slice.
TailscaleKit contains only a Swift interface that Swift 6.4 generated, so the app needs Xcode 27.1 or later. Of the GitHub-hosted images, only xcode-27 has Xcode 27.1; macos-26 stops at Xcode 26.6. CI now builds with Xcode 27.1 on xcode-27 and drops the Xcode 26.0 and 27.0 entries, which can't build the framework. The release workflow also moves from Xcode 26.0 on macos-26 to Xcode 27.1 on xcode-27.
…ailscalekit # Conflicts: # App/Controllers/ServerController.swift # iMCP.xcodeproj/project.pbxproj
Cloud apps such as claude.ai can't join a tailnet, so iMCP can now serve its MCP endpoint at a public HTTPS address and authorize apps with OAuth 2.1. - OAuth 2.1 authority and endpoints (RFC 9728 and RFC 8414 metadata, RFC 7591 dynamic registration, Client ID Metadata Documents, PKCE S256, refresh token rotation), a native approval window bound to the starting browser, and a list of connected apps with revocation in Settings. - Tailscale Funnel through the embedded node, with stricter request limits for public traffic and guidance for the missing funnel ACL capability. - Cloudflare Tunnel: sign in, find the zone, create or reuse a named tunnel, set the ingress and DNS record, and supervise cloudflared. - The tunnel restarts with backoff when cloudflared exits, reconnects after wake and when the network returns, and retries after a discovery or provisioning failure.
This was referenced Nov 18, 2026
Closed
Owner
|
Following up from #364, the two things that stood out to me here: the public routes accept tailnet tokens that aren't bound to a device yet, and Cloudflare setup can replace a tunnel's existing ingress and CNAME. |
Contributor
Author
|
Closing per #364. Thanks for catching the unbound tailnet token and Cloudflare ingress issues. I will fix those on my fork. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #308. This branch includes #308's commits, because public access builds on its embedded Tailscale node and HTTP server. Only the last two commits are new here, so review
git diff 0771351..HEAD(the merge ofmainaside). Once #308 merges, this diff is the whole change.What and why
Cloud apps such as claude.ai, Claude Duet, Muse and Gemini can't join a tailnet, so #308 doesn't reach them. This adds two public routes to the same loopback HTTP server, and an OAuth 2.1 authorization server so a cloud app is approved once in a window on the Mac instead of with a pasted token.
What changed
OAuthAuthority,OAuthEndpoints,OAuthGrant,ClientMetadataFetcher): RFC 9728 and RFC 8414 metadata, RFC 7591 dynamic client registration, Client ID Metadata Documents, PKCE S256, refresh token rotation. A native window approves each new app. The approval is bound to the browser that started it (a 6-character code and an HttpOnly cookie), and the metadata fetch pins the resolved address to limit SSRF. Grants keep only a hash of the refresh token, in the Keychain.FunnelAccess,RemoteAccess): one toggle forhttps://<node>.<tailnet>.ts.net/mcp, smaller request limits for public traffic, and guidance on thenodeAttrsentry when thefunnelcapability is missing.CloudflareTunnel): sign in withcloudflared tunnel login, acert.pem, or an API token. It finds the zone, creates or reuses a per-Mac named tunnel, sets the ingress to the loopback server, creates or updates the proxied DNSCNAME, and supervisescloudflared tunnel run. It needscloudflaredinstalled (brew install cloudflared).cloudflaredexits, reconnects after wake and when the network returns, and retries after a discovery or provisioning failure.OAuthTests,RemoteAccessTests).How to turn it on
In Settings, choose Remote Access, then either Public Access (Cloudflare Tunnel) or, after logging in to Tailscale, Public Access (Tailscale Funnel). Add the address that Settings shows as a custom connector in the app (in claude.ai: Settings, Connectors) and approve it in the window that opens on the Mac.
One thing to decide
Funnel needs
enableFunnelanddisableFunnelon TailscaleKit's node, which themattt/libtailscale0.2.0-imcp.2release doesn't have. This branch pinsoliverames/libtailscaleat0.2.0-imcp.2-funnel.1, which adds them. If you'd rather keep the pin onmattt/libtailscale, the Funnel API needs to land there first. Cloudflare Tunnel doesn't use it.Testing
iMCPscheme succeeds.swift format lint --strictis clean.imcp-serverTests: 271 tests, 1 skipped, 0 failures, run locally on macOS 26.OAuthTests.testFullFlowThroughTheEndpointsruns the whole OAuth flow against the local endpoints./mcpand the/.well-known/oauth-*metadata. claude.ai (Claude Web) completed OAuth consent through the tunnel on 2026-11-18 and called tools live: Weather, Music, and a read-only sweep of Reminders, Notes, Files, Home, Calendar, Contacts and Maps all answered. The restart-after-exit behavior was added after the tunnel was seen to drop.Not verified
Replaces #352, which carried the same change together with the Setup Assistant and Settings reorganization. Those are left out and will come separately.
Screenshots
Clients in Settings, with a cloud app connected through the tunnel and the connector address to copy.
This is from the Settings window of my integration build, which has a sidebar redesign and the AI app list that are not part of this PR. The connected cloud app (Claude, used seconds before the capture) is the live connection this PR makes possible.