feat(platform): 强化工作流节点 JSON schema 约束并修复 MCP inputSchema 生成
- 将 tasks 从 z.array(z.any()) 改为递归 discriminated union - 覆盖 webhook/condition/every/stop/http/flow-detail/code/code-js2/ekuaibao-datalink-filter/create/data-convert/flow-create-task 及兜底 unknown - 使用 Zod v4 内置 toJSONSchema() 替换不兼容的 zod-to-json-schema - 移除 zod-to-json-schema 依赖
This commit is contained in:
1 parent
58c8a92d8e
commit
e583a5faab
4 files changed
+242
-44
No files matched your search
+9
-29
@@ -4,7 +4,6 @@ import {
|
||||
CallToolRequestSchema,
|
||||
ListToolsRequestSchema,
|
||||
} from "@modelcontextprotocol/sdk/types.js";
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
import { loadCorpConfigs } from "./core/config/loader.js";
|
||||
import { CorpContext } from "./core/config/manager.js";
|
||||
import { createClient } from "./core/http/factory.js";
|
||||
@@ -12,7 +11,6 @@ import { getEasoClient } from "./core/auth/easo.js";
|
||||
import { getPiperClient } from "./core/auth/piper.js";
|
||||
import { sealaiTools } from "./domains/sealai/tools.js";
|
||||
import { platformTools } from "./domains/platform/tools.js";
|
||||
import * as platformApi from "./domains/platform/api.js";
|
||||
|
||||
async function main() {
|
||||
// 加载企业配置
|
||||
@@ -54,18 +52,13 @@ async function main() {
|
||||
...sealaiTools.map((t) => ({
|
||||
name: t.name,
|
||||
description: t.description,
|
||||
inputSchema: zodToJsonSchema(t.parameters as any),
|
||||
inputSchema: (t.parameters as any).toJSONSchema(),
|
||||
})),
|
||||
// Platform 工具
|
||||
{
|
||||
name: "platform_list",
|
||||
description: "列出企业下所有启用的自建应用",
|
||||
inputSchema: { type: "object", properties: {} },
|
||||
},
|
||||
...platformTools.map((t) => ({
|
||||
name: t.name,
|
||||
description: t.description,
|
||||
inputSchema: zodToJsonSchema(t.parameters as any),
|
||||
inputSchema: (t.parameters as any).toJSONSchema(),
|
||||
})),
|
||||
],
|
||||
};
|
||||
@@ -122,11 +115,13 @@ async function main() {
|
||||
}
|
||||
|
||||
// Platform 工具
|
||||
if (name === "platform_list") {
|
||||
const client = await createClient(currentCorp, "ekb");
|
||||
const result = await platformApi.listPlatforms(
|
||||
client,
|
||||
currentCorp.credentials.corpId
|
||||
const platformTool = platformTools.find((t) => t.name === name);
|
||||
if (platformTool) {
|
||||
const ekbClient = await createClient(currentCorp, "ekb");
|
||||
const { client: easoClient } = await getEasoClient(currentCorp);
|
||||
const result = await platformTool.handler(
|
||||
{ corp: currentCorp, ekbClient, easoClient },
|
||||
args as never
|
||||
);
|
||||
return {
|
||||
content: [
|
||||
@@ -138,21 +133,6 @@ async function main() {
|
||||
};
|
||||
}
|
||||
|
||||
// Platform 工作流工具(EASO)
|
||||
const easoTool = platformTools.find((t) => t.name === name);
|
||||
if (easoTool) {
|
||||
const { client } = await getEasoClient(currentCorp);
|
||||
const result = await easoTool.handler(client, args as never);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: JSON.stringify(result, null, 2),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user