🧩 refactor: Decouple MCP Config from Startup Config (#10689)

* Decouple mcp config from start up config

* Chore: Work on AI Review and Copilot Comments

- setRawConfig is not needed since the private raw config is not needed any more
- !!serversLoading bug fixed
- added unit tests for route /api/mcp/servers
- copilot comments addressed

* chore: remove comments

* chore: rename data-provider dir for MCP

* chore: reorganize mcp specific query hooks

* fix: consolidate imports for MCP server manager

* chore: add dev-staging branch to frontend review workflow triggers

* feat: add GitHub Actions workflow for building and pushing Docker images to GitHub Container Registry and Docker Hub

* fix: update label for tag input in BookmarkForm tests to improve clarity

---------

Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com>
Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
Atef Bellaaj 2025-11-26 21:26:40 +01:00 committed by Danny Avila
parent 477a80c22a
commit 8b5f34047f
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
36 changed files with 548 additions and 301 deletions

View file

@ -0,0 +1 @@
export * from './queries';

View file

@ -0,0 +1,44 @@
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 = <TData = t.MCPServersListResponse>(
config?: UseQueryOptions<t.MCPServersListResponse, unknown, TData>,
): QueryObserverResult<TData> => {
return useQuery<t.MCPServersListResponse, unknown, TData>(
[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 = <TData = t.MCPServersResponse>(
config?: UseQueryOptions<t.MCPServersResponse, unknown, TData>,
): QueryObserverResult<TData> => {
return useQuery<t.MCPServersResponse, unknown, TData>(
[QueryKeys.mcpTools],
() => dataService.getMCPTools(),
{
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
staleTime: 5 * 60 * 1000, // 5 minutes
...config,
},
);
};

View file

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

View file

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