@@ -36,17 +36,11 @@ export interface UseMcpToolsResult {
3636 getToolsByServer : ( serverId : string ) => McpToolForUI [ ]
3737}
3838
39- /**
40- * Hook for accessing MCP tools with TanStack Query
41- * Provides backward-compatible API with the old useState-based implementation
42- */
4339export function useMcpTools ( workspaceId : string ) : UseMcpToolsResult {
4440 const queryClient = useQueryClient ( )
4541
46- // Use TanStack Query hook for data fetching with caching
4742 const { data : mcpToolsData = [ ] , isLoading, error : queryError } = useMcpToolsQuery ( workspaceId )
4843
49- // Transform raw tool data to UI-friendly format with memoization
5044 const mcpTools = useMemo < McpToolForUI [ ] > ( ( ) => {
5145 return mcpToolsData . map ( ( tool ) => ( {
5246 id : createMcpToolId ( tool . serverId , tool . name ) ,
@@ -61,7 +55,6 @@ export function useMcpTools(workspaceId: string): UseMcpToolsResult {
6155 } ) )
6256 } , [ mcpToolsData ] )
6357
64- // Refresh tools by invalidating the query cache
6558 const refreshTools = useCallback (
6659 async ( forceRefresh = false ) => {
6760 if ( ! workspaceId ) {
@@ -71,7 +64,6 @@ export function useMcpTools(workspaceId: string): UseMcpToolsResult {
7164
7265 logger . info ( 'Refreshing MCP tools' , { forceRefresh, workspaceId } )
7366
74- // Invalidate the query to trigger a refetch
7567 await queryClient . invalidateQueries ( {
7668 queryKey : mcpKeys . tools ( workspaceId ) ,
7769 refetchType : forceRefresh ? 'active' : 'all' ,
@@ -80,15 +72,13 @@ export function useMcpTools(workspaceId: string): UseMcpToolsResult {
8072 [ workspaceId , queryClient ]
8173 )
8274
83- // Get tool by ID
8475 const getToolById = useCallback (
8576 ( toolId : string ) : McpToolForUI | undefined => {
8677 return mcpTools . find ( ( tool ) => tool . id === toolId )
8778 } ,
8879 [ mcpTools ]
8980 )
9081
91- // Get all tools for a specific server
9282 const getToolsByServer = useCallback (
9383 ( serverId : string ) : McpToolForUI [ ] => {
9484 return mcpTools . filter ( ( tool ) => tool . serverId === serverId )
0 commit comments