You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue 301 - Option B - minimal implementation - #302
Option B from #301: quit and Ctrl+D are the clean exits, and Ctrl+C just stops the client. For comparison with #300 (option A).
Python: restore the default SIGINT handler, so Ctrl+C exits at once instead of hanging on the thread blocked in input()
TypeScript: Ctrl+C stops the client at once, also during a query (it used to wait for the pending reply). In a terminal readline takes Ctrl+C itself, so this is one rl.on("SIGINT", ...) line in place of the old process handler
Ruby: rescue Interrupt, so Ctrl+C exits without a backtrace
Go, Rust: unchanged, they already stop at once
READMEs: every client says quit or Ctrl+D exits cleanly and Ctrl+C stops the client at once
Tests: the tool-loop test presses Ctrl+C at the prompt with stdin left open and requires the client to exit within 15s
How Has This Been Tested?
Locally.
Breaking Changes
N/a
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The Ctrl-C regression test can pass without ever sending SIGINT and does not check stderr for the uncaught Interrupt backtrace it is intended to prevent.
Implements the minimal Ctrl-C behavior from issue #301 for the tutorial clients: quit and Ctrl-D remain clean exits, while Ctrl-C stops the client promptly.
Changes:
Adjusts interrupt handling in Python, TypeScript, and Ruby; Go and Rust code remain unchanged.
Documents exit behavior in all five client READMEs.
Adds a regression check that sends SIGINT at the prompt with stdin left open.
File
Description
tests/smoke-test.sh
Updates a comment describing interrupt coverage.
tests/README.md
Documents the new Ctrl-C check.
tests/helpers/tool-loop-test.ts
Adds a process-group interrupt check with a timeout.
mcp-client-typescript/README.md
Documents clean exits and Ctrl-C behavior.
mcp-client-typescript/index.ts
Makes readline Ctrl-C exit immediately.
mcp-client-rust/README.md
Documents clean exits and Ctrl-C behavior.
mcp-client-ruby/README.md
Documents clean exits and Ctrl-C behavior.
mcp-client-ruby/client.rb
Rescues Interrupt to suppress its backtrace.
mcp-client-python/README.md
Documents clean exits and Ctrl-C behavior.
mcp-client-python/client.py
Restores default SIGINT termination to avoid blocked-input shutdown hangs.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The interrupt test only sends SIGINT at an idle prompt with piped stdio, leaving terminal Ctrl-C handling and timely exit during pending queries unverified.
Interrupt test misses Ctrl-C during pending queries
mcp-client-typescript/index.ts:235
The new interrupt test sends an OS SIGINT only at an idle prompt with piped stdio, so it does not exercise readline's terminal SIGINT handler or interruption during a pending query. It would still pass if this handler were removed and terminal Ctrl-C reverted to waiting for the API reply. Add a held-response fake-API scenario that requires all five clients to exit within the deadline during a query, using terminal Ctrl-C input for TypeScript so this handler is covered.
The reason will be displayed to describe this comment to others. Learn more.
Going with Option B from #301. It fixes the two real defects (the Python hang on the blocked input() thread and the Ruby backtrace), gives TypeScript the same stop-at-once behavior in a terminal, and documents the rule in every README: quit or Ctrl-D is the clean exit, Ctrl-C just stops the client. That fits the AGENTS.md rule to leave out code that only makes an example more robust, and nothing leaks in practice since a stdio server exits when its stdin closes. The process-group SIGINT test with stdin left open covers the hang and the backtrace. CI is green. Merging.
One optional nit for a follow-up: Ruby now exits 0 after Ctrl-C while the other four exit 130. An exit 130 in the rescue Interrupt branch would make the five fully alike.
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
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.
Motivation and Context
Option B from #301:
quitand Ctrl+D are the clean exits, and Ctrl+C just stops the client. For comparison with #300 (option A).input()rl.on("SIGINT", ...)line in place of the old process handlerInterrupt, so Ctrl+C exits without a backtracequitor Ctrl+D exits cleanly and Ctrl+C stops the client at onceHow Has This Been Tested?
Locally.
Breaking Changes
N/a
Types of changes
Checklist
Additional context
Assisted by Claude Opus, reviewed by me