LibreChat/client/src/store/mcp.ts
Danny Avila 751c2e1d17
👻 refactor: LocalStorage Cleanup and MCP State Optimization (#9528)
* 👻 refactor: MCP Select State with Jotai Atoms

* refactor: Implement timestamp management for ChatArea localStorage entries

* refactor: Integrate MCP Server Manager into BadgeRow context and components to avoid double-calling within BadgeRow

* refactor: add try/catch

* chore: remove comment
2025-09-09 17:32:10 -04:00

20 lines
759 B
TypeScript

import { atomFamily, atomWithStorage } from 'jotai/utils';
import { Constants, LocalStorageKeys } from 'librechat-data-provider';
/**
* Creates a storage atom for MCP values per conversation
* Uses atomFamily to create unique atoms for each conversation ID
*/
export const mcpValuesAtomFamily = atomFamily((conversationId: string | null) => {
const key = conversationId ?? Constants.NEW_CONVO;
const storageKey = `${LocalStorageKeys.LAST_MCP_}${key}`;
return atomWithStorage<string[]>(storageKey, [], undefined, { getOnInit: true });
});
/**
* Global storage atom for MCP pinned state (shared across all conversations)
*/
export const mcpPinnedAtom = atomWithStorage<boolean>(LocalStorageKeys.PIN_MCP_, true, undefined, {
getOnInit: true,
});