mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
init mcp tools test
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { CliCommand } from "cli/types";
|
||||
import { makeAppFromEnv } from "../run";
|
||||
import { getSystemMcp } from "modules/server/system-mcp";
|
||||
import { getSystemMcp } from "modules/mcp/system-mcp";
|
||||
import { $console } from "bknd/utils";
|
||||
import { stdioTransport } from "jsonv-ts/mcp";
|
||||
|
||||
|
||||
@@ -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");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
openAPISpecs,
|
||||
mcpTool,
|
||||
mcp as mcpMiddleware,
|
||||
isNode,
|
||||
} from "bknd/utils";
|
||||
import type { Context, Hono } from "hono";
|
||||
import { Controller } from "modules/Controller";
|
||||
@@ -28,7 +29,7 @@ import {
|
||||
import * as SystemPermissions from "modules/permissions";
|
||||
import { getVersion } from "core/env";
|
||||
import type { Module } from "modules/Module";
|
||||
import { getSystemMcp } from "./system-mcp";
|
||||
import { getSystemMcp } from "modules/mcp/system-mcp";
|
||||
|
||||
export type ConfigUpdate<Key extends ModuleKey = ModuleKey> = {
|
||||
success: true;
|
||||
@@ -94,6 +95,8 @@ export class SystemController extends Controller {
|
||||
},
|
||||
endpoint: {
|
||||
path: "/mcp",
|
||||
// @ts-ignore
|
||||
_init: isNode() ? { duplex: "half" } : {},
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -365,7 +368,10 @@ export class SystemController extends Controller {
|
||||
}),
|
||||
(c) =>
|
||||
c.json({
|
||||
version: c.get("app")?.version(),
|
||||
version: {
|
||||
config: c.get("app")?.version(),
|
||||
bknd: getVersion(),
|
||||
},
|
||||
runtime: getRuntimeKey(),
|
||||
connection: {
|
||||
name: this.app.em.connection.name,
|
||||
|
||||
Reference in New Issue
Block a user