(_args: unknown, context?: { userId: string; workspaceId?: string })
| 18 | inputSchema: GetTriggerBlocksInput, |
| 19 | outputSchema: GetTriggerBlocksResult, |
| 20 | async execute(_args: unknown, context?: { userId: string; workspaceId?: string }) { |
| 21 | const logger = createLogger('GetTriggerBlocksServerTool') |
| 22 | logger.debug('Executing get_trigger_blocks') |
| 23 | |
| 24 | const permissionConfig = |
| 25 | context?.userId && context?.workspaceId |
| 26 | ? await getUserPermissionConfig(context.userId, context.workspaceId) |
| 27 | : null |
| 28 | const allowedIntegrations = |
| 29 | permissionConfig?.allowedIntegrations ?? getAllowedIntegrationsFromEnv() |
| 30 | |
| 31 | const triggerBlockIds: string[] = [] |
| 32 | |
| 33 | for (const blockConfig of getAllBlocks()) { |
| 34 | const blockType = blockConfig.type |
| 35 | if (blockConfig.hideFromToolbar) continue |
| 36 | if (allowedIntegrations != null && !allowedIntegrations.includes(blockType.toLowerCase())) |
| 37 | continue |
| 38 | |
| 39 | if (blockConfig.category === 'triggers') { |
| 40 | triggerBlockIds.push(blockType) |
| 41 | } else if ('triggerAllowed' in blockConfig && blockConfig.triggerAllowed === true) { |
| 42 | triggerBlockIds.push(blockType) |
| 43 | } else if (blockConfig.subBlocks?.some((subBlock) => subBlock.mode === 'trigger')) { |
| 44 | triggerBlockIds.push(blockType) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | triggerBlockIds.sort() |
| 49 | |
| 50 | logger.debug(`Found ${triggerBlockIds.length} trigger blocks`) |
| 51 | return GetTriggerBlocksResult.parse({ triggerBlockIds }) |
| 52 | }, |
| 53 | } |
nothing calls this directly
no test coverage detected