StdioClientTransport should support bounded child process termination
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start at StdioClientTransport.closeGracefully() and inspect how ServerParameters configures the transport and how process.onExit() is awaited. Add a configurable termination timeout, then run or add the suggested regression test with a child process that ignores SIGTERM. Done means shutdown completes within the timeout buffer, forcibly terminates a surviving child, and cleans up schedulers and sinks.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/java-sdk
-
area/transport bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/java-sdk#1124 · 1 comment ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Openbug P2 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/java-sdk#1086 · 1 comment ·
-
enhancement good first issue P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
modelcontextprotocol/java-sdk#898 · 1 comment ·
All issues in modelcontextprotocol/java-sdk
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100