🧰 refactor: Decouple MCP Tools from System Tools (#9748)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run

This commit is contained in:
Danny Avila 2025-09-21 07:56:40 -04:00 committed by GitHub
parent 9d2aba5df5
commit 386900fb4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 1032 additions and 1195 deletions

View file

@ -11,5 +11,6 @@ export * from './connection';
export * from './mutations';
export * from './prompts';
export * from './queries';
export * from './mcp';
export * from './roles';
export * from './tags';

View file

@ -0,0 +1,29 @@
/**
* 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';
import type { TPlugin } from 'librechat-data-provider';
/**
* Hook for fetching MCP-specific tools
* @param config - React Query configuration
* @returns MCP tools grouped by server
*/
export const useMCPToolsQuery = <TData = TPlugin[]>(
config?: UseQueryOptions<TPlugin[], unknown, TData>,
): QueryObserverResult<TData> => {
return useQuery<TPlugin[], unknown, TData>(
[QueryKeys.mcpTools],
() => dataService.getMCPTools(),
{
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
staleTime: 5 * 60 * 1000, // 5 minutes
...config,
},
);
};

View file

@ -178,7 +178,8 @@ export const useConversationTagsQuery = (
*/
/**
* Hook for getting all available tools for Assistants
* Hook for getting available LibreChat tools (excludes MCP tools)
* For MCP tools, use `useMCPToolsQuery` from mcp-queries.ts
*/
export const useAvailableToolsQuery = <TData = t.TPlugin[]>(
endpoint: t.AssistantsEndpoint | EModelEndpoint.agents,