modelcontextprotocol / modelcontextprotocol/java-sdk
io.modelcontextprotocol.client.transport.StdioClientTransport#closeGracefully
還沒有人認領這個 Issue。
- 主要語言
- Java
- 星號
- 3.7k
- 分支
- 1.1k
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 9
描述
Bug description
When npx is launched on Windows, a related subprocess is initiated. When using the io.modelcontextprotocol.client.transport.StdioClientTransport#closeGracefully method to close, this.process.destroy() will only terminate the current process, but the subprocess cannot be closed, resulting in the main method not being able to end normally. Therefore, the taskkill pid /F /T command needs to be used to terminate it.
Environment
jdk 17
mcp 0.12.0-SNAPSHOT
windows 11
Steps to reproduce
StdioClientTransport stdioClientTransport = new StdioClientTransport(ServerParameters.builder("D:\dev\nodejs\npx.cmd").args(Arrays.asList("-y","@wopal/mcp-server-hotnews")).build());
McpSyncClient mcpClient = McpClient.sync(stdioClientTransport)
.requestTimeout(Duration.ofSeconds(20L))
.capabilities(McpSchema.ClientCapabilities.builder()
.roots(true)
.sampling()
.build())
.build();
mcpClient.initialize();
McpSchema.ListToolsResult listToolsResult = mcpClient.listTools();
List<McpSchema.Tool> tools = listToolsResult.tools();
System.out.println(tools.get(0).name());
mcpClient.closeGracefully();
Expected behavior
Close the child processes simultaneously
Minimal Complete Reproducible example
StdioClientTransport stdioClientTransport = new StdioClientTransport(ServerParameters.builder("D:\dev\nodejs\npx.cmd").args(Arrays.asList("-y","@wopal/mcp-server-hotnews")).build());
McpSyncClient mcpClient = McpClient.sync(stdioClientTransport)
.requestTimeout(Duration.ofSeconds(20L))
.capabilities(McpSchema.ClientCapabilities.builder()
.roots(true)
.sampling()
.build())
.build();
mcpClient.initialize();
McpSchema.ListToolsResult listToolsResult = mcpClient.listTools();
List<McpSchema.Tool> tools = listToolsResult.tools();
System.out.println(tools.get(0).name());
mcpClient.closeGracefully();
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 io.modelcontextprotocol.client.transport.StdioClientTransport#closeGracefully 開始,並重現 issue 中的 Windows npx.cmd 範例。調查啟動的程序及其子程序是如何被終止的;完成的標準是關閉 client 後,子程序樹也會結束,且 main 方法可以正常返回。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java, node.js
- 領域
- backend, operating-systems
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100