refactor(mcp): switch desc.json loading to fastjson2 to avoid desc.json loading error

This commit is contained in:
2026-04-01 22:57:17 +08:00
parent 4ae65b885e
commit b9fd9bcaac
3 changed files with 44 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
package work.slhaf.partner.core.action.runner.mcp;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import io.modelcontextprotocol.common.McpTransportContext;
import io.modelcontextprotocol.json.McpJsonMapper;
@@ -241,7 +241,7 @@ public class DynamicActionMcpManager implements AutoCloseable {
}
MetaActionInfo info;
try {
info = JSONUtil.readJSONObject(dir.resolve("desc.json").toFile(), StandardCharsets.UTF_8).toBean(MetaActionInfo.class);
info = JSON.parseObject(Files.readString(dir.resolve("desc.json"), StandardCharsets.UTF_8), MetaActionInfo.class);
} catch (Exception e) {
log.error("desc.json 加载失败: {}", dir);
return false;

View File

@@ -1,6 +1,6 @@
package work.slhaf.partner.core.action.runner.mcp;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import io.modelcontextprotocol.common.McpTransportContext;
import io.modelcontextprotocol.json.McpJsonMapper;
@@ -70,7 +70,7 @@ public class McpMetaRegistry implements AutoCloseable {
return false;
}
try {
MetaActionInfo info = JSONUtil.readJSONObject(file, StandardCharsets.UTF_8).toBean(MetaActionInfo.class);
MetaActionInfo info = JSON.parseObject(Files.readString(file.toPath(), StandardCharsets.UTF_8), MetaActionInfo.class);
String uri = file.toPath().toUri().toString();
descCache.put(uri, JSONObject.toJSONString(info));
String actionKey = name.replace(".desc.json", "");