initialized mcp support

This commit is contained in:
dswbx
2025-08-02 16:33:05 +02:00
parent bd48bb7a18
commit ffbb61d58a
19 changed files with 468 additions and 68 deletions

View File

@@ -0,0 +1,42 @@
import { describe, it, expect } from "bun:test";
import { makeAppFromEnv } from "cli/commands/run";
import { createApp } from "core/test/utils";
import { ObjectToolSchema } from "modules/mcp";
import { s } from "bknd/utils";
describe("mcp", () => {
it("...", async () => {
const app = createApp({
initialConfig: {
auth: {
enabled: true,
},
},
});
await app.build();
const appConfig = app.modules.configs();
const { version, ...appSchema } = app.getSchema();
const schema = s.strictObject(appSchema);
const nodes = [...schema.walk({ data: appConfig })]
.map((n) => {
const path = n.instancePath.join(".");
if (path.startsWith("auth")) {
console.log("schema", n.instancePath, n.schema.constructor.name);
if (path === "auth.jwt") {
//console.log("jwt", n.schema.IS_MCP);
}
}
return n;
})
.filter((n) => n.schema instanceof ObjectToolSchema) as s.Node<ObjectToolSchema>[];
const tools = nodes.flatMap((n) => n.schema.getTools(n));
console.log(
"tools",
tools.map((t) => t.name),
);
});
});