fix tools when auth is disabled + log notifications to console

This commit is contained in:
dswbx
2025-08-09 15:07:20 +02:00
parent ad04d5273e
commit 822e6fd644
5 changed files with 27 additions and 7 deletions

View File

@@ -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(

View File

@@ -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({