This repository was archived by the owner on May 4, 2026. It is now read-only.
fix: keep stdin open in stdio test to survive mcp>=1.27.0 transport-close cancel - #28
Merged
Merged
Conversation
…lose cancel Agent-Logs-Url: https://github.com/teh-hippo/tiny-ntfy-mcp/sessions/28e21323-f524-40eb-9c2e-09206b13d4ad Co-authored-by: teh-hippo <490309+teh-hippo@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
teh-hippo
May 4, 2026 00:25
View session
There was a problem hiding this comment.
Pull request overview
Updates the stdio integration test to keep the subprocess stdin open long enough for tools/list to respond, avoiding handler cancellation introduced by MCP >=1.27.0 when the transport closes.
Changes:
- Switch
test_stdio_initialize_and_tools_listfromsubprocess.run()tosubprocess.Popen()to avoid closing stdin immediately. - Send JSON-RPC messages incrementally and keep stdin open until the
tools/listresponse is observed (or a timeout occurs). - Collect stdout responses asynchronously and improve failure diagnostics by asserting on explicit timeouts and capturing stderr.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
teh-hippo
marked this pull request as ready for review
May 4, 2026 01:37
teh-hippo
enabled auto-merge (rebase)
May 4, 2026 01:37
Replace the t.join(timeout=...) wait with a threading.Event set by the reader the moment the id=2 response is observed, and join the reader explicitly after the subprocess exits. This removes the small race where the reader could still be appending to responses while the main thread was evaluating the assertion, addresses reviewer feedback on PR #28, and also surfaces the captured response ids and stderr in the timeout assertion message for easier diagnosis. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
|
Addressed the reviewer's race-condition concern in 7e669fa: the reader thread now signals a |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
MCP 1.27.0 added
finally: tg.cancel_scope.cancel()toServer.run()(PR modelcontextprotocol/python-sdk#2334). When stdin closes, all in-flight handlers are immediately cancelled — includingtools/list— before they can respond. The previous test usedsubprocess.run()which closes stdin immediately after writing all messages, creating a race where the handler was cancelled before it could flush its response.Changes
tests/test_mcp_server.py: Replacesubprocess.run()withsubprocess.Popen()intest_stdio_initialize_and_tools_listid=2(tools/list) arrives or 5 s elapseswait()for clean exit