perf: parallelize MCP server initialization in get_all_tool_definitions#138
Open
JasonOA888 wants to merge 1 commit intoMiroMindAI:mainfrom
Open
perf: parallelize MCP server initialization in get_all_tool_definitions#138JasonOA888 wants to merge 1 commit intoMiroMindAI:mainfrom
JasonOA888 wants to merge 1 commit intoMiroMindAI:mainfrom
Conversation
Partially addresses MiroMindAI#137 MCP tool servers were being initialized sequentially in a for loop, causing ~70-80s overhead per task (tool-python ~33s, search ~21s, jina ~17s). This change: - Refactors server connection logic into a helper function _get_server_tools() - Uses asyncio.gather() to connect to all servers in parallel - Expected savings: ~40-50s per task initialization The parallel approach maintains the same error handling behavior: - Failed connections still add an error entry - Exceptions from asyncio.gather are logged and handled gracefully
4 tasks
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.
Partially addresses #137
Problem:
MCP tool servers were being initialized sequentially in a for loop:
With 1266 BC-EN tasks, this adds significant overhead to evaluation runs.
Solution:
_get_server_tools()helper functionasyncio.gather()to connect to all servers in parallelChanges:
libs/miroflow-tools/src/miroflow_tools/manager.py:_get_server_tools(config)asyncio.gather(..., return_exceptions=True)Error handling preserved:
Benchmark impact: