From 4f36c0dd2d0f37d21b1df54690e2d89a38246231 Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Thu, 8 Jan 2026 22:23:08 +0800 Subject: [PATCH] feat(LocalRunnerClient): support deleting MCP configurations in CommonMcp --- .../core/action/runner/LocalRunnerClient.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Partner-Main/src/main/java/work/slhaf/partner/core/action/runner/LocalRunnerClient.java b/Partner-Main/src/main/java/work/slhaf/partner/core/action/runner/LocalRunnerClient.java index 9a7cadcc..fef9578a 100644 --- a/Partner-Main/src/main/java/work/slhaf/partner/core/action/runner/LocalRunnerClient.java +++ b/Partner-Main/src/main/java/work/slhaf/partner/core/action/runner/LocalRunnerClient.java @@ -1242,7 +1242,35 @@ public class LocalRunnerClient extends RunnerClient { @Override @NotNull protected LocalWatchServiceBuild.EventHandler buildDelete() { - return null; + return (thisDir, context) -> { + val file = context.toFile(); + if (file.isFile() && file.getName().endsWith(".json")) { + return; + } + + val fileRecord = mcpConfigFileCache.remove(file); + if (fileRecord == null) { + return; + } + + // clear from existedMetaActions and mcpClients + // client id comes from fileRecord.paramsCache + // actionKey from `id::toolName` + val clientIdSet = fileRecord.paramsCacheMap().keySet(); + for (String clientId : clientIdSet) { + val client = mcpClients.remove(clientId); + if (client == null) { + continue; + } + + val tools = client.listTools().tools(); + for (McpSchema.Tool tool : tools) { + val actionKey = clientId + "::" + tool.name(); + existedMetaActions.remove(actionKey); + } + client.close(); + } + }; } private record McpConfigFileRecord(long lastModified, long length,