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
| Type | Purpose | Key config field | Output names |
|---|---|---|---|
Input | Flow entry point; provides initial data | None (auto-configured) | document |
Output | Flow exit point; receives final data | None | None (sink) |
Prompt | Call a Bedrock foundation model | configuration.prompt | modelCompletion |
LambdaFunction | Invoke an AWS Lambda function | configuration.lambdaFunction.lambdaArn | functionResponse |
KnowledgeBase | Query a Bedrock Knowledge Base | configuration.knowledgeBase.knowledgeBaseId | outputText |
Storage | Read/write S3 objects | configuration.storage.serviceConfiguration | body |
Condition | Route flow based on boolean expressions | configuration.condition.conditions[] | One per condition name |
Iterator | Fan out: array → individual elements | None (auto-configured) | arrayItem, arraySize |
Collector | Fan in: individual results → array | None (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:
- Expressions are JSONata, not JSONPath or JMESPath. Use
$.datato reference the entire incoming value,$.data.fieldNamefor a subfield. Comparisons use==,!=,>,<. String literals use single quotes. Example:"$.data.score > 0.9". - The default condition must be last in the conditions array. If no condition matches and there is no default, the flow emits
flowCompletionEventwithcompletionReason: 'INPUT_REQUIRED'— the flow does not emit anyflowOutputEventand the MCP tool gets no result. - Conditional connections use
type: 'Conditional', not'Data'. Using the wrong type causes a validation failure at PrepareFlow. - ConditionNode passes through its entire input on the matched branch — there is no data transformation. The downstream node receives the same value that entered the ConditionNode.
- Multiple conditions can match, but only the first matching branch executes. Conditions are evaluated in array order.
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:
- IteratorNode input must be named
'array'. Any other name causes a validation error at PrepareFlow. - CollectorNode input must be named
'arrayItem'. The same constraint applies. - IteratorNode flattens exactly one level. If your input is
[['a','b'],['c','d']], the iterator emits['a','b']and['c','d']as Array-typed elements, not individual strings. Use a LambdaFunctionNode before the Iterator if you need to flatten nested arrays. - CollectorNode preserves order. Elements are collected in the same order as the iterator emitted them, regardless of execution timing.
- Maximum array size: Bedrock Flows imposes a limit on the number of elements an IteratorNode will process in a single invocation. Exceeding it causes a
ServiceQuotaExceededException. Batch large arrays in your MCP tool handler before passing to the flow. - Using Iterator without Collector is valid: the flow emits one
flowOutputEventper element and oneflowCompletionEventat the end. This is useful when the MCP server needs to stream incremental results.
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:
- The Lambda function's return value becomes the
functionResponseoutput. The output type in the node definition must match what your Lambda returns. If your Lambda returns an object and you declaretype: 'String', the flow will fail with a type error. - Lambda timeout: Bedrock Flows waits for Lambda to complete synchronously. The effective maximum wait is bounded by Lambda's configured timeout. Keep Lambda timeouts generous — LambdaFunctionNode does not time out the Lambda call independently.
- Lambda errors: If Lambda throws an unhandled exception or returns an error response, the flow emits an
internalServerExceptionstream event. Catch all exceptions in your Lambda handler and return a structured error value instead. - Lambda version and aliases: The
lambdaArncan include a version suffix (e.g.,:3) or alias suffix (e.g.,:production) to pin to a specific Lambda version. Without a suffix, it invokes the$LATESTversion.
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:
| Expression | Meaning | Example |
|---|---|---|
$.data | The entire upstream value | Pass a String through unchanged |
$.data.fieldName | A top-level field of an Object upstream | Extract text from {text: "...", score: 0.9} |
$.data[0] | First element of an Array upstream | Pass first retrieved document only |
$.data.results[*].text | Map over array and extract field | Flatten 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 type | Compatible target input types | Notes |
|---|---|---|
String | String | Strict — String does not coerce to Number or Boolean |
Number | Number | Strict |
Boolean | Boolean | Strict |
Object | Object | Strict — if you need a field, use an expression |
Array | Array | IteratorNode input must be Array |
| Any type | String (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
| Mistake | Symptom | Fix |
|---|---|---|
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 |