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:

AttributeConnectedHomeFaceSearch
What it detectsPERSON, PET, PACKAGE (door camera labels)Specific faces from a Face Collection
OutputKinesis Data Stream + S3 (image of detected object)Kinesis Data Stream
Use caseSmart home, delivery detection, occupancy sensingEmployee access, known person alerts
Requires Face CollectionNoYes
Pricing driverPer minute of video analyzedPer minute of video analyzed
Min confidenceConfigurable 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

Continue in this series

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