import { useQuery, UseQueryOptions, QueryObserverResult } from '@tanstack/react-query'; import { QueryKeys, dataService } from 'librechat-data-provider'; import type * as t from 'librechat-data-provider'; /** * Hook for fetching all accessible MCP servers with permission metadata */ export const useMCPServersQuery = ( config?: UseQueryOptions, ): QueryObserverResult => { return useQuery( [QueryKeys.mcpServers], () => dataService.getMCPServers(), { staleTime: 1000 * 60 * 5, // 5 minutes - data stays fresh longer refetchOnWindowFocus: false, refetchOnReconnect: false, refetchOnMount: false, retry: false, ...config, }, ); }; /** * Hook for fetching MCP-specific tools * @param config - React Query configuration * @returns MCP servers with their tools */ export const useMCPToolsQuery = ( config?: UseQueryOptions, ): QueryObserverResult => { return useQuery( [QueryKeys.mcpTools], () => dataService.getMCPTools(), { refetchOnWindowFocus: false, refetchOnReconnect: false, refetchOnMount: false, staleTime: 5 * 60 * 1000, // 5 minutes ...config, }, ); };