-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(server): add host process watchdog to StdioServerTransport #1712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
travisbreaks
wants to merge
2
commits into
modelcontextprotocol:main
Choose a base branch
from
travisbreaks:feat/server-orphan-detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+57
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@modelcontextprotocol/server': patch | ||
| --- | ||
|
|
||
| Close StdioServerTransport when stdin reaches EOF. When the host process exits or is killed, the stdin pipe closes and the transport now detects this via the `end` event, preventing orphaned server processes. Aligns with the behavior of the Python and Kotlin SDKs. | ||
|
Check warning on line 5 in .changeset/server-host-watchdog.md
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The PR title ("add host process watchdog") and description (clientProcessId, watchdogIntervalMs,
process.kill(pid, 0)polling,StdioServerTransportOptions, constructor overloads,unref()timer, and the listed test plan) still describe the original implementation that was replaced on 2026-04-07 with the stdin-EOF approach — none of those exist in the shipped diff. Please update the PR title/body before merge so the squash-commit message matches what actually shipped; the changeset filenameserver-host-watchdog.mdis also a stale leftover (cosmetic, since changeset files are deleted on release).Extended reasoning...
What's wrong
The PR metadata describes an implementation that no longer exists. The title is "feat(server): add host process watchdog to StdioServerTransport" and the description documents:
clientProcessIdoptionwatchdogIntervalMsoption (default 3s)process.kill(pid, 0)StdioServerTransportOptionsinterface.unref()should close transport when host process is gone,should not close when host process is alive,should stop watchdog on close,should accept options object constructorPer the timeline (author comments on 2026-04-05 and 2026-04-07), this was completely rewritten to the stdin-EOF approach. The shipped diff contains none of the above.
What actually shipped
packages/server/src/server/stdio.tsadds exactly three lines of behavior:No options, no interface, no constructor overload, no timer, no PID polling. The tests are
should close transport when stdin emits end,should not fire onclose twice when close() is called after stdin end, andshould remove end listener on close— none of the four tests listed in the PR description exist.Step-by-step proof
clientProcessIdoption" →grep clientProcessId packages/server/src/server/stdio.ts→ no matches.watchdogIntervalMs" →grep watchdogIntervalMs→ no matches.StdioServerTransportOptionsinterface" →grep StdioServerTransportOptions→ no matches. (The earlier bot review flagging an unusedimport type { StdioServerTransportOptions }is also obsolete — that import no longer exists in the test file.)unref()" →grep unref→ no matches.should close transport when host process is gone→ not instdio.test.ts; the actual test isshould close transport when stdin emits end..changeset/server-host-watchdog.md): "Close StdioServerTransport when stdin reaches EOF … detects this via theendevent" — this is correct and matches the code. Only the filename is stale.Why it matters
This repo squash-merges PRs, so the PR title and body become the permanent commit message on
main. Anyone runninggit logorgit blameonstdio.tswill see a commit claiming to add a PID-polling watchdog with a configurable interval and a new options interface — and find none of it in the tree. The repo's review conventions explicitly call out "prose that promises behavior the code no longer ships" as something to flag.The published npm changelog will be fine (the changeset body is accurate), so this has zero runtime or API impact — hence nit severity.
Fix
Before merge:
feat(server): close StdioServerTransport on stdin EOF to prevent orphaned processes..changeset/server-host-watchdog.md→ something like.changeset/server-stdin-eof.md(cosmetic — changeset files are deleted on release, so this only affects git history).