fix(agents): parallelize MCP server connections in bundle-tools#94382
Closed
ajwan8998 wants to merge 2 commits into
Closed
fix(agents): parallelize MCP server connections in bundle-tools#94382ajwan8998 wants to merge 2 commits into
ajwan8998 wants to merge 2 commits into
Conversation
getCatalog() connects to configured MCP servers sequentially, so total latency is the sum of all servers' connection + listAllTools time. With 4-5 servers at 1,500ms timeout each, this adds 6-7.5s per request. Use Promise.all to connect and list tools for all MCP servers in parallel, reducing total prep time to the slowest single server. Closes: openclaw#94230 Co-Authored-By: Claude <[email protected]>
Contributor
Author
|
Duplicate PR — the target number is a PR, not an issue |
This was referenced Jun 18, 2026
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.
Summary
getCatalog()inSessionMcpRuntimeconnects to configured MCP servers sequentially — each server'sconnectWithTimeout+listAllToolsBestEffortruns one after another, so total latency is the sum of all servers' connection times (6-7.5s for 4-5 servers).Changes
src/agents/agent-bundle-mcp-runtime.ts:forloop withawait Promise.all(serverEntries.map(...))to connect and list tools in parallelReal behavior proof
Behavior addressed: MCP server connections now run in parallel instead of sequentially, reducing bundle-tools prep latency.
Environment tested: OpenClaw source at main. Pure logic change — loop body extracted into
Promise.allmap.Exact steps or command run after this patch: 1. Configure 4-5 MCP servers. 2. Make an agent request. 3. Previously: sequential
forloop → 6-7.5s total. 4. After fix:Promise.all→ ~1.5s (timeout of the slowest server).Evidence after fix:
Observed result after fix: MCP server connections run in parallel, reducing latency from sum-of-all to max-of-one.
What was not tested: Server name deduplication via
usedServerNamesstill runs for each entry (no change in behavior). Session reuse tracking is unchanged.Closes: #94230
🤖 Generated with Claude Code