@@ -106,14 +106,14 @@ function ServerToolsQuery({
106106 workspaceId : string
107107 server : WorkflowMcpServer
108108 workflowId : string
109- onData : ( serverId : string , tool : WorkflowMcpTool | null , isLoading : boolean ) => void
109+ onData : ( serverId : string , tool : WorkflowMcpTool | null ) => void
110110} ) {
111- const { data : tools , isLoading } = useWorkflowMcpTools ( workspaceId , server . id )
111+ const { data : tools } = useWorkflowMcpTools ( workspaceId , server . id )
112112
113113 useEffect ( ( ) => {
114114 const tool = tools ?. find ( ( t ) => t . workflowId === workflowId ) || null
115- onData ( server . id , tool , isLoading )
116- } , [ tools , isLoading , workflowId , server . id , onData ] )
115+ onData ( server . id , tool )
116+ } , [ tools , workflowId , server . id , onData ] )
117117
118118 return null
119119}
@@ -185,31 +185,24 @@ export function McpDeploy({
185185 return null
186186 } , [ toolName ] )
187187
188- const [ serverToolsMap , setServerToolsMap ] = useState <
189- Record < string , { tool : WorkflowMcpTool | null ; isLoading : boolean } >
190- > ( { } )
188+ const [ serverToolsMap , setServerToolsMap ] = useState < Record < string , WorkflowMcpTool | null > > ( { } )
191189
192- const handleServerToolData = useCallback (
193- ( serverId : string , tool : WorkflowMcpTool | null , isLoading : boolean ) => {
194- setServerToolsMap ( ( prev ) => {
195- const existing = prev [ serverId ]
196- if ( existing ?. tool ?. id === tool ?. id && existing ?. isLoading === isLoading ) {
197- return prev
198- }
199- return {
200- ...prev ,
201- [ serverId ] : { tool, isLoading } ,
202- }
203- } )
204- } ,
205- [ ]
206- )
190+ const handleServerToolData = useCallback ( ( serverId : string , tool : WorkflowMcpTool | null ) => {
191+ setServerToolsMap ( ( prev ) => {
192+ if ( prev [ serverId ] ?. id === tool ?. id ) {
193+ return prev
194+ }
195+ return {
196+ ...prev ,
197+ [ serverId ] : tool ,
198+ }
199+ } )
200+ } , [ ] )
207201
208202 const selectedServerIds = useMemo ( ( ) => {
209203 const ids : string [ ] = [ ]
210204 for ( const server of servers ) {
211- const toolInfo = serverToolsMap [ server . id ]
212- if ( toolInfo ?. tool ) {
205+ if ( serverToolsMap [ server . id ] ) {
213206 ids . push ( server . id )
214207 }
215208 }
@@ -229,19 +222,19 @@ export function McpDeploy({
229222 if ( savedValues || ( isLoadingDeployedState && ! deployedState ) ) return
230223
231224 for ( const server of servers ) {
232- const toolInfo = serverToolsMap [ server . id ]
233- if ( toolInfo ?. tool ) {
234- const initialToolName = toolInfo . tool . toolName
235- const initialToolDescription = toolInfo . tool . toolDescription ?? ''
236- const storedOverrides = toolInfo . tool . parameterDescriptionOverrides ?? { }
225+ const existingTool = serverToolsMap [ server . id ]
226+ if ( existingTool ) {
227+ const initialToolName = existingTool . toolName
228+ const initialToolDescription = existingTool . toolDescription ?? ''
229+ const storedOverrides = existingTool . parameterDescriptionOverrides ?? { }
237230 // Tools created before the overrides column kept custom descriptions only in the stored
238231 // schema; derive them (dropping field-name and Start-block-default values) so opening and
239232 // saving the form never wipes descriptions that were never migrated to the column.
240233 const initialOverrides =
241234 Object . keys ( storedOverrides ) . length > 0
242235 ? storedOverrides
243236 : extractDescriptionOverrides (
244- toolInfo . tool . parameterSchema ,
237+ existingTool . parameterSchema ,
245238 generateToolInputSchema ( inputFormat )
246239 )
247240
@@ -316,7 +309,7 @@ export function McpDeploy({
316309 setSaveErrors ( [ ] )
317310 try {
318311 const errors : string [ ] = [ ]
319- const addedEntries : Record < string , { tool : WorkflowMcpTool ; isLoading : boolean } > = { }
312+ const addedEntries : Record < string , WorkflowMcpTool > = { }
320313 const removedIds : string [ ] = [ ]
321314
322315 for ( const serverId of toAdd ) {
@@ -330,7 +323,7 @@ export function McpDeploy({
330323 toolDescription : toolDescriptionForSave ,
331324 parameterDescriptionOverrides,
332325 } )
333- addedEntries [ serverId ] = { tool : addedTool , isLoading : false }
326+ addedEntries [ serverId ] = addedTool
334327 onAddedToServer ?.( )
335328 logger . info ( `Added workflow ${ workflowId } as tool to server ${ serverId } ` )
336329 } catch ( error ) {
@@ -347,15 +340,15 @@ export function McpDeploy({
347340 }
348341
349342 for ( const serverId of toRemove ) {
350- const toolInfo = serverToolsMap [ serverId ]
351- if ( ! toolInfo ?. tool ) continue
343+ const existingTool = serverToolsMap [ serverId ]
344+ if ( ! existingTool ) continue
352345
353346 setPendingServerChanges ( ( prev ) => new Set ( prev ) . add ( serverId ) )
354347 try {
355348 await deleteToolMutation . mutateAsync ( {
356349 workspaceId,
357350 serverId,
358- toolId : toolInfo . tool . id ,
351+ toolId : existingTool . id ,
359352 } )
360353 removedIds . push ( serverId )
361354 } catch ( error ) {
@@ -374,14 +367,14 @@ export function McpDeploy({
374367 if ( shouldUpdateExisting ) {
375368 for ( const serverId of selectedServerIdsForForm ) {
376369 if ( toAdd . has ( serverId ) ) continue
377- const toolInfo = serverToolsMap [ serverId ]
378- if ( ! toolInfo ?. tool ) continue
370+ const existingTool = serverToolsMap [ serverId ]
371+ if ( ! existingTool ) continue
379372
380373 try {
381374 await updateToolMutation . mutateAsync ( {
382375 workspaceId,
383376 serverId,
384- toolId : toolInfo . tool . id ,
377+ toolId : existingTool . id ,
385378 toolName : toolName . trim ( ) ,
386379 toolDescription : toolDescriptionForSave ,
387380 parameterDescriptionOverrides,
@@ -400,7 +393,7 @@ export function McpDeploy({
400393 toolDescription : toolDescriptionForSave ,
401394 parameterDescriptionOverrides,
402395 } )
403- addedEntries [ serverId ] = { tool : recreated , isLoading : false }
396+ addedEntries [ serverId ] = recreated
404397 } catch ( recreateError ) {
405398 errors . push ( `Failed to update on ${ serverName } ` )
406399 logger . error ( `Failed to re-add tool on server ${ serverId } :` , recreateError )
0 commit comments