MCPcopy Create free account
hub / github.com/simstudioai/sim / collectWorkflowMcpToolServerIds

Function collectWorkflowMcpToolServerIds

apps/sim/lib/mcp/workflow-mcp-sync.ts:86–110  ·  view source on GitHub ↗
(
  tx: DbOrTx,
  workflowId: string
)

Source from the content-addressed store, hash-verified

84}
85
86async function collectWorkflowMcpToolServerIds(
87 tx: DbOrTx,
88 workflowId: string
89): Promise<Array<{ serverId: string }>> {
90 const serverIds = new Set<string>()
91 let afterToolId: string | undefined
92
93 while (true) {
94 const page = await listWorkflowMcpToolSyncPage(tx, workflowId, afterToolId)
95 if (page.length === 0) break
96
97 const pageTools = page.slice(0, MCP_SYNC_TOOLS_PAGE_SIZE)
98 for (const tool of pageTools) {
99 serverIds.add(tool.serverId)
100 if (serverIds.size > MAX_MCP_SERVERS_PER_WORKFLOW) {
101 throw new WorkflowMcpServerFanoutError(workflowId)
102 }
103 }
104
105 if (page.length <= MCP_SYNC_TOOLS_PAGE_SIZE) break
106 afterToolId = pageTools.at(-1)?.id
107 }
108
109 return [...serverIds].sort().map((serverId) => ({ serverId }))
110}
111
112/**
113 * Generate MCP tool parameter schema from workflow blocks.

Callers 2

syncMcpToolsForWorkflowFunction · 0.85

Calls 2

addMethod · 0.45

Tested by

no test coverage detected