Guide · Amazon Kinesis Video Streams · SDK Overview & Stream Management

Amazon Kinesis Video Streams for MCP Servers — SDK Overview, Stream Management, and AI Frame Extraction

Amazon Kinesis Video Streams (KVS) is AWS's fully managed service for ingesting, storing, and retrieving video streams from connected devices. For MCP server teams building multi-modal AI agents, KVS provides the bridge between physical cameras, IoT sensors, and AI models: agents can retrieve archived video frames for Claude Vision or Rekognition analysis, receive real-time video via WebRTC signaling channels, or trigger event-driven pipelines when motion is detected. The SDK is split across five packages — each handling a distinct interaction plane — and the data endpoint pattern means your media operations target stream-specific URLs, not the standard regional endpoint.

TL;DR

KVS uses five npm packages: @aws-sdk/client-kinesis-video (control plane — create/describe streams and signaling channels), @aws-sdk/client-kinesis-video-media (live GetMedia stream), @aws-sdk/client-kinesis-video-archived-media (HLS/DASH URLs and GetMediaForFragmentList for AI frame extraction), @aws-sdk/client-kinesis-video-signaling (WebRTC ICE server config), and @aws-sdk/client-kinesis-video-webrtc-storage (WebRTC video ingestion). Every media operation requires calling GetDataEndpointCommand first to get a stream-specific endpoint URL — you then instantiate a second client pointed at that URL for actual media reads/writes. Streams must have DataRetentionInHours >= 1 to retrieve archived media; retention 0 means data is not stored.

Why MCP servers need video stream access

Multi-modal AI agents increasingly need to perceive the physical world through cameras. KVS solves three distinct problems for MCP server teams:

The five SDK packages

Unlike most AWS services that ship a single SDK package, KVS is split by interaction plane:

npm install \
  @aws-sdk/client-kinesis-video \
  @aws-sdk/client-kinesis-video-media \
  @aws-sdk/client-kinesis-video-archived-media \
  @aws-sdk/client-kinesis-video-signaling \
  @aws-sdk/client-kinesis-video-webrtc-storage

Install only the packages you need. For control-plane-only work (creating streams, describing streams, managing tags), @aws-sdk/client-kinesis-video is sufficient.

Creating and describing streams

A stream is the fundamental resource: it has a name, an optional ARN-based alternative identifier, a media type hint, a shard count, and a retention window:

import {
  KinesisVideoClient,
  CreateStreamCommand,
  DescribeStreamCommand,
  ListStreamsCommand,
  DeleteStreamCommand,
} from "@aws-sdk/client-kinesis-video";

const kv = new KinesisVideoClient({ region: "us-east-1" });

// Create a stream for a factory camera
await kv.send(new CreateStreamCommand({
  StreamName: "factory-cam-01",
  DataRetentionInHours: 168, // 7 days
  MediaType: "video/h264",   // hint only — not enforced by KVS
  DeviceName: "factory-cam-01",
  Tags: {
    Environment: "production",
    Location: "assembly-line-3",
  },
}));

// Describe the stream to get its ARN
const { StreamInfo } = await kv.send(new DescribeStreamCommand({
  StreamName: "factory-cam-01",
}));
console.log("Stream ARN:", StreamInfo.StreamARN);
console.log("Status:", StreamInfo.Status);  // "CREATING" | "ACTIVE" | "UPDATING" | "DELETING"
console.log("Retention:", StreamInfo.DataRetentionInHours, "hours");

// List all streams with optional prefix filter
const { StreamInfoList } = await kv.send(new ListStreamsCommand({
  StreamNameCondition: {
    ComparisonOperator: "BEGINS_WITH",
    ComparisonValue: "factory-",
  },
}));
console.log("Factory streams:", StreamInfoList.map(s => s.StreamName));

The MediaType field is advisory — KVS accepts any media as long as it conforms to the MKV (Matroska) container format for PutMedia operations. Common values: "video/h264", "video/h265", "video/x-matroska". For GetHLSStreamingSessionURL to work, the stream must contain H.264 or H.265 encoded video.

The data endpoint pattern

This is the most important gotcha in KVS development. Media operations (GetMedia, GetHLSStreamingSessionURL, PutMedia, GetMediaForFragmentList, etc.) cannot use the standard regional endpoint. You must call GetDataEndpointCommand to get a stream-specific endpoint, then create a new client instance using that endpoint:

import { KinesisVideoClient, GetDataEndpointCommand } from "@aws-sdk/client-kinesis-video";
import { KinesisVideoArchivedMediaClient, GetHLSStreamingSessionURLCommand } from "@aws-sdk/client-kinesis-video-archived-media";

const kv = new KinesisVideoClient({ region: "us-east-1" });

// Step 1: Get the data endpoint for the specific API you want to call
const { DataEndpoint } = await kv.send(new GetDataEndpointCommand({
  StreamName: "factory-cam-01",
  APIName: "GET_HLS_STREAMING_SESSION_URL",
  // APIName options:
  // "PUT_MEDIA"
  // "GET_MEDIA"
  // "LIST_FRAGMENTS"
  // "GET_MEDIA_FOR_FRAGMENT_LIST"
  // "GET_HLS_STREAMING_SESSION_URL"
  // "GET_DASH_STREAMING_SESSION_URL"
  // "GET_CLIP"
}));
console.log("Data endpoint:", DataEndpoint);
// e.g. "https://b-23456789.kinesisvideo.us-east-1.amazonaws.com"

// Step 2: Create a media client pointed at the data endpoint
const kvArchived = new KinesisVideoArchivedMediaClient({
  region: "us-east-1",
  endpoint: DataEndpoint,
});

// Step 3: Now call media APIs using the data-endpoint-specific client
const { HLSStreamingSessionURL } = await kvArchived.send(
  new GetHLSStreamingSessionURLCommand({
    StreamName: "factory-cam-01",
    PlaybackMode: "LIVE",
    HLSFragmentSelector: {
      FragmentSelectorType: "SERVER_TIMESTAMP",
    },
    Expires: 3600, // seconds — default 300, max 43200
  })
);
console.log("HLS URL:", HLSStreamingSessionURL);

Data endpoints are durable — they don't rotate unless a stream is deleted and recreated. Caching the endpoint per (stream, API name) pair for a session is safe and reduces latency. Each API name may return a different endpoint URL, so cache per (stream + API name), not just per stream.

Stream retention and data availability

The DataRetentionInHours setting controls how long fragments are stored and therefore retrievable:

Changing retention on an existing stream is non-destructive for existing data — increasing retention extends the window for new fragments; decreasing it allows older fragments to be garbage-collected but doesn't immediately delete them. Use UpdateDataRetentionCommand with an Operation of "INCREASE_DATA_RETENTION" or "DECREASE_DATA_RETENTION".

import { UpdateDataRetentionCommand } from "@aws-sdk/client-kinesis-video";

await kv.send(new UpdateDataRetentionCommand({
  StreamName: "factory-cam-01",
  CurrentVersion: StreamInfo.Version, // must match current version — prevents conflicts
  Operation: "INCREASE_DATA_RETENTION",
  DataRetentionChangeInHours: 24, // add 24 hours to current retention
}));

Stream tags and discovery

Tags enable fleet-level stream discovery and cost attribution. MCP tools that manage cameras across a fleet can use tags to find streams by location, device type, or environment:

import { TagStreamCommand, ListTagsForStreamCommand, UntagStreamCommand } from "@aws-sdk/client-kinesis-video";

// Add or update tags (up to 50 per stream)
await kv.send(new TagStreamCommand({
  StreamName: "factory-cam-01",
  Tags: {
    CameraModel: "Hikvision-DS-2CD2347",
    Floor: "2",
    LineId: "assembly-3",
    MCPManagedBy: "factory-vision-agent",
  },
}));

// List tags to filter in your MCP tool
const { Tags } = await kv.send(new ListTagsForStreamCommand({
  StreamName: "factory-cam-01",
}));
console.log("Tags:", Tags);

// Remove a specific tag
await kv.send(new UntagStreamCommand({
  StreamName: "factory-cam-01",
  TagKeyList: ["MCPManagedBy"],
}));

IAM setup for MCP server video access

KVS uses the kinesisvideo: IAM action prefix. The minimum policy for an MCP tool that only reads archived video differs from one that also writes (ingests) video:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "KVSControlPlane",
      "Effect": "Allow",
      "Action": [
        "kinesisvideo:DescribeStream",
        "kinesisvideo:ListStreams",
        "kinesisvideo:GetDataEndpoint",
        "kinesisvideo:ListTagsForStream"
      ],
      "Resource": "arn:aws:kinesisvideo:us-east-1:*:stream/factory-*/*"
    },
    {
      "Sid": "KVSArchivedMediaRead",
      "Effect": "Allow",
      "Action": [
        "kinesisvideo:GetHLSStreamingSessionURL",
        "kinesisvideo:GetDASHStreamingSessionURL",
        "kinesisvideo:GetMediaForFragmentList",
        "kinesisvideo:ListFragments",
        "kinesisvideo:GetMedia"
      ],
      "Resource": "arn:aws:kinesisvideo:us-east-1:*:stream/factory-*/*"
    }
  ]
}

For write access (PutMedia from an IoT device), add "kinesisvideo:PutMedia" to a separate statement. Keep write-only devices on a separate IAM role from read-only MCP tools — this limits blast radius if either credential is compromised.

Key gotchas at a glance

Continue in this series

Related AWS media and ML guides: Rekognition label detection for MCP servers · Kinesis Data Streams for MCP servers · AWS IoT Core for MCP servers · CloudWatch monitoring for MCP servers