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

1.3 KB
Raw Blame
import { ApId, Permission } from '@activepieces/core-utils'
import { AgentMcpTool, PrincipalType } from '@activepieces/shared'
import { FastifyPluginAsyncZod } from 'fastify-type-provider-zod'
import { z } from 'zod'
import { ProjectResourceType } from '../core/security/authorization/common'
import { securityAccess } from '../core/security/authorization/fastify-security'
import { mcpToolValidator } from './mcp-tool-validator'

export const agentToolsController: FastifyPluginAsyncZod = async (app) => {
    app.post('/mcp/validate', ValidateMcpToolRequest, async (req) => {
        return mcpToolValidator.validateAgentMcpTool(req.body)
    })
}

const ValidateMcpToolRequest = {
    config: {
        security: securityAccess.project(
            [PrincipalType.USER],
            Permission.WRITE_FLOW,
            {
                type: ProjectResourceType.PARAM,
            },
        ),
    },
    schema: {
        tags: ['agent'],
        description: 'Probe an external MCP server configured as an agent tool and return its tool names. The outbound call is routed through the SSRF-filtered safeHttp axios; all failure modes collapse to a single generic error so the response cannot be used for port or network reconnaissance.',
        params: z.object({
            projectId: ApId,
        }),
        body: AgentMcpTool,
    },
}