mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
docs: updated mcp tools
This commit is contained in:
@@ -3,11 +3,14 @@ import { createApp } from "bknd/adapter/bun";
|
||||
async function generate() {
|
||||
console.info("Generating MCP documentation...");
|
||||
const app = await createApp({
|
||||
connection: {
|
||||
url: ":memory:",
|
||||
},
|
||||
config: {
|
||||
server: {
|
||||
mcp: {
|
||||
enabled: true,
|
||||
path: "/mcp",
|
||||
path: "/mcp2",
|
||||
},
|
||||
},
|
||||
auth: {
|
||||
@@ -25,9 +28,9 @@ async function generate() {
|
||||
},
|
||||
});
|
||||
await app.build();
|
||||
await app.getMcpClient().ping();
|
||||
|
||||
const res = await app.server.request("/mcp?explain=1");
|
||||
const { tools, resources } = await res.json();
|
||||
const { tools, resources } = app.mcp!.toJSON();
|
||||
await Bun.write("../docs/mcp.json", JSON.stringify({ tools, resources }, null, 2));
|
||||
|
||||
console.info("MCP documentation generated.");
|
||||
|
||||
@@ -311,8 +311,9 @@ export class App<
|
||||
throw new Error("MCP is not enabled");
|
||||
}
|
||||
|
||||
const url = new URL(config.path, "http://localhost").toString();
|
||||
return new McpClient({
|
||||
url: "http://localhost" + config.path,
|
||||
url,
|
||||
fetch: this.server.request,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,12 +70,13 @@ export class SystemController extends Controller {
|
||||
if (!config.mcp.enabled) {
|
||||
return;
|
||||
}
|
||||
const { permission } = this.middlewares;
|
||||
const { permission, auth } = this.middlewares;
|
||||
|
||||
this.registerMcp();
|
||||
|
||||
app.server.all(
|
||||
config.mcp.path,
|
||||
auth(),
|
||||
permission(SystemPermissions.mcp, {}),
|
||||
mcpMiddleware({
|
||||
setup: async () => {
|
||||
|
||||
Reference in New Issue
Block a user