Guide · Amazon Personalize · Datasets & Solution Training

Amazon Personalize for MCP Servers — Recommendation Datasets, Schema Design, and Solution Training

Amazon Personalize is a fully managed ML service that delivers personalized recommendations without requiring data science expertise. For MCP server teams, it enables tools that surface relevant items — documents, actions, products, API endpoints, or commands — based on each user's interaction history. This guide covers the @aws-sdk/client-personalize management-plane SDK: creating dataset groups, designing Avro schemas with reserved field names, uploading interaction data from S3, selecting recipes, training solution versions, and deploying campaigns that the runtime SDK calls will then invoke.

TL;DR

Personalize has two SDKs: @aws-sdk/client-personalize (management — create resources, train models) and @aws-sdk/client-personalize-runtime (inference — get recommendations). The minimum viable setup is: create a dataset group → create an Interactions schema → create an Interactions dataset → upload interaction data from S3 → create a solution with a recipe → create a solution version (the actual training run) → create a campaign pointing at the solution version. The campaign ARN is what your runtime calls use. Training a solution version takes 20–90 minutes; poll DescribeSolutionVersionCommand until status === "ACTIVE".

Why MCP servers benefit from built-in personalization

LLM-powered agents executing multi-step tasks need to decide what to do next from large option spaces. Without personalization, agents either use static ordering (alphabetical, by popularity, by recency) or ask the user to choose explicitly. Personalize adds a third path: rank by predicted relevance for this specific user based on their interaction history.

Concrete MCP tool use cases for Personalize:

Personalize runs entirely within your AWS account — no data leaves to external ML platforms, the IAM boundary controls who can invoke it, and VPC endpoints eliminate public internet exposure.

Two SDK packages, two planes

Install both before starting:

npm install @aws-sdk/client-personalize @aws-sdk/client-personalize-runtime

The management client handles resource lifecycle:

import { PersonalizeClient } from "@aws-sdk/client-personalize";

const personalize = new PersonalizeClient({ region: "us-east-1" });

The runtime client handles inference:

import { PersonalizeRuntimeClient } from "@aws-sdk/client-personalize-runtime";

const runtime = new PersonalizeRuntimeClient({ region: "us-east-1" });

Runtime calls go to a different endpoint (personalize-runtime.us-east-1.amazonaws.com) and have different IAM actions (personalize:GetRecommendations vs personalize:CreateDatasetGroup). Separate the execution roles in your IAM policies accordingly — the MCP server's inference role needs only runtime permissions; the provisioning role used during setup needs management permissions.

Dataset groups

A dataset group is the top-level container for all Personalize resources. Everything else — schemas, datasets, solutions, campaigns — belongs to a single dataset group. Dataset groups are regional and cannot share resources across regions.

import { CreateDatasetGroupCommand } from "@aws-sdk/client-personalize";

const { datasetGroupArn } = await personalize.send(new CreateDatasetGroupCommand({
  name: "mcp-tools-recommendations",
  // For domain-specific recommenders, set domain here:
  // domain: "ECOMMERCE" | "VIDEO_ON_DEMAND"
  // For custom recipes (aws-user-personalization, aws-similar-items, etc.), omit domain.
  tags: [{ tagKey: "mcp-server", tagValue: "true" }],
}));

console.log("Dataset group ARN:", datasetGroupArn);
// arn:aws:personalize:us-east-1:123456789012:dataset-group/mcp-tools-recommendations

Poll for readiness before creating datasets:

import { DescribeDatasetGroupCommand } from "@aws-sdk/client-personalize";

let status = "";
while (status !== "ACTIVE") {
  const resp = await personalize.send(new DescribeDatasetGroupCommand({
    datasetGroupArn,
  }));
  status = resp.datasetGroup!.status!;
  if (status === "CREATE FAILED") throw new Error(resp.datasetGroup!.failureReason ?? "Dataset group creation failed");
  if (status !== "ACTIVE") await new Promise(r => setTimeout(r, 5000));
}

Dataset group names must be unique within an account and region. The ARN format is arn:aws:personalize:{region}:{account}:dataset-group/{name}.

Schema design for the Interactions dataset

Schemas use Apache Avro JSON format. The Interactions dataset is the only required dataset — without it, no model can be trained. It must contain exactly these three reserved fields:

Optional reserved interaction fields that unlock additional ML signal:

const interactionsSchema = {
  type: "record",
  name: "Interactions",
  namespace: "com.amazonaws.personalize.schema",
  fields: [
    { name: "USER_ID",       type: "string" },
    { name: "ITEM_ID",       type: "string" },
    { name: "TIMESTAMP",     type: "long" },
    { name: "EVENT_TYPE",    type: "string" },
    { name: "EVENT_VALUE",   type: ["null", "float"], default: null },
    { name: "IMPRESSION",    type: ["null", "string"], default: null },
  ],
  version: "1.0",
};

const { schemaArn } = await personalize.send(new CreateSchemaCommand({
  name: "mcp-interactions-schema",
  schema: JSON.stringify(interactionsSchema),
}));

Three important constraints to know before writing your first schema:

  1. Field names must exactly match the reserved names (all uppercase with underscores). user_id will not be recognized as USER_ID.
  2. TIMESTAMP must be Unix epoch seconds, not milliseconds. Millisecond timestamps cause Personalize to interpret all events as being from the year 33000+, which silently corrupts the temporal signal the model uses for recency weighting.
  3. Nullable fields in Avro use the union syntax ["null", "float"] with default: null. Fields declared as simply "float" must be present in every row — missing values cause the import job to fail.

Items and Users schemas (optional but high-value)

The Items dataset adds metadata that improves cold-start performance for new items. The Users dataset adds demographic or account-tier signals. Both are optional but strongly recommended when you have the data.

// Items schema — replace CATEGORY, CONTENT_TYPE with your actual metadata fields
const itemsSchema = {
  type: "record",
  name: "Items",
  namespace: "com.amazonaws.personalize.schema",
  fields: [
    { name: "ITEM_ID",       type: "string" },
    { name: "CATEGORY",      type: ["null", "string"], default: null,
      metadata: { categorical: true } },        // categorical hint improves embeddings
    { name: "CONTENT_TYPE",  type: ["null", "string"], default: null,
      metadata: { categorical: true } },
    { name: "CREATION_TIMESTAMP", type: ["null", "long"], default: null }, // reserved: used for cold-start temporal modeling
  ],
  version: "1.0",
};

// Users schema
const usersSchema = {
  type: "record",
  name: "Users",
  namespace: "com.amazonaws.personalize.schema",
  fields: [
    { name: "USER_ID",   type: "string" },
    { name: "PLAN_TIER", type: ["null", "string"], default: null,
      metadata: { categorical: true } },        // "free" | "author" | "team" | "enterprise"
  ],
  version: "1.0",
};

CREATION_TIMESTAMP in the Items schema is a reserved field name. When present, Personalize uses it to model item age, weight older items less aggressively in cold-start, and handle item lifecycle decay. It must be Unix epoch seconds if populated.

The metadata: { categorical: true } annotation on string fields tells the training job to embed them as discrete categories rather than as free-text tokens. Always set this for fields with a bounded enum of values (plan tiers, item categories, content types). Do not set it for high-cardinality text fields like descriptions.

Creating datasets and importing from S3

Once schemas are created, create the dataset containers and then import data via S3:

import { CreateDatasetCommand, CreateDatasetImportJobCommand } from "@aws-sdk/client-personalize";

// Create the Interactions dataset container
const { datasetArn } = await personalize.send(new CreateDatasetCommand({
  name: "mcp-interactions",
  datasetType: "Interactions",    // "Interactions" | "Items" | "Users"
  datasetGroupArn,
  schemaArn,
}));

// Upload a CSV file to S3 first, then import:
// CSV header must match schema field names exactly (same case)
// USER_ID,ITEM_ID,TIMESTAMP,EVENT_TYPE
// user-42,tool-search-mcp,1746000000,invoke
// user-42,tool-read-mcp,1746000120,invoke

const { datasetImportJobArn } = await personalize.send(new CreateDatasetImportJobCommand({
  jobName:    "mcp-interactions-import-v1",
  datasetArn,
  dataSource: { dataLocation: "s3://my-bucket/personalize/interactions.csv" },
  roleArn:    "arn:aws:iam::123456789012:role/PersonalizeS3Role",
  importMode: "FULL",    // "FULL" replaces all existing data; "INCREMENTAL" appends
}));

The roleArn must have s3:GetObject permission on the data location and have Personalize as a trusted service:

// Trust policy for the Personalize S3 import role
{
  "Effect": "Allow",
  "Principal": { "Service": "personalize.amazonaws.com" },
  "Action": "sts:AssumeRole"
}

// Permissions policy
{
  "Effect": "Allow",
  "Action": ["s3:GetObject", "s3:ListBucket"],
  "Resource": [
    "arn:aws:s3:::my-bucket",
    "arn:aws:s3:::my-bucket/personalize/*"
  ]
}

Poll the import job until it completes:

import { DescribeDatasetImportJobCommand } from "@aws-sdk/client-personalize";

let importStatus = "";
while (!["ACTIVE", "CREATE FAILED"].includes(importStatus)) {
  const resp = await personalize.send(new DescribeDatasetImportJobCommand({
    datasetImportJobArn,
  }));
  importStatus = resp.datasetImportJob!.status!;
  if (importStatus !== "ACTIVE") await new Promise(r => setTimeout(r, 15_000));
}
if (importStatus === "CREATE FAILED") {
  throw new Error("Import failed — check S3 path, role permissions, and CSV format");
}

Import job durations depend on dataset size: a 1 million row CSV typically takes 5–15 minutes. The minimum dataset requirement for training is 1,000 unique interactions across 25 unique users and 25 unique items — smaller datasets produce low-quality models and may fail training entirely.

Selecting a recipe

A recipe is a pre-built ML algorithm. Personalize ships six built-in recipes for custom dataset groups:

Recipe ARN (us-east-1)Use caseRequired input at inference
arn:aws:personalize:::recipe/aws-user-personalization Recommend items for a specific user based on history userId
arn:aws:personalize:::recipe/aws-similar-items Find items similar to a given item (collaborative + content-based) itemId
arn:aws:personalize:::recipe/aws-personalized-ranking Re-rank a provided list of items for a specific user userId + inputList of item IDs
arn:aws:personalize:::recipe/aws-popularity-count Recommend most popular items (no user-specific signal) None required
arn:aws:personalize:::recipe/aws-item-affinity Score users' affinity for a given item (reverse of user-personalization) itemId
arn:aws:personalize:::recipe/aws-item-attribute-affinity Score users' affinity for item attributes (requires Items dataset) userId + attribute name

Recipe ARNs do not include a region segment — the triple-colon arn:aws:personalize:::recipe/… format is correct and the same across all regions.

Training a solution and solution version

A solution binds a dataset group to a recipe. A solution version is the result of one training run. You need a solution version to create a campaign:

import { CreateSolutionCommand, CreateSolutionVersionCommand,
         DescribeSolutionVersionCommand } from "@aws-sdk/client-personalize";

// Step 1: create the solution (configuration only — no training yet)
const { solutionArn } = await personalize.send(new CreateSolutionCommand({
  name:           "mcp-user-personalization",
  datasetGroupArn,
  recipeArn:      "arn:aws:personalize:::recipe/aws-user-personalization",
  solutionConfig: {
    // User-personalization has built-in exploration; tune explorationWeight here
    algorithmHyperParameters: {
      // Defaults are usually fine; override only after baseline testing
    },
    featureTransformationParameters: {},
    // autoMLConfig omitted — only needed if you want Personalize to pick the recipe
  },
}));

// Step 2: start training (this triggers the actual ML job)
const { solutionVersionArn } = await personalize.send(new CreateSolutionVersionCommand({
  solutionArn,
  trainingMode: "FULL",   // "FULL" or "UPDATE"
  // "UPDATE" only works for aws-user-personalization; faster incremental re-train
}));

// Step 3: poll until ACTIVE (20–90 minutes for most datasets)
let svStatus = "";
while (svStatus !== "ACTIVE") {
  const resp = await personalize.send(new DescribeSolutionVersionCommand({
    solutionVersionArn,
  }));
  svStatus = resp.solutionVersion!.status!;
  if (svStatus === "CREATE FAILED") {
    throw new Error(resp.solutionVersion!.failureReason ?? "Solution version training failed");
  }
  if (svStatus !== "ACTIVE") await new Promise(r => setTimeout(r, 60_000));
}

console.log("Training complete. SolutionVersionArn:", solutionVersionArn);

Training costs: Personalize charges per training hour. A solution version for a 1 million interaction dataset typically trains in 20–40 minutes at ~$0.24/hour per training node. Training time scales sub-linearly with dataset size. The FULL mode retrains from scratch; the UPDATE mode (aws-user-personalization only) runs an incremental pass on recent interactions, completing in 5–15 minutes.

Deploying a campaign

A campaign is the hosted endpoint that serves real-time recommendations. It wraps a solution version and provisions throughput capacity:

import { CreateCampaignCommand, DescribeCampaignCommand } from "@aws-sdk/client-personalize";

const { campaignArn } = await personalize.send(new CreateCampaignCommand({
  name:               "mcp-recommendations-prod",
  solutionVersionArn,
  minProvisionedTPS:  1,     // minimum transactions per second; billing floor
  campaignConfig: {
    itemExplorationConfig: {
      explorationWeight:         "0.3",   // 0=exploit fully, 1=explore fully; default 0.3
      explorationItemAgeCutOff:  "30",    // days; items older than this excluded from exploration
    },
  },
}));

// Poll until ACTIVE (~5 minutes)
let campaignStatus = "";
while (campaignStatus !== "ACTIVE") {
  const resp = await personalize.send(new DescribeCampaignCommand({ campaignArn }));
  campaignStatus = resp.campaign!.status!;
  if (campaignStatus !== "ACTIVE") await new Promise(r => setTimeout(r, 10_000));
}

console.log("Campaign live. CampaignArn:", campaignArn);

minProvisionedTPS is the billing floor — you are billed for at least this many TPS whether or not you use them. Set it to 1 for development, 5–10 for production workloads, or higher if your MCP server receives burst traffic. If actual traffic exceeds minProvisionedTPS, Personalize auto-scales up and charges for the additional capacity at $0.0048 per TPS-hour.

To update a campaign to point at a new solution version after retraining:

import { UpdateCampaignCommand } from "@aws-sdk/client-personalize";

await personalize.send(new UpdateCampaignCommand({
  campaignArn,
  solutionVersionArn: newSolutionVersionArn,
  minProvisionedTPS:  2,   // optionally adjust capacity at the same time
}));

During the update, the campaign continues serving the old solution version with no downtime. The cutover to the new version happens atomically when the update completes.

Pricing summary

For a development campaign at 1 TPS running 24/7, the monthly hosting cost is approximately $0.20 × 720 hours ≈ $144/month. For MCP server teams building an internal tool, consider sharing a single campaign across all tool calls rather than creating per-tool campaigns.