Guide · Amazon Bedrock Flows

Bedrock Flows node types for MCP servers — Prompt, Condition, Iterator, Collector, Lambda

Bedrock Flows has nine node types that together cover the full range of AI pipeline primitives: model calls, conditional routing, fan-out/fan-in, Lambda side effects, Knowledge Base retrieval, and S3 storage. Understanding each node type's exact input/output contract is what separates working flows from flows that fail silently with type errors or never emit output because a branch was never connected. This guide covers every node type with its SDK definition structure, the gotchas that cause silent failures, and how each one fits into an MCP server pipeline. The two nodes most commonly misused are ConditionNode (which uses JSONata expressions, not JSONPath, and requires an explicit default branch) and IteratorNode (which must always be paired with CollectorNode unless you intentionally want a one-output-per-element flow).

TL;DR

Node types: Input, Output, Prompt, LambdaFunction, KnowledgeBase, Storage, Condition, Iterator, Collector. Use a Bedrock Prompt ARN in PromptNode (not an inline template) for production — it lets you version prompts independently. ConditionNode expressions use $.data-prefixed JSONata (e.g., $.data == 'en') and must have a default condition as the last condition in the array. IteratorNode flattens exactly one array level; CollectorNode must be downstream to merge results. LambdaFunctionNode receives all upstream inputs as a JSON object keyed by input name.

Node type overview

TypePurposeKey config fieldOutput names
InputFlow entry point; provides initial dataNone (auto-configured)document
OutputFlow exit point; receives final dataNoneNone (sink)
PromptCall a Bedrock foundation modelconfiguration.promptmodelCompletion
LambdaFunctionInvoke an AWS Lambda functionconfiguration.lambdaFunction.lambdaArnfunctionResponse
KnowledgeBaseQuery a Bedrock Knowledge Baseconfiguration.knowledgeBase.knowledgeBaseIdoutputText
StorageRead/write S3 objectsconfiguration.storage.serviceConfigurationbody
ConditionRoute flow based on boolean expressionsconfiguration.condition.conditions[]One per condition name
IteratorFan out: array → individual elementsNone (auto-configured)arrayItem, arraySize
CollectorFan in: individual results → arrayNone (auto-configured)collectedArray

PromptNode: calling a foundation model

PromptNode calls a Bedrock foundation model with a prompt template. There are two source configurations: a saved Bedrock Prompt resource (recommended) or an inline template (convenient for quick iteration, but cannot be versioned independently of the flow).

Using a saved Prompt ARN (recommended)

// First, create a Bedrock Prompt (separate resource)
import { CreatePromptCommand } from '@aws-sdk/client-bedrock-agent';

const prompt = await mgmt.send(new CreatePromptCommand({
  name: 'summarization-prompt',
  variants: [
    {
      name: 'default',
      modelId: 'anthropic.claude-3-haiku-20240307-v1:0',
      templateType: 'TEXT',
      templateConfiguration: {
        text: {
          text: 'Summarize the following document in {{style}} format:\n\n{{document}}',
          inputVariables: [
            { name: 'document' },
            { name: 'style' },
          ],
        },
      },
    },
  ],
  defaultVariant: 'default',
}));

// Reference it in your flow PromptNode
const promptNode = {
  name: 'SummarizationPrompt',
  type: 'Prompt',
  configuration: {
    prompt: {
      sourceConfiguration: {
        resource: {
          promptArn: `arn:aws:bedrock:us-east-1:123456789012:prompt/${prompt.id}`,
        },
      },
    },
  },
  inputs: [
    { name: 'document', type: 'String', expression: '$.data' },
    { name: 'style', type: 'String', expression: '$.data' },
  ],
  outputs: [
    { name: 'modelCompletion', type: 'String' },
  ],
};

The promptArn does not include the version — it always resolves to the prompt's default variant at flow preparation time. To use a specific version of a prompt, append :VERSION_NUMBER to the ARN: arn:aws:bedrock:us-east-1:123456789012:prompt/ABCDEF1234:3.

Using an inline template

const promptNodeInline = {
  name: 'ClassificationPrompt',
  type: 'Prompt',
  configuration: {
    prompt: {
      sourceConfiguration: {
        inline: {
          modelId: 'anthropic.claude-3-haiku-20240307-v1:0',
          templateType: 'TEXT',
          templateConfiguration: {
            text: {
              text: 'Classify the following text into one of these categories: news, opinion, tutorial.\n\nText: {{text}}\n\nCategory (one word):',
              inputVariables: [
                { name: 'text' },
              ],
            },
          },
          inferenceConfiguration: {
            text: {
              maxTokens: 10,          // classification only needs a few tokens
              temperature: 0.0,       // deterministic classification
              stopSequences: ['\n'],  // stop at newline to get clean category
            },
          },
        },
      },
    },
  },
  inputs: [
    { name: 'text', type: 'String', expression: '$.data' },
  ],
  outputs: [
    { name: 'modelCompletion', type: 'String' },
  ],
};

The PromptNode output name is always modelCompletion regardless of configuration. It is a String type. If you need structured JSON output, the model must produce valid JSON in its completion — there is no native typed output from PromptNode. Post-process with a LambdaFunctionNode to parse and extract fields.

Temperature and maxTokens can be set in inferenceConfiguration.text. For inline templates these are set once. For resource-based prompts, inference config is set in the Bedrock Prompt resource itself.

ConditionNode: branching with JSONata expressions

ConditionNode evaluates a list of conditions in order and routes the flow to the first matching branch. Each condition has a name (which becomes the output port name used in connections) and an expression. The last condition in the array must be a default (no expression, or expression true) to handle all unmatched cases.

const conditionNode = {
  name: 'LanguageRouter',
  type: 'Condition',
  configuration: {
    condition: {
      conditions: [
        {
          name: 'isEnglish',
          expression: "$.data == 'en'",   // JSONata, not JSONPath
        },
        {
          name: 'isFrench',
          expression: "$.data == 'fr'",
        },
        {
          name: 'default',
          // No expression = default fallback branch
        },
      ],
    },
  },
  inputs: [
    {
      name: 'languageCode',
      type: 'String',
      expression: '$.data',
    },
  ],
  // Outputs are auto-generated from condition names:
  // 'isEnglish', 'isFrench', 'default'
};

// Connect each branch with Conditional-type connections
const connections = [
  {
    name: 'ToEnglishPrompt',
    source: 'LanguageRouter',
    target: 'EnglishSummarizationPrompt',
    type: 'Conditional',
    configuration: {
      conditional: {
        condition: 'isEnglish',  // matches condition name
      },
    },
  },
  {
    name: 'ToFrenchPrompt',
    source: 'LanguageRouter',
    target: 'FrenchSummarizationPrompt',
    type: 'Conditional',
    configuration: {
      conditional: {
        condition: 'isFrench',
      },
    },
  },
  {
    name: 'ToDefaultPrompt',
    source: 'LanguageRouter',
    target: 'DefaultSummarizationPrompt',
    type: 'Conditional',
    configuration: {
      conditional: {
        condition: 'default',
      },
    },
  },
];

Critical details for ConditionNode:

IteratorNode and CollectorNode: fan-out processing

IteratorNode takes an Array-typed input and emits each element individually, one at a time, to its downstream nodes. CollectorNode is the complementary accumulator — it receives one result per element and merges them back into an Array. They must be used as a matched pair when you need to process each element and collect all results.

// Fan-out: process each document in a list independently
const iteratorNode = {
  name: 'DocumentIterator',
  type: 'Iterator',
  inputs: [
    {
      name: 'array',              // must be named 'array'
      type: 'Array',
      expression: '$.data',
    },
  ],
  outputs: [
    { name: 'arrayItem', type: 'String' },   // one element at a time
    { name: 'arraySize', type: 'Number' },   // total array length (same for all elements)
  ],
};

// Process each element through a PromptNode (called once per element)
const perDocumentPrompt = {
  name: 'PerDocumentSummary',
  type: 'Prompt',
  // ... prompt configuration ...
  inputs: [
    { name: 'document', type: 'String', expression: '$.data' },
  ],
  outputs: [
    { name: 'modelCompletion', type: 'String' },
  ],
};

// Collect all per-element results back into an array
const collectorNode = {
  name: 'SummaryCollector',
  type: 'Collector',
  inputs: [
    {
      name: 'arrayItem',          // must be named 'arrayItem'
      type: 'String',
      expression: '$.data',
    },
  ],
  outputs: [
    { name: 'collectedArray', type: 'Array' },  // all elements merged
  ],
};

Connections for the fan-out pattern:

const fanOutConnections = [
  // Flow input → Iterator
  {
    name: 'InputToIterator',
    source: 'FlowInputNode',
    target: 'DocumentIterator',
    type: 'Data',
    configuration: { data: { sourceOutput: 'document', targetInput: 'array' } },
  },
  // Iterator → PromptNode (runs once per element)
  {
    name: 'IteratorToPrompt',
    source: 'DocumentIterator',
    target: 'PerDocumentSummary',
    type: 'Data',
    configuration: { data: { sourceOutput: 'arrayItem', targetInput: 'document' } },
  },
  // PromptNode → Collector
  {
    name: 'PromptToCollector',
    source: 'PerDocumentSummary',
    target: 'SummaryCollector',
    type: 'Data',
    configuration: { data: { sourceOutput: 'modelCompletion', targetInput: 'arrayItem' } },
  },
  // Collector → Output
  {
    name: 'CollectorToOutput',
    source: 'SummaryCollector',
    target: 'FlowOutputNode',
    type: 'Data',
    configuration: { data: { sourceOutput: 'collectedArray', targetInput: 'document' } },
  },
];

Important constraints:

LambdaFunctionNode: custom logic via Lambda

LambdaFunctionNode invokes an AWS Lambda function synchronously. The flow execution role must have lambda:InvokeFunction permission on the Lambda ARN. All node inputs are passed to Lambda as a single JSON object; the Lambda return value becomes the node's output.

const lambdaNode = {
  name: 'FormatOutputLambda',
  type: 'LambdaFunction',
  configuration: {
    lambdaFunction: {
      lambdaArn: 'arn:aws:lambda:us-east-1:123456789012:function:format-flow-output',
    },
  },
  inputs: [
    { name: 'summary', type: 'String', expression: '$.data' },
    { name: 'metadata', type: 'Object', expression: '$.data' },
  ],
  outputs: [
    { name: 'functionResponse', type: 'String' },
  ],
};

The Lambda function receives a JSON event with this shape:

// Lambda event shape (what your function receives)
interface BedrockFlowLambdaEvent {
  node: {
    name: string;      // e.g. 'FormatOutputLambda'
    type: string;      // 'LambdaFunction'
    outputs: Array<{ name: string; type: string }>;
  };
  inputs: Array<{
    name: string;      // matches input name from node definition
    type: string;
    value: unknown;    // the actual data
  }>;
}

// Lambda handler
export async function handler(event: BedrockFlowLambdaEvent) {
  // Extract inputs by name
  const summaryInput = event.inputs.find(i => i.name === 'summary');
  const metadataInput = event.inputs.find(i => i.name === 'metadata');

  const summary = summaryInput?.value as string;
  const metadata = metadataInput?.value as Record;

  const formatted = `# ${metadata.title}\n\n${summary}`;

  // Return value must match the declared output type
  return formatted;  // String
}

Key details for LambdaFunctionNode:

Node input expression syntax

Every node input has an expression field that extracts the relevant value from the upstream output. The expression syntax is a subset of JSONata:

ExpressionMeaningExample
$.dataThe entire upstream valuePass a String through unchanged
$.data.fieldNameA top-level field of an Object upstreamExtract text from {text: "...", score: 0.9}
$.data[0]First element of an Array upstreamPass first retrieved document only
$.data.results[*].textMap over array and extract fieldFlatten text from array of objects

Expressions are evaluated at the connection level — the same upstream output can be referenced by multiple downstream inputs with different expressions. If the expression does not match (the field does not exist in the object), the input receives null. Null inputs to a PromptNode cause the template variable to render as the empty string, which may produce unexpected model behavior.

Expressions are evaluated at runtime, not at prepare time. A flow with an expression targeting $.data.nonexistentField will prepare successfully and only fail (silently, as a null value) during invocation.

Type compatibility rules

Bedrock Flows is strictly typed. The declared type of a connection's source output must be compatible with the declared type of the target input. Mismatches cause a ValidationException at PrepareFlow with a message naming the incompatible connection.

Source output typeCompatible target input typesNotes
StringStringStrict — String does not coerce to Number or Boolean
NumberNumberStrict
BooleanBooleanStrict
ObjectObjectStrict — if you need a field, use an expression
ArrayArrayIteratorNode input must be Array
Any typeString (via expression)Expressions can coerce — $.data on a Number input that expects String still fails; expression does not auto-coerce types

When you need to convert between types — for example, turning a Number into a String for a PromptNode variable — use a LambdaFunctionNode as a type conversion shim. Even a trivial Lambda (return String(event.inputs[0].value)) is the correct solution.

Common node configuration mistakes

MistakeSymptomFix
ConditionNode missing default branch flowCompletionEvent.completionReason: 'INPUT_REQUIRED'; no output received Add a condition with no expression as the last item in conditions[]
Connecting ConditionNode branch with type: 'Data' PrepareFlow fails with ValidationException: connection type mismatch Use type: 'Conditional' for all ConditionNode outbound connections
IteratorNode input named anything other than 'array' PrepareFlow validation error on the Iterator node Rename the input to 'array' exactly
PromptNode variable name mismatch Template variable renders as empty string; model receives incomplete prompt Node input name must exactly match the {{variable_name}} in the prompt template
Lambda returns object when output declared as String Flow stream emits internalServerException or type error Change output type to Object or JSON-stringify in Lambda before returning
No path from ConditionNode branch to Output node Flow completes with no output on that branch Connect every branch (including default) to the Output node, possibly via different PromptNodes