mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
feat: add local auth support if api storage provided
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { McpClient, type McpClientConfig } from "jsonv-ts/mcp";
|
||||
import { useApi } from "bknd/client";
|
||||
import { useBknd } from "ui/client/bknd";
|
||||
|
||||
const clients = new Map<string, McpClient>();
|
||||
@@ -12,5 +13,14 @@ export function getClient(opts: McpClientConfig) {
|
||||
|
||||
export function useMcpClient() {
|
||||
const { config } = useBknd();
|
||||
return getClient({ url: window.location.origin + config.server.mcp.path });
|
||||
const api = useApi();
|
||||
const token = api.getAuthState().token;
|
||||
const headers =
|
||||
api.token_transport === "header" && token ? { Authorization: `Bearer ${token}` } : undefined;
|
||||
|
||||
return getClient({
|
||||
url: window.location.origin + config.server.mcp.path,
|
||||
fetch: api.fetcher,
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useBrowserTitle } from "ui/hooks/use-browser-title";
|
||||
export default function ToolsMcp() {
|
||||
useBrowserTitle(["MCP UI"]);
|
||||
|
||||
const { config, options } = useBknd();
|
||||
const { config } = useBknd();
|
||||
const feature = useMcpStore((state) => state.feature);
|
||||
const setFeature = useMcpStore((state) => state.setFeature);
|
||||
const content = useMcpStore((state) => state.content);
|
||||
|
||||
Reference in New Issue
Block a user