AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { Permission } from '@activepieces/core-utils'
import { McpToolContext, McpToolDefinition } from '@activepieces/shared'
import { FastifyBaseLogger } from 'fastify'
import { z } from 'zod'
import { executeFlowTest } from './flow-run-utils'
import { mcpUtils } from './mcp-utils'
const testFlowInput = z.object({
flowId: z.string().describe('The ID of the flow to test. Use ap_list_flows to find it.'),
displayName: z.string().optional().describe('Short approval prompt shown to the user (e.g. "Test Send Welcome Email"). Must include what the action does and the target name.'),
triggerTestData: z.record(z.string(), z.unknown()).optional().describe('Mock trigger output data. Saved as sample data before running the test. Useful when the trigger has no prior test data.'),
})
export const apTestFlowTool = ({ mcp, userId }: McpToolContext, log: FastifyBaseLogger): McpToolDefinition => {
return {
title: 'ap_test_flow',
permission: Permission.WRITE_FLOW,
description: 'Test a flow end-to-end in the test environment. Requires a configured trigger. Waits up to 120s. Pass triggerTestData to provide mock trigger output when no sample data exists.',
inputSchema: testFlowInput.shape,
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
execute: async (args) => {
try {
const { flowId, triggerTestData } = testFlowInput.parse(args)
return await executeFlowTest({ userId, flowId, projectId: mcp.projectId, triggerTestData, log })
}
catch (err) {
log.error({ error: err, project: { id: mcp.projectId } }, 'ap_test_flow failed')
return mcpUtils.mcpToolError('Failed to test flow', err)
}
},
}
}