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 testStepInput = z.object({
flowId: z.string().describe('The ID of the flow containing the step. Use ap_list_flows to find it.'),
stepName: z.string().describe('The name of the step to test (e.g., "step_1"). Use ap_flow_structure to find it.'),
displayName: z.string().optional().describe('Short approval prompt shown to the user (e.g. "Test Send Email step in Welcome Flow"). 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 apTestStepTool = ({ mcp, userId }: McpToolContext, log: FastifyBaseLogger): McpToolDefinition => {
return {
title: 'ap_test_step',
permission: Permission.WRITE_FLOW,
description: 'Test a single step within a flow. Runs all steps up to and including the specified step. The flow must have a configured trigger. Pass triggerTestData when no sample data exists.',
inputSchema: testStepInput.shape,
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
execute: async (args) => {
try {
const { flowId, stepName, triggerTestData } = testStepInput.parse(args)
return await executeFlowTest({ userId, flowId, projectId: mcp.projectId, stepName, triggerTestData, log })
}
catch (err) {
log.error({ error: err, project: { id: mcp.projectId } }, 'ap_test_step failed')
return mcpUtils.mcpToolError('Failed to test step', err)
}
},
}
}