Repository navigation
Allow independent MCP backends to launch concurrently - #15006
Conversation
Co-authored-by: lpcox <[email protected]>
Co-authored-by: lpcox <[email protected]>
Co-authored-by: lpcox <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Launch completion is not coordinated with shutdown, allowing connections to escape cleanup.
2 open findings
What changed in this PR
Enables independent MCP backends to initialize concurrently while deduplicating launches for each server or session.
Changes:
- Replace launch-wide locking with per-key singleflight coordination.
- Limit mutex use to cache and runtime-state updates.
- Add concurrent HTTP initialization regression coverage.
| File | Description |
|---|---|
internal/launcher/launcher.go |
Coordinate launches per key and shorten critical sections. |
internal/launcher/launcher_test.go |
Test concurrent initialization of independent backends. |
go.mod |
Make golang.org/x/sync a direct dependency. |
🧠 Review effort: Max
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| logger.LogInfoToServer(serverID, "backend", "Successfully configured HTTP MCP backend: %s", serverID) | ||
|
|
||
| l.mu.Lock() | ||
| l.connections[serverID] = conn |
|
@copilot address review feedback |
Co-authored-by: lpcox <[email protected]>
Addressed in 82be445: shutdown now rejects new launches and closes late connections across all three publication paths. Added blocked-initialization regressions for HTTP and both stdio paths, and fixed timeout cleanup in the concurrency test. Race-enabled launcher tests and |


Parallel backend registration was serialized because the launcher's global mutex remained held during connection startup and MCP initialization. A slow or hung backend could therefore delay every backend behind it.
singleflightper stateless server and per stateful(server, session)pair.Launcher.mu.recordStartandrecordErrorself-locking.