Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Gateway now launches MCP servers concurrently during startup. Previously, servers were launched sequentially during tool registration, causing O(n) startup latency. Parallel launching reduces this to O(max) with proper timeout handling preserved.

Changes

Command-line interface:

  • Added --parallel-launch flag (default: true)

Server launching:

  • registerAllToolsParallel(): Launches each server in a goroutine, collects results via buffered channel
  • registerAllToolsSequential(): Preserves original sequential behavior when flag disabled
  • launchResult struct: Captures serverID, error, and duration from each launch
  • Uses sync.WaitGroup for synchronization (no sleep-based waiting)

Configuration:

  • Added ParallelLaunch field to Config struct

Implementation

// Launch each server in its own goroutine
for _, serverID := range serverIDs {
    wg.Add(1)
    go func(sid string) {
        defer wg.Done()
        
        startTime := time.Now()
        err := us.registerToolsFromBackend(sid)
        duration := time.Since(startTime)
        
        results <- launchResult{
            serverID: sid,
            err:      err,
            duration: duration,
        }
    }(serverID)
}

// Wait for all goroutines to complete
wg.Wait()
close(results)

Log output includes per-server timing and success/failure counts:

Parallel tool registration complete: 3 succeeded, 1 failed, total tools=42

Timeout handling inherited from existing GetOrLaunch() implementation ensures individual server failures don't block gateway startup.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • nonexistent.local
    • Triggering command: /tmp/go-build233922285/b269/launcher.test /tmp/go-build233922285/b269/launcher.test -test.testlogfile=/tmp/go-build233922285/b269/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true p/go-build (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build233922285/b278/mcp.test /tmp/go-build233922285/b278/mcp.test -test.testlogfile=/tmp/go-build233922285/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo 2xn6GOEZ9 x_amd64/compile (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 26, 2026 16:51
…abled by default)

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for parallel launching of mcp servers Add parallel server launching with --parallel-launch flag Jan 26, 2026
Copilot AI requested a review from lpcox January 26, 2026 16:59
@lpcox lpcox marked this pull request as ready for review January 26, 2026 17:03
@lpcox lpcox merged commit 3d61299 into main Jan 26, 2026
3 checks passed
@lpcox lpcox deleted the copilot/enable-parallel-launching branch January 26, 2026 17:03
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