Skip to content

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

6.8 KB
Raw Blame
import { McpToolDefinition, ProjectScopedMcpServer } from '@activepieces/shared'
import { FastifyBaseLogger } from 'fastify'
import { isToolSearchEnabled } from '../../tool-search/tool-search-flag'
import { apAddBranchTool } from './ap-add-branch'
import { apAddStepTool } from './ap-add-step'
import { apBuildFlowTool } from './ap-build-flow'
import { apChangeFlowStatusTool } from './ap-change-flow-status'
import { apCreateFlowTool } from './ap-create-flow'
import { apCreateFolderTool } from './ap-create-folder'
import { apCreateTableTool } from './ap-create-table'
import { apDeleteBranchTool } from './ap-delete-branch'
import { apDeleteFlowTool } from './ap-delete-flow'
import { apDeleteRecordsTool } from './ap-delete-records'
import { apDeleteStepTool } from './ap-delete-step'
import { apDeleteTableTool } from './ap-delete-table'
import { apDuplicateFlowTool } from './ap-duplicate-flow'
import { apFindRecordsTool } from './ap-find-records'
import { apFlowStructureTool } from './ap-flow-structure'
import { apGetPiecePropsTool } from './ap-get-piece-props'
import { apGetRunTool } from './ap-get-run'
import { apInsertRecordsTool } from './ap-insert-records'
import { apListAiModelsTool } from './ap-list-ai-models'
import { apListConnectionsTool } from './ap-list-connections'
import { apListFlowsTool } from './ap-list-flows'
import { apListFoldersTool } from './ap-list-folders'
import { apListRunsTool } from './ap-list-runs'
import { apListTablesTool } from './ap-list-tables'
import { apLockAndPublishTool } from './ap-lock-and-publish'
import { apManageFieldsTool } from './ap-manage-fields'
import { apManageNotesTool } from './ap-manage-notes'
import { apMoveFlowToFolderTool } from './ap-move-flow-to-folder'
import { apReadStepCodeTool } from './ap-read-step-code'
import { apReadStepSettingsTool } from './ap-read-step-settings'
import { apRenameFlowTool } from './ap-rename-flow'
import { apResearchPiecesTool } from './ap-research-pieces'
import { apResolvePropertyChainTool } from './ap-resolve-property-chain'
import { apResolvePropertyOptionsTool } from './ap-resolve-property-options'
import { apRetryRunTool } from './ap-retry-run'
import { apRunActionTool } from './ap-run-action'
import { apSearchActionsTool } from './ap-search-actions'
import { apSearchTriggersTool } from './ap-search-triggers'
import { apSetupGuideTool } from './ap-setup-guide'
import { apTestFlowTool } from './ap-test-flow'
import { apTestStepTool } from './ap-test-step'
import { apUpdateBranchTool } from './ap-update-branch'
import { apUpdateRecordTool } from './ap-update-record'
import { apUpdateStepTool } from './ap-update-step'
import { apUpdateTriggerTool } from './ap-update-trigger'
import { apValidateFlowTool } from './ap-validate-flow'
import { apValidateStepConfigTool } from './ap-validate-step-config'

// The tool-search tools (ap_search_actions / ap_search_triggers) only register when
// AP_TOOL_SEARCH_ENABLED=true — the flag stays the master switch and the rollback path. Once
// registered they are locked like the other read-only discovery tools; the locked entries are
// inert while the flag is off (a tool that never registers can't be force-on).
export const LOCKED_TOOL_NAMES: string[] = [
    'ap_list_flows',
    'ap_flow_structure',
    'ap_read_step_code',
    'ap_read_step_settings',
    'ap_validate_flow',
    'ap_research_pieces',
    'ap_search_actions',
    'ap_search_triggers',
    'ap_get_piece_props',
    'ap_resolve_property_options',
    'ap_resolve_property_chain',
    'ap_validate_step_config',
    'ap_list_connections',
    'ap_list_ai_models',
    'ap_list_tables',
    'ap_list_folders',
    'ap_find_records',
    'ap_list_runs',
    'ap_get_run',
    'ap_setup_guide',
] as const
 
export const PLATFORM_LEVEL_TOOL_NAMES = [
    'ap_research_pieces',
    'ap_search_actions',
    'ap_search_triggers',
    'ap_get_piece_props',
] as const

// NOTE: Keep this list in sync with TOOL_CATEGORIES in
// packages/web/src/app/components/project-settings/mcp-server/utils/mcp-tools-metadata.ts
// Any tool added here must also be added there so it appears in the UI settings panel.
export const ALL_CONTROLLABLE_TOOL_NAMES = [
    'ap_build_flow',
    'ap_create_flow',
    'ap_create_folder',
    'ap_duplicate_flow',
    'ap_rename_flow',
    'ap_move_flow_to_folder',
    'ap_update_trigger',
    'ap_add_step',
    'ap_update_step',
    'ap_delete_step',
    'ap_add_branch',
    'ap_update_branch',
    'ap_delete_branch',
    'ap_lock_and_publish',
    'ap_change_flow_status',
    'ap_delete_flow',
    'ap_manage_notes',
    'ap_create_table',
    'ap_delete_table',
    'ap_manage_fields',
    'ap_insert_records',
    'ap_update_record',
    'ap_delete_records',
    'ap_test_flow',
    'ap_test_step',
    'ap_retry_run',
    'ap_run_action',
]  as const

export const activepiecesTools = (mcp: ProjectScopedMcpServer, userId: string | undefined, log: FastifyBaseLogger): McpToolDefinition[] => [
    apBuildFlowTool({ mcp, userId }, log),
    apCreateFlowTool({ mcp, userId }, log),
    apCreateFolderTool(mcp, log),
    apDuplicateFlowTool({ mcp, userId }, log),
    apRenameFlowTool({ mcp, userId }, log),
    apMoveFlowToFolderTool({ mcp, userId }, log),
    apListFlowsTool(mcp, log),
    apListFoldersTool(mcp, log),
    apFlowStructureTool(mcp, log),
    apReadStepCodeTool(mcp, log),
    apReadStepSettingsTool(mcp, log),
    apValidateFlowTool({ mcp, userId }, log),
    apResearchPiecesTool(mcp, log),
    // Tool-search engine — gated behind the AP_TOOL_SEARCH_ENABLED rollout flag (default off).
    ...(isToolSearchEnabled() ? [apSearchActionsTool(mcp, log), apSearchTriggersTool(mcp, log)] : []),
    apGetPiecePropsTool(mcp, log),
    apResolvePropertyOptionsTool(mcp, log),
    apResolvePropertyChainTool(mcp, log),
    apValidateStepConfigTool(mcp, log),
    apListConnectionsTool(mcp, log),
    apUpdateTriggerTool({ mcp, userId }, log),
    apAddStepTool({ mcp, userId }, log),
    apUpdateStepTool({ mcp, userId }, log),
    apDeleteStepTool({ mcp, userId }, log),
    apAddBranchTool({ mcp, userId }, log),
    apUpdateBranchTool({ mcp, userId }, log),
    apDeleteBranchTool({ mcp, userId }, log),
    apLockAndPublishTool({ mcp, userId }, log),
    apChangeFlowStatusTool({ mcp, userId }, log),
    apDeleteFlowTool({ mcp, userId }, log),
    apManageNotesTool({ mcp, userId }, log),
    apListAiModelsTool(mcp, log),
    apListTablesTool(mcp, log),
    apFindRecordsTool(mcp, log),
    apCreateTableTool(mcp, log),
    apDeleteTableTool(mcp, log),
    apManageFieldsTool(mcp, log),
    apInsertRecordsTool(mcp, log),
    apUpdateRecordTool(mcp, log),
    apDeleteRecordsTool(mcp, log),
    apListRunsTool(mcp, log),
    apGetRunTool(mcp, log),
    apTestFlowTool({ mcp, userId }, log),
    apTestStepTool({ mcp, userId }, log),
    apRetryRunTool(mcp, log),
    apRunActionTool(mcp, log),
    apSetupGuideTool(mcp, log),
]