Repository navigation
feat: run a pre-connect step before connecting to a server - #10
Merged
Merged
Conversation
Co-authored-by: tembo[bot] <208362400+tembo-io[bot]@users.noreply.github.com>
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.
A server can now name a pre-connect step: a command gate runs before every attempt to connect to it. It's for servers that need something set up first, and set up again later. Tembo's case is MCP servers on a customer's tailnet (tembo/monorepo#13140, with
proxyfrom #9). The sandbox has to join the tailnet before connecting, and join again after its ephemeral node has been dropped, for example while a VM was hibernated.{ "preConnect": { "tailnet": { "command": "tembo", "args": ["tailscale", "join"], "stderr": "forward" } }, "mcpServers": { "internal": { "url": "https://tools.example.ts.net/mcp", "proxy": "http://localhost:1056", "preConnect": "tailnet" } } }tembo tailscale joindoes."stderr": "forward"both of the command's outputs go to gate's stderr, never its stdout, which carries MCP. Gate only waits for the command to exit, so a daemon it starts (tailscaled) can't hold the step open, and it outlives the step.command,args,env,timeoutSeconds(default 120, since a first run may install or start things) andstderr. HTTP steps are rejected, as are references to unknown steps. Like other hooks, variables a step references are reserved for hooks.proxy.Tests:
pre_connect_steps_run_before_every_attempt: while the step fails, only the server that names it fails (all three attempts run the step, and the error names it), and another server connects. Once the step succeeds, the next attempt runs it again and connects. It fails if gate doesn't run the step.