Skip to content

Serve MCP over HTTP to your other devices on Tailscale - #308

Draft
mattt wants to merge 16 commits into
mainfrom
mattt/add-http-transport
Draft

mattt wants to merge 16 commits into
mainfrom
mattt/add-http-transport

Conversation

@mattt

@mattt mattt commented Oct 26, 2026

Copy link
Copy Markdown
Owner

No description provided.

mattt added 10 commits October 26, 2026 11:21
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
@mattt mattt mentioned this pull request Nov 4, 2026
@oliverames

Copy link
Copy Markdown
Contributor

@mattt I read through this with fresh eyes, since I've been working on the same kind of tailnet and public HTTP code on my fork and just hit a few problems there. Most of what I was looking for isn't an issue here. The peer and the token are checked on every request on a kept-alive connection, tokens are hashed and stay in the Keychain, the Host and Origin allow-list blocks DNS rebinding, and the parser is careful about Content-Length and Transfer-Encoding. A few things did stand out:

  1. The peer is checked only after a whole request is read. accept takes any connection while there are fewer than 32 (RemoteAccess.swift:517), and authorizedPeer runs inside the request handler (:531), so a device on the tailnet that isn't the owner's, a shared or tagged node for example, can open all 32 connections and send a byte every couple of minutes. Each receive gets a fresh 120-second timeout, so they never close, and the owner's own devices get refused while it lasts. A declared 8 MB body is buffered before the check, and Expect: 100-continue gets its 100 Continue before it too. Running whois at accept, closing other peers right away, a short deadline on the request head, and a per-address connection cap would close all of that.

  2. One client can use up every session. maximumSessions is 16 across all tokens, and a session with an open stream is never evicted (:692, :794), so a stuck client holding 16 GET streams makes every other token's initialize return 503. A per-token cap that evicts that token's own oldest session first would keep one client from locking out the others.

  3. Host is only checked when it's sent. The validator skips the check when the header is missing, and the parser doesn't require it on HTTP/1.1. It isn't exploitable since a token is still needed, but a 400 for a missing Host would match the spec. The match is also case-sensitive, so Mac-iMCP.ts.net or a trailing dot gets a 421.

  4. A failing whois is asked again on every request (:580), and each one also reads the full node status. A few seconds of negative caching would stop a misbehaving peer from turning every request into two status calls.

I haven't run any of this against a live tailnet, so these are all from reading the code. If any of them would help as a PR on top of this branch, I'm glad to send one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants