init mcp tools test

This commit is contained in:
dswbx
2025-08-12 08:51:32 +02:00
parent 822e6fd644
commit 2e145bbf95
13 changed files with 233 additions and 51 deletions

View File

@@ -1,6 +1,7 @@
import { createApp as createAppInternal, type CreateAppConfig } from "App";
import { bunSqlite } from "adapter/bun/connection/BunSqliteConnection";
import { Connection } from "data/connection/Connection";
import type { getSystemMcp } from "modules/mcp/system-mcp";
export { App } from "App";
@@ -10,3 +11,17 @@ export function createApp({ connection, ...config }: CreateAppConfig = {}) {
connection: Connection.isConnection(connection) ? connection : bunSqlite(connection as any),
});
}
export function createMcpToolCaller() {
return async (server: ReturnType<typeof getSystemMcp>, name: string, args: any) => {
const res = await server.handle({
jsonrpc: "2.0",
method: "tools/call",
params: {
name,
arguments: args,
},
});
return JSON.parse((res.result as any)?.content?.[0]?.text ?? "null");
};
}