( tx: DbOrTx, workflowId: string )
| 84 | } |
| 85 | |
| 86 | async 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. |
no test coverage detected