added getMcpClient to app

This commit is contained in:
dswbx
2025-08-15 10:27:05 +02:00
parent deb8aacca4
commit 5c28511fe6
4 changed files with 32 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
import type { CreateUserPayload } from "auth/AppAuth";
import { $console } from "bknd/utils";
import { $console, McpClient } from "bknd/utils";
import { Event } from "core/events";
import type { em as prototypeEm } from "data/prototype";
import { Connection } from "data/connection/Connection";
@@ -268,6 +268,17 @@ export class App<C extends Connection = Connection, Options extends AppOptions =
return new Api({ host: "http://localhost", ...(options ?? {}), fetcher });
}
getMcpClient() {
if (!this.mcp) {
throw new Error("MCP is not enabled");
}
return new McpClient({
url: "http://localhost/mcp",
fetch: this.server.request,
});
}
async onUpdated<Module extends keyof Modules>(module: Module, config: ModuleConfigs[Module]) {
// if the EventManager was disabled, we assume we shouldn't
// respond to events, such as "onUpdated".