#4896 : Fix deadlock in MCPTool.message_handler when server sends tool/prompt…#4898
Closed
manjunathshiva wants to merge 2 commits intomicrosoft:mainfrom
Closed
#4896 : Fix deadlock in MCPTool.message_handler when server sends tool/prompt…#4898manjunathshiva wants to merge 2 commits intomicrosoft:mainfrom
manjunathshiva wants to merge 2 commits intomicrosoft:mainfrom
Conversation
… list_changed notifications message_handler was awaiting load_tools()/load_prompts() inline on notifications/tools/list_changed. load_tools() calls _ensure_connected() which sends a ping, but the session cannot process it while blocked waiting for an in-flight call_tool response — causing a deadlock. Replace inline reloads with debug logging. Tools/prompts will be refreshed on the next connect(reset=True) or explicit load_tools() call. Fixes microsoft#4896
Contributor
|
This is being worked on here: #4866 |
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
message_handlerawaitsload_tools()/load_prompts()inline whennotifications/tools/list_changedarrives.
load_tools()calls_ensure_connected()→send_ping(), but the session can't process the ping whileblocked on an in-flight
call_toolresponse — deadlock.connect(reset=True)orexplicit
load_tools()call.tools/list_changedduring tool execution (e.g.mongodb-mcp-server) causesMCPStdioTool.call_toolto hang indefinitely.Fixes #4896
Test plan
MCPStdioToolwithmongodb-mcp-server—call_toolshould return without hangingconnect()connect(reset=True)still refreshes tools