MCPcopy
hub / github.com/simstudioai/sim / execute

Function execute

apps/sim/lib/copilot/tools/server/blocks/get-trigger-blocks.ts:20–52  ·  view source on GitHub ↗
(_args: unknown, context?: { userId: string; workspaceId?: string })

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 7

createLoggerFunction · 0.90
getUserPermissionConfigFunction · 0.90
getAllBlocksFunction · 0.90
debugMethod · 0.80
parseMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected