mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-03 00:26:01 +00:00
2de12674d9
* added mcp documentation * added mcp docs
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { create } from "zustand";
|
|
import { combine } from "zustand/middleware";
|
|
|
|
import type { ToolJson } from "jsonv-ts/mcp";
|
|
|
|
const FEATURES = ["tools", "resources"] as const;
|
|
export type Feature = (typeof FEATURES)[number];
|
|
|
|
export const useMcpStore = create(
|
|
combine(
|
|
{
|
|
tools: [] as ToolJson[],
|
|
feature: "tools" as Feature | null,
|
|
content: null as ToolJson | null,
|
|
history: [] as { type: "request" | "response"; data: any }[],
|
|
historyLimit: 50,
|
|
historyVisible: false,
|
|
},
|
|
(set) => ({
|
|
setTools: (tools: ToolJson[]) => set({ tools }),
|
|
setFeature: (feature: Feature) => set({ feature }),
|
|
setContent: (content: ToolJson | null) => set({ content }),
|
|
addHistory: (type: "request" | "response", data: any) =>
|
|
set((state) => ({
|
|
history: [{ type, data }, ...state.history.slice(0, state.historyLimit - 1)],
|
|
})),
|
|
setHistoryLimit: (limit: number) => set({ historyLimit: limit }),
|
|
setHistoryVisible: (visible: boolean) => set({ historyVisible: visible }),
|
|
}),
|
|
),
|
|
);
|