UNPKG

@allma/core-cdk

Version:

Core AWS CDK constructs for deploying the Allma serverless AI orchestration platform.

26 lines 1.35 kB
import { PermanentStepError, McpCallStepPayloadSchema } from '@allma/core-types'; import { McpConnectionService } from '../../allma-admin/services/mcp-connection.service.js'; import { callTool } from '../utils/mcp-client.js'; export const handleMcpCall = async (stepDefinition, stepInput, runtimeState) => { const validatedStep = McpCallStepPayloadSchema.parse(stepDefinition); const { mcpConnectionId, toolName } = validatedStep; try { const connection = await McpConnectionService.get(mcpConnectionId); if (!connection) { // This is a permanent failure because the connection ID is invalid and will never become valid. throw new PermanentStepError(`MCP Connection with ID '${mcpConnectionId}' not found.`); } const result = await callTool(connection, toolName, stepInput); return { outputData: { result }, }; } catch (error) { // The callTool utility now throws specific, typed errors. // The orchestrator's iterative step processor is designed to catch these and act accordingly // (e.g., retry on TransientStepError, fail on PermanentStepError). // By re-throwing the original error, we let the orchestrator handle the failure as designed. throw error; } }; //# sourceMappingURL=mcp-call-handler.js.map