fix(LocalRunnerClient): close old MCP client while a new client's name is duplicated with the old one

This commit is contained in:
2026-01-13 23:22:54 +08:00
parent 774e2b6cd5
commit fdf398b86e

View File

@@ -1077,6 +1077,12 @@ public class LocalRunnerClient extends RunnerClient {
* @param mcpClientTransportParams MCP Server 的参数
*/
private void registerMcpClient(String id, McpClientTransportParams mcpClientTransportParams) {
// 如果已存在同名 client则需要先获取并关闭
val old = mcpClients.get(id);
if (old != null) {
old.close();
}
val clientTransport = createTransport(mcpClientTransportParams);
val timeout = mcpClientTransportParams.timeout;
val client = McpClient.sync(clientTransport)