Repository navigation
feat: Remote Access via Tailscale Funnel & Cloudflare Tunnel with OAuth 2.1 - #352
Closed
oliverames wants to merge 30 commits into
Closed
oliverames wants to merge 30 commits into
oliverames wants to merge 30 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
Off by default. Funnel forwards public HTTPS traffic to a listener on 127.0.0.1, so those requests are treated as internet traffic: a bearer token is required on every request (no whois or loopback trust), only the node's public ts.net name is accepted as Host and Origin, requests and connections have smaller limits, and repeated bad tokens get 429. Tokens bound to a tailnet device are rejected on this path. Funnel's saved serve config is cleared whenever the node stops or starts without public access. The tailnet-only path is unchanged. Needs the libtailscale funnel branch (ACME enabled, enableFunnel and disableFunnel).
Public access now works without a copied token. iMCP is its own OAuth authorization server (MCP authorization spec 2025-11-25): protected resource metadata (RFC 9728), authorization server metadata (RFC 8414), dynamic client registration (RFC 7591), Client ID Metadata Documents, PKCE S256 only, and resource indicators (RFC 8707). The owner approves each app in a native window, and Settings lists connected apps with a Revoke button. Access tokens last an hour and live in memory. Refresh tokens rotate, are stored hashed in the Keychain, and a reused one ends the grant. Also adds a 15 second total deadline for requests on Funnel connections, and clears Funnel's saved configuration when the node starts and after a stop that raced a pending enable.
This was referenced Nov 16, 2026
added 6 commits
November 16, 2026 18:13
…h address Authorization requests get a 6-character confirmation code shown on the waiting page and in the approval request, plus a 256-bit poll secret in an HttpOnly, Secure, SameSite=Lax cookie. Only a poll with the cookie can get the code redirect. The approval shows the full client ID and redirect URI. The Client ID metadata fetch resolves once, checks every address, and connects to the checked address with Network.framework, using the hostname for SNI and certificate verification. It also blocks 64:ff9b::/96, 64:ff9b:1::/48, 2002::/16, fec0::/10 and ::/96.
URL.path and URL.query decode %0D%0A into a line break, so a client ID URL could inject headers into the pinned HTTP/1.0 request. Use the encoded forms and refuse any target byte outside printable ASCII.
added 2 commits
November 17, 2026 15:47
This was referenced Nov 18, 2026
Closed
…econnect when the network returns
oliverames
marked this pull request as ready for review
November 18, 2026 18:26
Contributor
Author
|
Replaced by #376, the same change cut as one PR so it can merge on its own. |
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.
An early spike, opened for discussion. It depends on #308 and includes its commits. Once #308 lands I plan to split what is left into Funnel, OAuth 2.1 (#330) and Cloudflare Tunnel PRs, tracked in #364. It is out of draft so it can be read and commented on, not because it is ready to merge.
What it does
Lets remote MCP clients reach iMCP from outside the local Mac:
claude.ai, Claude Duet, Muse, and other devices on the user's tailnet. It builds on #308's embedded Tailscale node and adds two public routes, Tailscale Funnel and Cloudflare Tunnel, plus an OAuth 2.1 authorization server so a cloud client can be approved on the Mac instead of pasting a token.What changed
FunnelAccess.swift,RemoteAccess.swift): one toggle for public access athttps://<node>.<tailnet>.ts.net/mcp, with guidance on the ACLnodeAttrsentry when the Funnel capability is missing. Needs the TailscaleKit build fromoliverames/libtailscale(release0.2.0-imcp.2-funnel.1), pinned in this branch.CloudflareTunnel.swift): sign in withcloudflared tunnel login, an existingcert.pem, or an API token in the Keychain. It finds the zone, creates or reuses a per-Mac named tunnel, sets the ingress to the loopback HTTP server, creates or updates the proxied DNSCNAME, and supervisescloudflared tunnel run, restarting it with backoff and after wake.OAuthAuthority.swift,OAuthEndpoints.swift,OAuthGrant.swift): RFC 9728 and RFC 8414 metadata, RFC 7591 dynamic client registration, Client ID Metadata Documents, PKCE S256, refresh token rotation. A native Mac window approves each new client, and connected apps can be revoked in Settings. 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.OnboardingGate.swift,OnboardingWizard.swift,SettingsView.swift,RemoteAccessSettingsView.swift): a guided setup for services, remote tunnels and connecting AI apps, and a reorganized Clients pane with technical overrides under "Developer & Advanced". This part is early and is expected to move to its own PR.Testing
OAuthTestsandRemoteAccessTestscover the OAuth endpoints, the approval binding, the metadata fetch checks and the remote access paths.OAuthTests.testFullFlowThroughTheEndpointsruns the whole flow against the local endpoints.imcp-serverTestssuite./mcpand the/.well-known/oauth-*metadata (200 and 401 as expected). The restart-after-exit behavior was added after the tunnel was seen to drop.Not verified