StdioClientTransport should support bounded child process termination
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 55/100
Rechercherichtung
Beginne bei StdioClientTransport.closeGracefully() und untersuche, wie ServerParameters den Transport konfiguriert und wie auf process.onExit() gewartet wird. Füge ein konfigurierbares Beendigungs-Timeout hinzu und führe dann den vorgeschlagenen Regressionstest mit einem Kindprozess aus, der SIGTERM ignoriert, oder füge ihn hinzu. Fertig ist es, wenn das Herunterfahren innerhalb des Timeout-Puffers abgeschlossen wird, ein weiterhin laufender Kindprozess zwangsweise beendet wird und Scheduler sowie Sinks bereinigt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
StdioClientTransport starts and manages a child MCP server process. During graceful shutdown, the SDK transport currently calls process.destroy() and waits for process.onExit().
That works when the child process responds to SIGTERM, but it can hang indefinitely if the child process ignores termination or becomes stuck. Downstream, we had to implement a custom McpClientTransport to ensure proxied MCP server processes are always cleaned up when the parent shuts down.
Current behavior
The current shutdown flow is effectively:
if (this.process != null) {
this.process.destroy();
return Mono.fromFuture(process.onExit());
}
There is no configurable timeout and no fallback to destroyForcibly().
Expected behavior
StdioClientTransport.closeGracefully() should support bounded process termination:
- Stop accepting new messages.
- Complete the transport sinks.
- Send graceful termination with
process.destroy(). - Wait up to a configurable timeout.
- If the process is still alive, call
process.destroyForcibly(). - Dispose the transport schedulers.
This guarantees that child MCP server processes do not survive parent shutdown indefinitely.
Proposed fix
Add a configurable process termination timeout to StdioClientTransport, with a sensible default.
Conceptually:
process.destroy();
return Mono.fromFuture(process.onExit())
.timeout(processTerminationTimeout, Mono.defer(() -> {
if (process.isAlive()) {
process.destroyForcibly();
}
return Mono.fromFuture(process.onExit());
}));
This could be exposed through the existing ServerParameters builder or a dedicated StdioClientTransport constructor/builder option.
Suggested regression test
Add a test with a child process that ignores SIGTERM or does not exit promptly.
The test should verify that:
closeGracefully()completes within the configured timeout plus a small buffer.- The child process is no longer alive after
closeGracefully()completes. - The transport schedulers and sinks are cleaned up.
- Vorherrschende Sprache
- Java
- Sterne
- 3.7k
- Forks
- 1.1k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 9
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/java-sdk
-
area/transport bug P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
modelcontextprotocol/java-sdk#1124 · 1 Kommentar ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Offenbug P2 ready for work
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
modelcontextprotocol/java-sdk#1086 · 1 Kommentar ·
-
enhancement good first issue P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
modelcontextprotocol/java-sdk#898 · 1 Kommentar ·
Alle Issues in modelcontextprotocol/java-sdk
Ähnliche Issues
-
Bug Java Platform: Java
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
getsentry/sentry-java#6138 · 1 Kommentar ·
-
bug needs triage p2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 Kommentar ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/rocketmq-dashboard#4654 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100