mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
fix tools when auth is disabled + log notifications to console
This commit is contained in:
@@ -121,9 +121,10 @@ export class ModuleHelper {
|
||||
invariant(c.context.app, "app is not available in mcp context");
|
||||
invariant(c.raw instanceof Request, "request is not available in mcp context");
|
||||
|
||||
const user = await c.context.app.module.auth.authenticator.resolveAuthFromRequest(
|
||||
c.raw as Request,
|
||||
);
|
||||
const auth = c.context.app.module.auth;
|
||||
if (!auth.enabled) return;
|
||||
|
||||
const user = await auth.authenticator?.resolveAuthFromRequest(c.raw as Request);
|
||||
|
||||
if (!this.ctx.guard.granted(permission, user)) {
|
||||
throw new Exception(
|
||||
|
||||
@@ -64,6 +64,25 @@ export class SystemController extends Controller {
|
||||
this.registerMcp();
|
||||
|
||||
const mcpServer = getSystemMcp(app);
|
||||
mcpServer.onNotification((message) => {
|
||||
if (message.method === "notification/message") {
|
||||
const consoleMap = {
|
||||
emergency: "error",
|
||||
alert: "error",
|
||||
critical: "error",
|
||||
error: "error",
|
||||
warning: "warn",
|
||||
notice: "log",
|
||||
info: "info",
|
||||
debug: "debug",
|
||||
};
|
||||
|
||||
const level = consoleMap[message.params.level];
|
||||
if (!level) return;
|
||||
|
||||
$console[level](message.params.message);
|
||||
}
|
||||
});
|
||||
|
||||
app.server.use(
|
||||
mcpMiddleware({
|
||||
|
||||
Reference in New Issue
Block a user