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 { isNil, Permission } from '@activepieces/core-utils'
import { FlowOperationRequest, FlowOperationType, McpToolContext, McpToolDefinition } from '@activepieces/shared'
import { FastifyBaseLogger } from 'fastify'
import { z } from 'zod'
import { flowService } from '../../flows/flow/flow.service'
import { projectService } from '../../project/project-service'
import { mcpUtils } from './mcp-utils'
const renameFlowInput = z.object({
flowId: z.string(),
displayName: z.string(),
})
export const apRenameFlowTool = ({ mcp, userId }: McpToolContext, log: FastifyBaseLogger): McpToolDefinition => {
return {
title: 'ap_rename_flow',
permission: Permission.WRITE_FLOW,
description: 'Rename a flow.',
inputSchema: {
flowId: z.string().describe('The id of the flow to rename'),
displayName: z.string().describe('The new display name for the flow'),
},
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
execute: async (args) => {
const { flowId, displayName } = renameFlowInput.parse(args)
const [flow, project] = await Promise.all([
flowService(log).getOnePopulated({ id: flowId, projectId: mcp.projectId }),
projectService(log).getOneOrThrow(mcp.projectId),
])
if (isNil(flow)) {
return { content: [{ type: 'text', text: '❌ Flow not found' }] }
}
const operation: FlowOperationRequest = {
type: FlowOperationType.CHANGE_NAME,
request: { displayName },
}
try {
await flowService(log).update({
id: flow.id,
projectId: mcp.projectId,
userId,
previousFlow: flow,
platformId: project.platformId,
operation,
})
return {
content: [{ type: 'text', text: `✅ Flow renamed to "${displayName}".` }],
}
}
catch (err) {
return mcpUtils.mcpToolError('Flow rename failed', err)
}
},
}
}