(tools: Array<{ serverId: string }>)
| 366 | * Resolves workspace IDs from the server table so callers don't need to pass them. |
| 367 | */ |
| 368 | export function notifyMcpToolServers(tools: Array<{ serverId: string }>): void { |
| 369 | if (!mcpPubSub) return |
| 370 | |
| 371 | const uniqueServerIds = [...new Set(tools.map((t) => t.serverId))] |
| 372 | |
| 373 | void (async () => { |
| 374 | try { |
| 375 | const servers = await db |
| 376 | .select({ id: workflowMcpServer.id, workspaceId: workflowMcpServer.workspaceId }) |
| 377 | .from(workflowMcpServer) |
| 378 | .where( |
| 379 | and(inArray(workflowMcpServer.id, uniqueServerIds), isNull(workflowMcpServer.deletedAt)) |
| 380 | ) |
| 381 | |
| 382 | for (const server of servers) { |
| 383 | mcpPubSub.publishWorkflowToolsChanged({ |
| 384 | serverId: server.id, |
| 385 | workspaceId: server.workspaceId, |
| 386 | }) |
| 387 | } |
| 388 | } catch (error) { |
| 389 | logger.error('Error notifying affected servers:', error) |
| 390 | } |
| 391 | })() |
| 392 | } |
no test coverage detected