From bc1ab0f6d3cef28bda9a977d5f9eab9fc0c5546f Mon Sep 17 00:00:00 2001 From: dswbx Date: Wed, 20 Aug 2025 18:26:48 +0200 Subject: [PATCH] mcp: sorting tools, fixed cloudflare example, fixed some styling --- app/build.cli.ts | 2 +- app/src/modules/mcp/system-mcp.ts | 10 ++++-- app/src/ui/components/display/Empty.tsx | 3 ++ app/src/ui/routes/data/data.$entity.index.tsx | 2 +- app/src/ui/routes/tools/mcp/mcp.tsx | 31 ++++++++++++++++--- app/src/ui/routes/tools/mcp/tools.tsx | 20 +++++++----- examples/cloudflare-worker/bknd.config.ts | 9 +++--- examples/cloudflare-worker/config.ts | 7 +++++ examples/cloudflare-worker/src/index.ts | 2 +- examples/cloudflare-worker/tsconfig.json | 1 + 10 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 examples/cloudflare-worker/config.ts diff --git a/app/build.cli.ts b/app/build.cli.ts index ff20803..999a6a1 100644 --- a/app/build.cli.ts +++ b/app/build.cli.ts @@ -25,7 +25,7 @@ const result = await Bun.build({ target: "node", outdir: "./dist/cli", env: "PUBLIC_*", - minify: false, + minify: true, external: ["jsonv-ts", "jsonv-ts/*"], define: { __isDev: "0", diff --git a/app/src/modules/mcp/system-mcp.ts b/app/src/modules/mcp/system-mcp.ts index c1ab148..bd278db 100644 --- a/app/src/modules/mcp/system-mcp.ts +++ b/app/src/modules/mcp/system-mcp.ts @@ -16,9 +16,13 @@ export function getSystemMcp(app: App) { ...middlewareServer.tools, // tools added from ctx ...app.modules.ctx().mcp.tools, - // tools from app schema - ...nodes.flatMap((n) => n.schema.getTools(n)), - ]; + ].sort((a, b) => a.name.localeCompare(b.name)); + + // tools from app schema + tools.push( + ...nodes.flatMap((n) => n.schema.getTools(n)).sort((a, b) => a.name.localeCompare(b.name)), + ); + const resources = [...middlewareServer.resources, ...app.modules.ctx().mcp.resources]; return new McpServer( diff --git a/app/src/ui/components/display/Empty.tsx b/app/src/ui/components/display/Empty.tsx index 39bf4f2..9bb7b0d 100644 --- a/app/src/ui/components/display/Empty.tsx +++ b/app/src/ui/components/display/Empty.tsx @@ -8,6 +8,7 @@ export type EmptyProps = { primary?: ButtonProps; secondary?: ButtonProps; className?: string; + children?: React.ReactNode; }; export const Empty: React.FC = ({ Icon = undefined, @@ -16,6 +17,7 @@ export const Empty: React.FC = ({ primary, secondary, className, + children, }) => (
@@ -27,6 +29,7 @@ export const Empty: React.FC = ({
{secondary &&
diff --git a/app/src/ui/routes/data/data.$entity.index.tsx b/app/src/ui/routes/data/data.$entity.index.tsx index 09a604e..ff3c057 100644 --- a/app/src/ui/routes/data/data.$entity.index.tsx +++ b/app/src/ui/routes/data/data.$entity.index.tsx @@ -124,7 +124,7 @@ function DataEntityListImpl({ params }) { } > - {entity.label} + {entity.label}
diff --git a/app/src/ui/routes/tools/mcp/mcp.tsx b/app/src/ui/routes/tools/mcp/mcp.tsx index 8b46657..c63e3b7 100644 --- a/app/src/ui/routes/tools/mcp/mcp.tsx +++ b/app/src/ui/routes/tools/mcp/mcp.tsx @@ -5,11 +5,15 @@ import { TbWorld } from "react-icons/tb"; import { McpIcon } from "./components/mcp-icon"; import { useBknd } from "ui/client/bknd"; import { Empty } from "ui/components/display/Empty"; +import { Button } from "ui/components/buttons/Button"; +import { appShellStore } from "ui/store"; export default function ToolsMcp() { const { config, options } = useBknd(); const feature = useMcpStore((state) => state.feature); const setFeature = useMcpStore((state) => state.setFeature); + const content = useMcpStore((state) => state.content); + const openSidebar = appShellStore((store) => store.toggleSidebar("default")); if (!config.server.mcp.enabled) { return ( @@ -25,15 +29,20 @@ export default function ToolsMcp() {
- MCP UI -
+ + MCP UI + +
- - {window.location.origin + "/mcp"} - +
+ + {window.location.origin + "/mcp"} + +
+
@@ -50,6 +59,18 @@ export default function ToolsMcp() { {feature === "tools" && } + + {!content && ( + + + + )}
); diff --git a/app/src/ui/routes/tools/mcp/tools.tsx b/app/src/ui/routes/tools/mcp/tools.tsx index 1855937..50cdd57 100644 --- a/app/src/ui/routes/tools/mcp/tools.tsx +++ b/app/src/ui/routes/tools/mcp/tools.tsx @@ -6,15 +6,14 @@ import { TbHistory, TbHistoryOff, TbRefresh } from "react-icons/tb"; import { IconButton } from "ui/components/buttons/IconButton"; import { JsonViewer, JsonViewerTabs, type JsonViewerTabsRef } from "ui/components/code/JsonViewer"; import { twMerge } from "ui/elements/mocks/tailwind-merge"; -import { - Form, -} from "ui/components/form/json-schema-form"; +import { Form } from "ui/components/form/json-schema-form"; import { Button } from "ui/components/buttons/Button"; import * as Formy from "ui/components/form/Formy"; -import { JsonEditor } from "ui/components/code/JsonEditor"; +import { appShellStore } from "ui/store"; export function Sidebar({ open, toggle }) { const client = getClient(); + const closeSidebar = appShellStore((store) => store.closeSidebar("default")); const tools = useMcpStore((state) => state.tools); const setTools = useMcpStore((state) => state.setTools); const setContent = useMcpStore((state) => state.setContent); @@ -56,7 +55,7 @@ export function Sidebar({ open, toggle }) { />