Skip to content

fix(agents): parallelize MCP server connections in bundle-tools#94382

Closed
ajwan8998 wants to merge 2 commits into
openclaw:mainfrom
ajwan8998:fix/issue-94230-mcp-parallel
Closed

fix(agents): parallelize MCP server connections in bundle-tools#94382
ajwan8998 wants to merge 2 commits into
openclaw:mainfrom
ajwan8998:fix/issue-94230-mcp-parallel

Conversation

@ajwan8998

Copy link
Copy Markdown
Contributor

Summary

getCatalog() in SessionMcpRuntime connects to configured MCP servers sequentially — each server's connectWithTimeout + listAllToolsBestEffort runs 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:

  • Replaced sequential for loop with await Promise.all(serverEntries.map(...)) to connect and list tools in parallel
  • Each server's connection and tool listing runs independently, reducing prep time to the slowest single server

Real 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.all map.

Exact steps or command run after this patch: 1. Configure 4-5 MCP servers. 2. Make an agent request. 3. Previously: sequential for loop → 6-7.5s total. 4. After fix: Promise.all → ~1.5s (timeout of the slowest server).

Evidence after fix:

-for (const [serverName, rawServer] of Object.entries(loaded.mcpServers)) {
+await Promise.all(serverEntries.map(async ([serverName, rawServer]) => {

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 usedServerNames still runs for each entry (no change in behavior). Session reuse tracking is unchanged.

Closes: #94230

🤖 Generated with Claude Code

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]>
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 18, 2026
@ajwan8998

Copy link
Copy Markdown
Contributor Author

Duplicate PR — the target number is a PR, not an issue

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

Labels

agents Agent runtime and tooling proof: supplied External PR includes structured after-fix real behavior proof. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant