Guide · Amazon Kinesis Video Streams · Rekognition Stream Processor Integration
Kinesis Video Streams Rekognition Stream Processor for MCP Servers — ConnectedHome, FaceSearch, and Event-Driven AI
Rekognition Stream Processors connect a live KVS stream to Rekognition's real-time video analysis engine without you writing a frame-extraction loop. You define what to detect — PERSON, PET, PACKAGE, or faces from a known collection — and Rekognition emits structured detection events to a Kinesis Data Stream or S3 as frames match your criteria. For MCP server teams, this is the right primitive when you need event-driven AI rather than on-demand frame retrieval: the agent responds to what happens (a package appears at the door) rather than continuously polling for it.
TL;DR
Use CreateStreamProcessorCommand from @aws-sdk/client-rekognition (not the KVS package). Two processor modes: ConnectedHome (object detection: PERSON, PET, PACKAGE, ALL labels) and FaceSearch (match faces against a Rekognition face collection). Start with StartStreamProcessorCommand. ConnectedHome events arrive via a Kinesis Data Stream with ConnectedHomeLabels[]; FaceSearch events include matched face metadata. Stop with StopStreamProcessorCommand; delete with DeleteStreamProcessorCommand. Processor state changes are async — poll DescribeStreamProcessorCommand until Status === "RUNNING".
Stream processor modes compared
Rekognition offers two distinct analysis modes for stream processors, each targeting different use cases:
| Attribute | ConnectedHome | FaceSearch |
|---|---|---|
| What it detects | PERSON, PET, PACKAGE (door camera labels) | Specific faces from a Face Collection |
| Output | Kinesis Data Stream + S3 (image of detected object) | Kinesis Data Stream |
| Use case | Smart home, delivery detection, occupancy sensing | Employee access, known person alerts |
| Requires Face Collection | No | Yes |
| Pricing driver | Per minute of video analyzed | Per minute of video analyzed |
| Min confidence | Configurable per label (0–100) | FaceMatchThreshold (0–100) |
IAM prerequisites
Rekognition Stream Processors require cross-service IAM access — Rekognition must assume a role that has permission to read from KVS and write to Kinesis Data Streams and S3:
// Trust policy for the Rekognition service role
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "Service": "rekognition.amazonaws.com" },
"Action": "sts:AssumeRole"
}]
}
// Permission policy for the same role
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadFromKVS",
"Effect": "Allow",
"Action": [
"kinesisvideo:GetDataEndpoint",
"kinesisvideo:GetMedia"
],
"Resource": "arn:aws:kinesisvideo:us-east-1:*:stream/factory-cam-01/*"
},
{
"Sid": "WriteToKDS",
"Effect": "Allow",
"Action": ["kinesis:PutRecord"],
"Resource": "arn:aws:kinesis:us-east-1:*:stream/rekognition-events"
},
{
"Sid": "WriteToS3",
"Effect": "Allow",
"Action": ["s3:PutObject"],
"Resource": "arn:aws:s3:::my-rekognition-output/*"
}
]
}
Your MCP server also needs rekognition:CreateStreamProcessor, rekognition:StartStreamProcessor, rekognition:StopStreamProcessor, rekognition:DescribeStreamProcessor, and rekognition:DeleteStreamProcessor in its own IAM policy. Additionally, it needs iam:PassRole on the Rekognition service role ARN to associate it with the stream processor.
Creating a ConnectedHome stream processor
ConnectedHome is designed for door camera use cases: detecting when a PERSON, PET, or PACKAGE is visible in the frame:
import {
RekognitionClient,
CreateStreamProcessorCommand,
StartStreamProcessorCommand,
StopStreamProcessorCommand,
DescribeStreamProcessorCommand,
DeleteStreamProcessorCommand,
ListStreamProcessorsCommand,
GetStreamProcessorSettingsCommand,
UpdateStreamProcessorCommand,
} from "@aws-sdk/client-rekognition";
const rek = new RekognitionClient({ region: "us-east-1" });
const PROCESSOR_NAME = "factory-cam-01-processor";
const KVS_STREAM_ARN = "arn:aws:kinesisvideo:us-east-1:123456789012:stream/factory-cam-01/...";
const KDS_STREAM_ARN = "arn:aws:kinesis:us-east-1:123456789012:stream/rekognition-events";
const S3_BUCKET = "my-rekognition-output";
const ROLE_ARN = "arn:aws:iam::123456789012:role/RekognitionStreamProcessorRole";
// Create a ConnectedHome stream processor
await rek.send(new CreateStreamProcessorCommand({
Name: PROCESSOR_NAME,
Input: {
KinesisVideoStream: {
Arn: KVS_STREAM_ARN,
},
},
Output: {
// ConnectedHome requires BOTH KinesisDataStream (events) and S3 (snapshots)
KinesisDataStream: {
Arn: KDS_STREAM_ARN,
},
S3Destination: {
Bucket: S3_BUCKET,
KeyPrefix: "connected-home-snapshots/factory-cam-01/",
},
},
Settings: {
ConnectedHome: {
Labels: ["PERSON", "PET", "PACKAGE", "ALL"], // or subset
MinConfidence: 75.0, // 0-100; events below this threshold are suppressed
},
},
RoleArn: ROLE_ARN,
Tags: {
CameraId: "factory-cam-01",
Environment: "production",
},
// Optional: notify via SNS when processor status changes
NotificationChannel: {
SNSTopicArn: "arn:aws:sns:us-east-1:123456789012:rekognition-processor-status",
},
// Optional: define a region of interest (polygon) within the frame
RegionsOfInterest: [
{
Polygon: [
{ X: 0.0, Y: 0.0 }, // normalized coordinates 0.0-1.0
{ X: 0.5, Y: 0.0 },
{ X: 0.5, Y: 1.0 },
{ X: 0.0, Y: 1.0 },
],
},
],
// Optional: data sharing consent for model improvement
DataSharingPreference: {
OptIn: false,
},
}));
console.log("Stream processor created:", PROCESSOR_NAME);
RegionsOfInterest limits detection to specific areas of the frame using normalized polygon coordinates (0.0–1.0 relative to frame width/height). This is useful for door cameras where you only want to detect activity in the entryway zone, not in adjacent areas like parked cars or sidewalks.
Starting and monitoring the processor
Stream processors are not automatically running after creation. Start them explicitly and poll for RUNNING status before treating them as active:
// Start the processor
await rek.send(new StartStreamProcessorCommand({
Name: PROCESSOR_NAME,
}));
// Poll until RUNNING (usually 30-60 seconds)
async function waitForProcessorStatus(name, targetStatus, timeoutMs = 120_000) {
const start = Date.now();
while (Date.now() - start < timeoutMs) {
const { StreamProcessorStatus, StatusMessage } = await rek.send(
new DescribeStreamProcessorCommand({ Name: name })
);
console.log("Processor status:", StreamProcessorStatus, "-", StatusMessage);
if (StreamProcessorStatus === targetStatus) return;
if (StreamProcessorStatus === "FAILED") {
throw new Error(`Stream processor failed: ${StatusMessage}`);
}
await new Promise(r => setTimeout(r, 5_000));
}
throw new Error(`Timed out waiting for processor to reach ${targetStatus}`);
}
await waitForProcessorStatus(PROCESSOR_NAME, "RUNNING");
console.log("Processor is now analyzing the live stream");
// Describe the processor to see full configuration
const processorInfo = await rek.send(new DescribeStreamProcessorCommand({
Name: PROCESSOR_NAME,
}));
console.log("Processor ARN:", processorInfo.StreamProcessorArn);
console.log("Creation time:", processorInfo.CreationTimestamp);
console.log("Last update:", processorInfo.LastUpdateTimestamp);
Consuming ConnectedHome events from Kinesis Data Streams
When Rekognition detects a PERSON, PET, or PACKAGE, it writes a JSON record to the Kinesis Data Stream. Each record contains label metadata with bounding boxes and confidence scores:
import {
KinesisClient,
GetShardIteratorCommand,
GetRecordsCommand,
DescribeStreamCommand as KDSDescribeStreamCommand,
} from "@aws-sdk/client-kinesis";
const kinesis = new KinesisClient({ region: "us-east-1" });
async function consumeRekognitionEvents(kdsStreamName) {
// Get the first shard
const { StreamDescription } = await kinesis.send(
new KDSDescribeStreamCommand({ StreamName: kdsStreamName })
);
const shardId = StreamDescription.Shards[0].ShardId;
// Start from the latest events
const { ShardIterator } = await kinesis.send(new GetShardIteratorCommand({
StreamName: kdsStreamName,
ShardId: shardId,
ShardIteratorType: "LATEST",
}));
let iterator = ShardIterator;
while (iterator) {
const { Records, NextShardIterator, MillisBehindLatest } = await kinesis.send(
new GetRecordsCommand({ ShardIterator: iterator, Limit: 100 })
);
for (const record of Records) {
const payload = JSON.parse(Buffer.from(record.Data).toString("utf-8"));
handleConnectedHomeEvent(payload);
}
iterator = NextShardIterator;
if (MillisBehindLatest === 0) await new Promise(r => setTimeout(r, 1000));
}
}
function handleConnectedHomeEvent(event) {
// ConnectedHome event schema:
// {
// "StreamProcessorArn": "arn:aws:rekognition:...",
// "InputInformation": {
// "KinesisVideo": {
// "StreamArn": "...",
// "FragmentNumber": "91343852333181432392682062622244200492743730490",
// "ServerTimestamp": 1700000000.123,
// "ProducerTimestamp": 1700000000.100,
// "FrameOffsetInSeconds": 2.5
// }
// },
// "StreamProcessorInformation": { "Status": "RUNNING" },
// "ConnectedHomeDetection": {
// "Labels": [
// {
// "Name": "PERSON",
// "Confidence": 94.5,
// "Instances": [
// {
// "BoundingBox": {
// "Width": 0.15, "Height": 0.42,
// "Left": 0.30, "Top": 0.20
// },
// "Confidence": 94.5
// }
// ]
// }
// ]
// }
// }
const labels = event.ConnectedHomeDetection?.Labels ?? [];
for (const label of labels) {
console.log(`Detected: ${label.Name} (${label.Confidence.toFixed(1)}%) at fragment ${
event.InputInformation.KinesisVideo.FragmentNumber
}`);
if (label.Name === "PERSON" && label.Confidence > 90) {
console.log(" High-confidence person detected — triggering agent action");
// → Trigger MCP tool, send alert, start recording, etc.
}
if (label.Name === "PACKAGE") {
const fragmentNumber = event.InputInformation.KinesisVideo.FragmentNumber;
console.log(" Package detected — retrieving frame from fragment", fragmentNumber);
// → Call GetMediaForFragmentList with [fragmentNumber] to get the frame
}
}
}
Creating a FaceSearch stream processor
FaceSearch matches live video frames against faces stored in a Rekognition Face Collection. Use it for access control — detecting when a known employee enters a facility, or alerting when an unknown person is seen:
// First, ensure a Face Collection exists and has indexed faces
import { CreateCollectionCommand, IndexFacesCommand } from "@aws-sdk/client-rekognition";
await rek.send(new CreateCollectionCommand({
CollectionId: "factory-employees",
Tags: { Environment: "production" },
}));
// Index an employee face from S3
const { FaceRecords } = await rek.send(new IndexFacesCommand({
CollectionId: "factory-employees",
Image: {
S3Object: { Bucket: "employee-photos", Name: "alice-smith.jpg" },
},
ExternalImageId: "employee-alice-smith",
DetectionAttributes: ["ALL"],
MaxFaces: 1,
QualityFilter: "AUTO",
}));
const aliceFaceId = FaceRecords[0].Face.FaceId;
console.log("Indexed face:", aliceFaceId);
// Create a FaceSearch stream processor
await rek.send(new CreateStreamProcessorCommand({
Name: "factory-cam-01-facesearch",
Input: {
KinesisVideoStream: { Arn: KVS_STREAM_ARN },
},
Output: {
// FaceSearch only needs Kinesis Data Stream output (no S3 required)
KinesisDataStream: { Arn: KDS_STREAM_ARN },
},
Settings: {
FaceSearch: {
CollectionId: "factory-employees",
FaceMatchThreshold: 85.0, // 0-100; stricter = fewer false positives
},
},
RoleArn: ROLE_ARN,
}));
FaceSearch events have a different schema from ConnectedHome events. Each record contains a FaceSearchResponse array with matched faces, their similarity scores, and bounding box positions within the frame.
Updating a running processor
You can update certain settings on a running stream processor without stopping it. Use UpdateStreamProcessorCommand for label changes or regions of interest:
await rek.send(new UpdateStreamProcessorCommand({
Name: PROCESSOR_NAME,
// Add PET to the detected labels
SettingsForUpdate: {
ConnectedHomeForUpdate: {
Labels: ["PERSON", "PET", "PACKAGE"],
MinConfidence: 80.0, // updated threshold
},
},
// Add a second region of interest
RegionsOfInterestForUpdate: {
RegionsOfInterest: [
{
Polygon: [
{ X: 0.0, Y: 0.0 }, { X: 0.5, Y: 0.0 },
{ X: 0.5, Y: 1.0 }, { X: 0.0, Y: 1.0 },
],
},
{
Polygon: [
{ X: 0.5, Y: 0.0 }, { X: 1.0, Y: 0.0 },
{ X: 1.0, Y: 0.5 }, { X: 0.5, Y: 0.5 },
],
},
],
// Keep the existing parameter values not being updated
ParametersToDelete: [],
},
}));
Stopping and cleanup
// Stop the processor (can be restarted later — stream processor resource is preserved)
await rek.send(new StopStreamProcessorCommand({ Name: PROCESSOR_NAME }));
await waitForProcessorStatus(PROCESSOR_NAME, "STOPPED");
// List all processors in the account
const { StreamProcessors } = await rek.send(new ListStreamProcessorsCommand({
MaxResults: 100,
}));
console.log("All processors:", StreamProcessors.map(p => `${p.Name} (${p.Status})`));
// Delete the processor permanently
await rek.send(new DeleteStreamProcessorCommand({ Name: PROCESSOR_NAME }));
console.log("Processor deleted");
MCP tool pattern: event-driven video agent
The recommended MCP tool architecture for event-driven video AI combines a persistent stream processor with a Kinesis Data Stream consumer that triggers agent actions:
// MCP tool: "monitor_camera" — start monitoring a camera for person/package events
// MCP tool: "get_camera_status" — describe current stream processor status
// MCP tool: "get_recent_detections" — read latest KDS events
// In your MCP server tool handler:
async function monitorCamera({ streamName, labels, minConfidence, durationMinutes }) {
// 1. Ensure stream processor exists and is running
const processorName = `${streamName}-processor`;
try {
const info = await rek.send(new DescribeStreamProcessorCommand({ Name: processorName }));
if (info.StreamProcessorStatus !== "RUNNING") {
await rek.send(new StartStreamProcessorCommand({ Name: processorName }));
}
} catch (err) {
if (err.name === "ResourceNotFoundException") {
await rek.send(new CreateStreamProcessorCommand({
Name: processorName,
Input: { KinesisVideoStream: { Arn: await getStreamArn(streamName) } },
Output: { KinesisDataStream: { Arn: KDS_STREAM_ARN } },
Settings: { ConnectedHome: { Labels: labels, MinConfidence: minConfidence } },
RoleArn: ROLE_ARN,
}));
await waitForProcessorStatus(processorName, "RUNNING");
} else { throw err; }
}
// 2. Schedule auto-stop via EventBridge Scheduler if durationMinutes provided
if (durationMinutes) {
// → CreateScheduleCommand with StopStreamProcessor as target
// → see EventBridge Scheduler guide for MCP servers
}
return {
status: "monitoring_started",
processorName,
detectionLabels: labels,
kdsStreamArn: KDS_STREAM_ARN,
};
}
Key gotchas
- ConnectedHome requires both KDS and S3 output: Unlike FaceSearch which only needs a Kinesis Data Stream, ConnectedHome will fail to create if you omit
Output.S3Destination. Even if you don't use the S3 snapshots, you must specify a bucket and prefix. - Processor startup takes 30–90 seconds:
StartStreamProcessorCommandreturns immediately, but the processor transitions through STARTING → RUNNING asynchronously. Build retry/poll logic into any tool that depends on the processor being active before reading events. - KVS stream must be actively ingesting: If the camera device has disconnected and the KVS stream has no new fragments, the stream processor pauses analysis. It doesn't fail — it just emits no events. Monitor your KVS producer separately to ensure the camera feed is healthy.
- Label ALL vs specific labels: Specifying
Labels: ["ALL"]enables all ConnectedHome labels now and any new labels Rekognition adds in the future. Specifying only["PERSON"]means you will not receive PET or PACKAGE events even if detected. For broad monitoring,["ALL"]is safer; for cost optimization on high-traffic streams, restricting labels reduces event volume. - Face collection and stream processor are in the same region: You cannot reference a face collection in us-west-2 from a stream processor in us-east-1. All resources — KVS stream, Rekognition collection, and stream processor — must be in the same AWS region.
- Processor charges while running even if the stream is empty: You are charged per minute the processor is in RUNNING state, regardless of whether the KVS stream has active fragments. Stop the processor when monitoring is not needed to avoid idle charges (~$0.0025/minute in us-east-1 as of 2026).
Continue in this series
- KVS SDK overview and stream management — CreateStream, GetDataEndpoint, data endpoint pattern, retention configuration, IAM setup
- WebRTC signaling channels — CreateSignalingChannel, GetSignalingChannelEndpoint, GetIceServerConfig, real-time video
- Archived media: HLS, DASH, and frame extraction — GetHLSStreamingSessionURL, ListFragments, GetMediaForFragmentList for AI pipelines
Related AWS AI and event guides: Rekognition label detection for MCP servers · Rekognition face operations for MCP servers · Kinesis Data Streams for MCP servers · CloudWatch for MCP servers