MCPcopy Index your code
hub / github.com/simstudioai/sim / removeMcpToolsForWorkflow

Function removeMcpToolsForWorkflow

apps/sim/lib/mcp/workflow-mcp-sync.ts:330–362  ·  view source on GitHub ↗
(
  workflowId: string,
  requestId: string,
  tx?: DbOrTx,
  throwOnError = false
)

Source from the content-addressed store, hash-verified

328 * transaction owner notifies after commit using the returned server ids.
329 */
330export async function removeMcpToolsForWorkflow(
331 workflowId: string,
332 requestId: string,
333 tx?: DbOrTx,
334 throwOnError = false
335): Promise<Array<{ serverId: string }>> {
336 if (!tx) {
337 const tools = await db.transaction((transaction) =>
338 removeMcpToolsForWorkflow(workflowId, requestId, transaction, throwOnError)
339 )
340 notifyMcpToolServers(tools)
341 return tools
342 }
343
344 try {
345 const tools = await collectWorkflowMcpToolServerIds(tx, workflowId)
346
347 if (tools.length === 0) return []
348
349 for (const { serverId } of tools) {
350 await acquireWorkflowMcpServerLock(tx, serverId)
351 }
352
353 await tx.delete(workflowMcpTool).where(eq(workflowMcpTool.workflowId, workflowId))
354 logger.info(`[${requestId}] Removed MCP tools for workflow: ${workflowId}`)
355
356 return tools
357 } catch (error) {
358 logger.error(`[${requestId}] Error removing MCP tools:`, error)
359 if (throwOnError) throw error
360 return []
361 }
362}
363
364/**
365 * Publish pubsub events for each unique server affected by a tool change.

Callers 2

syncMcpToolsForWorkflowFunction · 0.85

Calls 7

notifyMcpToolServersFunction · 0.85
infoMethod · 0.80
errorMethod · 0.80
deleteMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected