2025-09-21 07:56:40 -04:00
|
|
|
/**
|
|
|
|
|
* Dedicated queries for MCP (Model Context Protocol) tools
|
|
|
|
|
* Decoupled from regular LibreChat tools
|
|
|
|
|
*/
|
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
import { QueryKeys, dataService } from 'librechat-data-provider';
|
|
|
|
|
import type { UseQueryOptions, QueryObserverResult } from '@tanstack/react-query';
|
2025-09-21 20:19:51 -04:00
|
|
|
import type { MCPServersResponse } from 'librechat-data-provider';
|
2025-09-21 07:56:40 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hook for fetching MCP-specific tools
|
|
|
|
|
* @param config - React Query configuration
|
2025-09-21 20:19:51 -04:00
|
|
|
* @returns MCP servers with their tools
|
2025-09-21 07:56:40 -04:00
|
|
|
*/
|
2025-09-21 20:19:51 -04:00
|
|
|
export const useMCPToolsQuery = <TData = MCPServersResponse>(
|
|
|
|
|
config?: UseQueryOptions<MCPServersResponse, unknown, TData>,
|
2025-09-21 07:56:40 -04:00
|
|
|
): QueryObserverResult<TData> => {
|
2025-09-21 20:19:51 -04:00
|
|
|
return useQuery<MCPServersResponse, unknown, TData>(
|
2025-09-21 07:56:40 -04:00
|
|
|
[QueryKeys.mcpTools],
|
|
|
|
|
() => dataService.getMCPTools(),
|
|
|
|
|
{
|
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
|
refetchOnMount: false,
|
|
|
|
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
|
|
|
...config,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
};
|