mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
added mcp ui as tool
This commit is contained in:
20
app/src/ui/routes/tools/mcp/utils.ts
Normal file
20
app/src/ui/routes/tools/mcp/utils.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { McpClient, type McpClientConfig } from "jsonv-ts/mcp";
|
||||
import { Draft2019 } from "json-schema-library";
|
||||
|
||||
const clients = new Map<string, McpClient>();
|
||||
|
||||
export function getClient(
|
||||
{ url, ...opts }: McpClientConfig = { url: window.location.origin + "/mcp" },
|
||||
) {
|
||||
if (!clients.has(String(url))) {
|
||||
clients.set(String(url), new McpClient({ url, ...opts }));
|
||||
}
|
||||
return clients.get(String(url))!;
|
||||
}
|
||||
|
||||
export function getTemplate(schema: object) {
|
||||
if (!schema || schema === undefined || schema === null) return undefined;
|
||||
|
||||
const lib = new Draft2019(schema);
|
||||
return lib.getTemplate(undefined, schema);
|
||||
}
|
||||
Reference in New Issue
Block a user