mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-16 15:35:31 +01:00
🧩 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:
parent
477a80c22a
commit
8b5f34047f
36 changed files with 548 additions and 301 deletions
1
client/src/data-provider/MCP/index.ts
Normal file
1
client/src/data-provider/MCP/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from './queries';
|
||||
44
client/src/data-provider/MCP/queries.ts
Normal file
44
client/src/data-provider/MCP/queries.ts
Normal 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,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue