feat(datalink): add generic app object and record queries

This commit is contained in:
gitea committed 2026-09-09 13:57:45 +08:00
1 parent 2502a49fb9
commit 893fc47ac6
20 files changed
+693 -55

No files matched your search

+22 -1
View File
@@ -10,6 +10,7 @@ import { getEasoClient } from "./core/auth/easo.js";
import { AuthenticationError, EkbError, NotLoggedInError } from "./core/errors.js";
import { authTools } from "./core/auth/tools.js";
import { platformTools } from "./domains/platform/tools.js";
import { datalinkTools } from "./domains/datalink/tools.js";
import { billTools } from "./domains/bill/tools.js";
import { runCli } from "./cli/runner.js";
import { redactSensitiveText } from "./cli/printer.js";
@@ -185,7 +186,7 @@ export function createServer(options: { mode?: HoseMcpMode; enabled?: boolean }
}
);
const fineGrainedTools = [...authTools, ...platformTools, ...billTools];
const fineGrainedTools = [...authTools, ...platformTools, ...datalinkTools, ...billTools];
// 注册工具列表
server.setRequestHandler("tools/list", async () => {
@@ -358,6 +359,26 @@ export function createServer(options: { mode?: HoseMcpMode; enabled?: boolean }
};
}
// DataLink 应用/业务对象/记录工具
const datalinkTool = datalinkTools.find((t) => t.name === name);
if (datalinkTool) {
const parsed = datalinkTool.parameters.safeParse(args || {});
if (!parsed.success) {
return {
content: [{ type: "text", text: `参数错误: ${parsed.error.message}` }],
isError: true,
};
}
const ekbClient = await createEkbClient(currentCorp);
const result = await datalinkTool.handler(
{ corp: currentCorp, ekbClient },
parsed.data as never
);
return {
content: [{ type: "text", text: typeof result === "string" ? result : JSON.stringify(result, null, 2) }],
};
}
return {
content: [
{