Skip to main content
Glama
dashboard.ts1.81 kB
import { create } from "zustand"; import { useShallow } from "zustand/react/shallow"; export const DashboardTabName = { Agents: "agents", MCPX: "mcpx", Servers: "servers", Tools: "tools", } as const; export type DashboardTab = (typeof DashboardTabName)[keyof typeof DashboardTabName]; interface DashboardActions { reset: () => void; setCurrentTab: ( tab: DashboardTab, options?: { setSearch?: { agents?: string; servers?: string } }, ) => void; setSearchAgentsValue: (value: string) => void; setSearchServersValue: (value: string) => void; toggleDiagramExpansion: () => void; } interface DashboardState { currentTab: DashboardTab; isDiagramExpanded: boolean; searchAgentsValue: string; searchServersValue: string; } export type DashboardStore = DashboardState & DashboardActions; const initialState: DashboardState = { currentTab: DashboardTabName.MCPX, // Default to MCPX tab isDiagramExpanded: true, // Default to expanded state searchAgentsValue: "", searchServersValue: "", }; const dashboardStore = create<DashboardStore>((set) => ({ ...initialState, reset: () => set({ ...initialState }), setCurrentTab: (tab, options) => { set((state) => ({ currentTab: tab, searchAgentsValue: options?.setSearch?.agents ?? state.searchAgentsValue, searchServersValue: options?.setSearch?.servers ?? state.searchServersValue, })); }, setSearchAgentsValue: (value: string) => set({ searchAgentsValue: value }), setSearchServersValue: (value: string) => set({ searchServersValue: value }), toggleDiagramExpansion: () => set((state) => ({ isDiagramExpanded: !state.isDiagramExpanded })), })); export const useDashboardStore = <T>(selector: (state: DashboardStore) => T) => dashboardStore(useShallow(selector));

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TheLunarCompany/lunar'

If you have feedback or need assistance with the MCP directory API, please join our Discord server