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:
@@ -65,7 +65,7 @@
|
|||||||
"hono": "4.8.3",
|
"hono": "4.8.3",
|
||||||
"json-schema-library": "10.0.0-rc7",
|
"json-schema-library": "10.0.0-rc7",
|
||||||
"json-schema-to-ts": "^3.1.1",
|
"json-schema-to-ts": "^3.1.1",
|
||||||
"jsonv-ts": "^0.7.0",
|
"jsonv-ts": "^0.7.1",
|
||||||
"kysely": "0.27.6",
|
"kysely": "0.27.6",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"oauth4webapi": "^2.11.1",
|
"oauth4webapi": "^2.11.1",
|
||||||
|
|||||||
@@ -121,9 +121,10 @@ export class ModuleHelper {
|
|||||||
invariant(c.context.app, "app is not available in mcp context");
|
invariant(c.context.app, "app is not available in mcp context");
|
||||||
invariant(c.raw instanceof Request, "request 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(
|
const auth = c.context.app.module.auth;
|
||||||
c.raw as Request,
|
if (!auth.enabled) return;
|
||||||
);
|
|
||||||
|
const user = await auth.authenticator?.resolveAuthFromRequest(c.raw as Request);
|
||||||
|
|
||||||
if (!this.ctx.guard.granted(permission, user)) {
|
if (!this.ctx.guard.granted(permission, user)) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
|||||||
@@ -64,6 +64,25 @@ export class SystemController extends Controller {
|
|||||||
this.registerMcp();
|
this.registerMcp();
|
||||||
|
|
||||||
const mcpServer = getSystemMcp(app);
|
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(
|
app.server.use(
|
||||||
mcpMiddleware({
|
mcpMiddleware({
|
||||||
|
|||||||
4
bun.lock
4
bun.lock
@@ -35,7 +35,7 @@
|
|||||||
"hono": "4.8.3",
|
"hono": "4.8.3",
|
||||||
"json-schema-library": "10.0.0-rc7",
|
"json-schema-library": "10.0.0-rc7",
|
||||||
"json-schema-to-ts": "^3.1.1",
|
"json-schema-to-ts": "^3.1.1",
|
||||||
"jsonv-ts": "^0.7.0",
|
"jsonv-ts": "^0.7.1",
|
||||||
"kysely": "0.27.6",
|
"kysely": "0.27.6",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"oauth4webapi": "^2.11.1",
|
"oauth4webapi": "^2.11.1",
|
||||||
@@ -2511,7 +2511,7 @@
|
|||||||
|
|
||||||
"jsonpointer": ["jsonpointer@5.0.1", "", {}, "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ=="],
|
"jsonpointer": ["jsonpointer@5.0.1", "", {}, "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ=="],
|
||||||
|
|
||||||
"jsonv-ts": ["jsonv-ts@0.7.0", "", { "optionalDependencies": { "hono": "*" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-zN5/KMs1WOs+0IbYiZF7mVku4dum8LKP9xv8VqgVm+PBz5VZuU1V8iLQhI991ogUbhGHHlOCwqxnxQUuvCPbQA=="],
|
"jsonv-ts": ["jsonv-ts@0.7.1", "", { "optionalDependencies": { "hono": "*" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-UMqzVRE93NKO/aPROYIbE7yZJxzZ+ab7QaR7Lkxqltkh9ss9c6n8beDxlen71bpsTceLbSxMCbO05r87UMf4JA=="],
|
||||||
|
|
||||||
"jsonwebtoken": ["jsonwebtoken@9.0.2", "", { "dependencies": { "jws": "^3.2.2", "lodash.includes": "^4.3.0", "lodash.isboolean": "^3.0.3", "lodash.isinteger": "^4.0.4", "lodash.isnumber": "^3.0.3", "lodash.isplainobject": "^4.0.6", "lodash.isstring": "^4.0.1", "lodash.once": "^4.0.0", "ms": "^2.1.1", "semver": "^7.5.4" } }, "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ=="],
|
"jsonwebtoken": ["jsonwebtoken@9.0.2", "", { "dependencies": { "jws": "^3.2.2", "lodash.includes": "^4.3.0", "lodash.isboolean": "^3.0.3", "lodash.isinteger": "^4.0.4", "lodash.isnumber": "^3.0.3", "lodash.isplainobject": "^4.0.6", "lodash.isstring": "^4.0.1", "lodash.once": "^4.0.0", "ms": "^2.1.1", "semver": "^7.5.4" } }, "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ=="],
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { serve } from "bknd/adapter/cloudflare";
|
import { serve } from "bknd/adapter/cloudflare";
|
||||||
|
|
||||||
export default serve({
|
export default serve({
|
||||||
mode: "warm",
|
mode: "fresh",
|
||||||
d1: {
|
d1: {
|
||||||
session: true,
|
session: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user