Blog · Amazon Forecast · Production Guide
Amazon Forecast for MCP Server Teams: Two SDKs, Five Gotchas, and the Full Forecasting Pipeline
Amazon Forecast is AWS's fully managed time-series prediction service. Trained on your historical endpoint metrics — request counts, latency percentiles, error rates — it returns probabilistic forecasts across p10/p50/p90 quantiles. For MCP server teams, this means knowing before your users do when traffic will spike, when a maintenance window is safe, and when an endpoint is trending toward failure. This guide synthesizes the full Amazon Forecast pipeline from dataset group creation through QueryForecastCommand runtime calls, with five production gotchas extracted from hands-on experience.
Why predictive monitoring changes what's possible for MCP servers
Most MCP monitoring — including AliveMCP's core 60-second ping loop — is reactive. You learn a server is down after it goes down. That model works well for incident detection but leaves a class of problems unsolved:
- Load spikes arrive before autoscaling can respond. If you provision based on current traffic, you're always one spike behind. Forecast tells you what traffic will look like in the next 4–24 hours, so you can pre-warm capacity.
- Maintenance windows are chosen by gut feeling. "Sunday at 3am" may feel low-traffic, but it might coincide with a scheduled batch job that calls your MCP server heavily. A p50 demand forecast for the next 7 days identifies the actual quietest windows.
- Static alerting thresholds produce noise. A threshold of 500 req/min that fires every Monday morning isn't an incident — it's a weekly cycle. Replacing static thresholds with p90 upper bands means alerts fire when actual traffic exceeds what the model expects, not when it exceeds an arbitrary constant.
- Gradual degradation is invisible until it isn't. When p90 latency slowly drifts upward over three weeks, reactive monitoring misses it because no single spike triggers the threshold. A widening prediction interval — where the gap between p10 and p90 grows week over week — is an early structural signal worth investigating.
Amazon Forecast adds this predictive layer without requiring your team to build or maintain ML infrastructure. Models train in AWS's managed environment; your MCP server tools query forecasts via a single API call that completes in under 100 ms.
The two-SDK split: management plane vs query plane
The first thing to understand about Amazon Forecast is that it uses two separate npm packages that cannot be interchanged. This is not a quirk — it reflects a fundamental architectural split:
npm install @aws-sdk/client-forecast @aws-sdk/client-forecastquery
The management client handles everything related to resource lifecycle: creating dataset groups, defining schemas, running import jobs, training predictors, and generating forecast artifacts. It talks to forecast.<region>.amazonaws.com:
import { ForecastClient } from "@aws-sdk/client-forecast";
const forecast = new ForecastClient({ region: "us-east-1" });
The query client handles runtime inference — reading prediction values for a specific item at a specific time. It talks to a different endpoint, forecastquery.<region>.amazonaws.com, and uses a different IAM action namespace (forecast:QueryForecast, not forecast:Describe*):
import { ForecastQueryClient } from "@aws-sdk/client-forecastquery";
const forecastQuery = new ForecastQueryClient({ region: "us-east-1" });
Attempting to call QueryForecastCommand from the management ForecastClient produces a "command not found" error at import time — it's not a runtime API error, it's a missing export. If you see this, you've imported from the wrong package.
The practical implication for MCP server architecture: use two distinct IAM roles. A provisioning role with forecast:Create* permissions runs the setup and training pipeline (typically in a one-time setup script or CI job). An inference role with only forecast:QueryForecast is what your running MCP server uses at request time. See the IAM roles guide for the trust policy pattern.
The five-stage pipeline at a glance
Every Amazon Forecast workflow follows a linear sequence. Each stage produces an ARN that the next stage references. Nothing is implicit — if you skip a step or fail to wire resources together, the predictor trains on incomplete data without warning.
| # | Stage | Command | Typical wait |
|---|---|---|---|
| 1 | Dataset group | CreateDatasetGroupCommand | < 10 seconds |
| 2a | Dataset schema | CreateDatasetCommand | < 10 seconds |
| 2b | Data import | CreateDatasetImportJobCommand | 5–30 minutes |
| 2c | Wire to group | UpdateDatasetGroupCommand | < 10 seconds |
| 3 | Predictor training | CreateAutoMLPredictorCommand | 20–90 minutes |
| 4 | Forecast generation | CreateForecastCommand | 10–30 minutes |
| 5 | Runtime query | QueryForecastCommand | < 100 ms |
The first four stages are setup work — you do them once (or on a nightly schedule for fresh predictions). Only stage 5 runs in your MCP server's hot path.
Stage 1: Creating the dataset group
The dataset group is the top-level container. Its most important parameter is Domain, which determines what built-in signals Forecast can add and what schema conventions apply. For MCP server metrics, CUSTOM or WEB_TRAFFIC are the right choices:
import { CreateDatasetGroupCommand } from "@aws-sdk/client-forecast";
const { DatasetGroupArn } = await forecast.send(new CreateDatasetGroupCommand({
DatasetGroupName: "mcp-endpoint-traffic",
Domain: "CUSTOM",
Tags: [{ Key: "project", Value: "alivemcp" }],
}));
Domain is immutable after creation. If you later decide you want the WEB_TRAFFIC domain's built-in holiday calendar, you must create a new dataset group and re-import all data. For most MCP server use cases, CUSTOM is better because it doesn't constrain your schema; you can still add holiday calendar signals at the predictor stage without changing the domain.
Domain selection reference for MCP server teams:
| Domain | Best for MCP use cases | Built-in signals |
|---|---|---|
CUSTOM | Endpoint metrics, error rates, arbitrary KPIs — maximum schema flexibility | None (add calendar/weather at predictor stage) |
WEB_TRAFFIC | Request-per-minute endpoint traffic with holiday patterns | Holiday calendar (US by default) |
METRICS | High-frequency financial or business metrics (< hourly) | None |
Stage 2a: Dataset schema design — Gotcha #1: lowercase attribute names
This is the most common first-hour mistake. Amazon Forecast requires schema attribute names to be lowercase. The reserved column names for the target time series are item_id, timestamp, and target_value — not ITEM_ID, not ItemId, not TARGET_VALUE. If you're coming from DynamoDB (which uses uppercase conventional names) or Amazon Personalize (which uses USER_ID, ITEM_ID), this is easy to get wrong.
import { CreateDatasetCommand } from "@aws-sdk/client-forecast";
const { DatasetArn } = await forecast.send(new CreateDatasetCommand({
DatasetName: "mcp-endpoint-requests",
Domain: "CUSTOM",
DatasetType: "TARGET_TIME_SERIES",
DataFrequency: "H", // hourly data
Schema: {
Attributes: [
{ AttributeName: "item_id", AttributeType: "string" }, // lowercase
{ AttributeName: "timestamp", AttributeType: "timestamp" },
{ AttributeName: "target_value", AttributeType: "float" },
// Optional extra covariate — also lowercase:
{ AttributeName: "error_rate", AttributeType: "float" },
],
},
}));
The validation error when you use uppercase is "Invalid schema" — not "attribute names must be lowercase." Always verify case first when you see this error.
What to put in item_id and target_value for MCP server monitoring:
item_id: your endpoint slug (e.g.,"weather-mcp-prod","maps-mcp-prod"). One item per unique MCP endpoint you want to forecast independently.target_value: the metric you want to predict — request count per hour, p95 latency in milliseconds, or error rate percentage. Choose one; you can't change it after dataset creation without deleting and recreating the dataset.
Forecast supports three dataset types within a dataset group. Only the target time series is required:
- TARGET_TIME_SERIES — the values to predict. The required dataset.
- RELATED_TIME_SERIES — additional covariates that co-vary with the target (e.g., upstream dependency error rates, deployment event flags). Must cover the same items and time range, plus extend through the forecast horizon.
- ITEM_METADATA — static per-item attributes (e.g., endpoint category: REST/SSE/stdio, cloud provider, region). Becomes categorical features in the model.
More detail in the dataset import guide.
Stage 2b: Importing data — Gotcha #2: TimestampFormat mismatch silently imports zero rows
Upload your CSV to S3 (no header row; column order must match the schema Attributes array), then run the import job:
import { CreateDatasetImportJobCommand } from "@aws-sdk/client-forecast";
const { DatasetImportJobArn } = await forecast.send(new CreateDatasetImportJobCommand({
DatasetImportJobName: "mcp-target-2026-import",
DatasetArn,
DataSource: {
S3Config: {
Path: "s3://my-forecast-data/mcp-endpoints/",
RoleArn: "arn:aws:iam::123456789012:role/ForecastS3ReadRole",
},
},
TimestampFormat: "yyyy-MM-dd HH:mm:ss",
ImportMode: "FULL",
}));
Now for the second gotcha: if TimestampFormat doesn't match your CSV data character-for-character, the import job will return Status: "ACTIVE" with zero rows imported. No error. No warning. The job succeeds; your data never makes it in.
The fix is to verify row counts after every import using FieldStatistics:
import { DescribeDatasetImportJobCommand } from "@aws-sdk/client-forecast";
// Poll until complete
let importJob;
while (true) {
importJob = await forecast.send(new DescribeDatasetImportJobCommand({
DatasetImportJobArn,
}));
if (importJob.Status === "ACTIVE" || importJob.Status === "CREATE_FAILED") break;
await new Promise(r => setTimeout(r, 30_000));
}
if (importJob.Status === "CREATE_FAILED") {
throw new Error(`Import failed: ${importJob.Message}`);
}
// CRITICAL verification step — always check this
const count = importJob.FieldStatistics?.target_value?.Count;
if (!count || count === 0) {
throw new Error(
`Import succeeded but imported 0 rows. ` +
`Check TimestampFormat: "${importJob.TimestampFormat}" ` +
`vs your actual CSV format.`
);
}
console.log(`Imported ${count} rows successfully.`);
The common timestamp format mistakes that trigger this trap:
| CSV example | Correct format | Common mistake |
|---|---|---|
2026-01-15 14:00:00 | yyyy-MM-dd HH:mm:ss | yyyy-MM-dd HH:mm (missing :ss) |
2026-01-15 | yyyy-MM-dd | yyyy/MM/dd (wrong separator) |
2026-01-15T14:00:00 | yyyy-MM-dd'T'HH:mm:ss | yyyy-MM-dd HH:mm:ss (space vs T literal) |
01/15/2026 14:00 | MM/dd/yyyy HH:mm | dd/MM/yyyy HH:mm (day/month order) |
Stage 2c: Wire datasets into the dataset group
Creating a dataset with CreateDatasetCommand does not automatically associate it with a dataset group. If you skip this step, the predictor trains without that dataset — no error, just reduced accuracy:
import { UpdateDatasetGroupCommand } from "@aws-sdk/client-forecast";
await forecast.send(new UpdateDatasetGroupCommand({
DatasetGroupArn,
DatasetArns: [
targetDatasetArn,
relatedDatasetArn, // optional
metadataDatasetArn, // optional
],
}));
The predictor at training time reads the DatasetGroupArn and discovers all associated datasets automatically. If you later add a related time series or item metadata dataset, update the group and create a new predictor — existing predictors don't pick up new datasets.
Stage 3: Predictor training — Gotcha #3: ForecastHorizon is in DataFrequency units, not wall-clock hours
Use CreateAutoMLPredictorCommand, not the legacy CreatePredictorCommand. AutoPredictor evaluates multiple algorithms (DeepAR+, CNN-QR, Prophet, ARIMA, ETS, NPTS) and ensembles the best combination:
import { CreateAutoMLPredictorCommand } from "@aws-sdk/client-forecast";
const { PredictorArn } = await forecast.send(new CreateAutoMLPredictorCommand({
PredictorName: "mcp-endpoint-traffic-predictor-v1",
ForecastHorizon: 24, // 24 × DataFrequency units ahead
ForecastFrequency: "H", // must match the target dataset's DataFrequency
DataConfig: {
DatasetGroupArn,
AttributeConfigs: [
{
AttributeName: "target_value",
Transformations: {
"filling": "zero", // request counts: missing = no traffic, fill with 0
// For latency metrics: use "median" or "value" — not "zero" (zero latency is impossible)
},
},
],
AdditionalDatasets: [
{
Name: "CALENDAR_ASSOCIATED_DATA",
Configuration: { CountryCode: ["US"] },
},
],
},
ExplainPredictor: true,
}));
The gotcha: ForecastHorizon is a count of ForecastFrequency steps, not a count of hours. If your data is daily (DataFrequency: "D"), then ForecastHorizon: 24 means predict 24 days ahead — not 24 hours. If your data is hourly, ForecastHorizon: 24 correctly means 24 hours. Getting this wrong means your forecast covers a completely different time window than intended, which you won't discover until you try to query and find the results don't match your expectations.
| ForecastFrequency | ForecastHorizon: 24 | ForecastHorizon: 168 |
|---|---|---|
"1min" | 24 minutes ahead | 2.8 hours ahead |
"5min" | 2 hours ahead | 14 hours ahead |
"H" | 24 hours ahead | 7 days ahead |
"D" | 24 days ahead | 168 days (~24 weeks) ahead |
Gotcha #4: DescribeAutoPredictorCommand, not DescribePredictorCommand
Predictors created with CreateAutoMLPredictorCommand must be polled with DescribeAutoPredictorCommand. Using the legacy DescribePredictorCommand on an AutoPredictor ARN returns ResourceNotFoundException. This is a frequent source of confusion because both describe commands exist and look identical in the API:
import { DescribeAutoPredictorCommand } from "@aws-sdk/client-forecast";
// NOT: DescribePredictorCommand — that's for the legacy CreatePredictorCommand API
async function waitForPredictor(PredictorArn) {
while (true) {
const { Status, Message } = await forecast.send(
new DescribeAutoPredictorCommand({ PredictorArn })
);
if (Status === "ACTIVE") return;
if (Status === "CREATE_FAILED") throw new Error(`Training failed: ${Message}`);
console.log(`Predictor ${Status}...`);
await new Promise(r => setTimeout(r, 120_000)); // 2-minute poll — training takes 20-90 min
}
}
CALENDAR_ASSOCIATED_DATA vs WEATHER_INDEX
The holiday calendar signal (CALENDAR_ASSOCIATED_DATA) is free, requires no schema changes, and helps the model recognize that traffic drops on public holidays are systematic rather than noise. It's the right choice for most MCP server teams.
The weather index (WEATHER_INDEX) adds temperature, precipitation, and wind speed as covariates. It requires a geolocation attribute in your target time series schema formatted as "latitude,longitude" (latitude first — the opposite of GeoJSON's longitude-first convention). Using longitude-first format silently assigns weather from the wrong geographic location.
For developer-tool MCP servers, the holiday calendar typically provides more lift than weather signals — developer activity drops on public holidays, not on rainy days. Add weather only if you have a domain-specific reason to believe it correlates with endpoint usage.
Missing value fills: choosing the right strategy
When your target time series has gaps — timestamps present for some items but absent for others — the AttributeConfigs.Transformations.filling strategy controls how they're handled during training:
| Strategy | Use for | Avoid when |
|---|---|---|
"zero" | Request counts: missing time step = no traffic (endpoint was quiet) | Latency metrics — zero latency is physically impossible, corrupts training |
"median" | Sparse metrics where gaps mean "no change" rather than zero | High-volume dense data where median fill would mask real seasonality |
"mean" | Dense data with occasional gaps | Skewed distributions where mean is misleading |
"nan" | Items with intentional gaps (endpoint was offline, monitoring paused) | Items with frequent gaps — too many NaN rows degrade model quality |
"value" | Latency metrics with a known baseline (e.g., 500 ms timeout value) | When no sensible default value exists |
Reading accuracy metrics with GetAccuracyMetricsCommand
After training completes, Forecast backtests the model by withholding the most recent ForecastHorizon data points and measuring prediction accuracy:
import { GetAccuracyMetricsCommand } from "@aws-sdk/client-forecast";
const { PredictorEvaluationResults } = await forecast.send(
new GetAccuracyMetricsCommand({ PredictorArn })
);
for (const result of PredictorEvaluationResults) {
for (const window of result.TestWindows) {
const m = window.Metrics;
console.log({
WAPE: m.WAPE, // primary: 0.10–0.15 is excellent for MCP traffic
MASE: m.MASE, // must be < 1.0 — if > 1.0, model is worse than naïve seasonal baseline
RMSE: m.RMSE, // in target_value units — useful for capacity budget sizing
});
}
}
If MASE > 1.0, the AutoPredictor found no meaningful pattern. Common causes: insufficient history (need at least 2–4 seasonal cycles), very noisy data with no recurring structure, or a data quality problem in the import (verify row counts via FieldStatistics as described above).
Stage 4: Generating the forecast — Gotcha #5: ForecastTypes are decimal quantile strings
Once the predictor is ACTIVE, create a forecast artifact — this materializes predictions for all items in the dataset group:
import { CreateForecastCommand } from "@aws-sdk/client-forecast";
const { ForecastArn } = await forecast.send(new CreateForecastCommand({
ForecastName: "mcp-endpoint-forecast-2026-11-16",
PredictorArn,
// ForecastTypes: MUST be decimal quantile strings — not "p10" labels, not integers
ForecastTypes: ["0.1", "0.5", "0.9"],
Tags: [{ Key: "project", Value: "alivemcp" }],
}));
The fifth gotcha: ForecastTypes values are decimal probability strings — "0.1", not "p10" and not 10. The input format and output format differ: you request "0.1" at creation time, and the response from QueryForecastCommand returns the key p10. Passing ["p10","p50","p90"] produces a validation error. Passing integers produces a type error.
You can request any quantile from 0.01 to 0.99. For SLA tracking at the 99th percentile, add "0.99":
ForecastTypes: ["0.1", "0.5", "0.9", "0.99"]
// Response keys: predictions.p10, p50, p90, p99
Forecast generation takes 10–30 minutes for large datasets. Poll with DescribeForecastCommand:
import { DescribeForecastCommand } from "@aws-sdk/client-forecast";
async function waitForForecast(ForecastArn) {
while (true) {
const { Status, Message } = await forecast.send(
new DescribeForecastCommand({ ForecastArn })
);
if (Status === "ACTIVE") return;
if (Status === "CREATE_FAILED") throw new Error(`Forecast failed: ${Message}`);
await new Promise(r => setTimeout(r, 60_000));
}
}
await waitForForecast(ForecastArn);
See the full query guide for TimeSeriesSelector (limit forecast generation to a subset of items), batch export via CreateForecastExportJobCommand, and what-if scenario analysis.
Stage 5: QueryForecastCommand at runtime
Once the forecast is ACTIVE, your MCP server tools can query it on demand using the query client (the second npm package):
import { ForecastQueryClient, QueryForecastCommand } from "@aws-sdk/client-forecastquery";
const forecastQuery = new ForecastQueryClient({ region: "us-east-1" });
const response = await forecastQuery.send(new QueryForecastCommand({
ForecastArn,
Filters: {
item_id: "weather-mcp-prod",
},
// Optional: narrow to a window within the forecast horizon
// StartDate: "2026-11-17T00:00:00",
// EndDate: "2026-11-18T00:00:00",
}));
const { p10, p50, p90 } = response.Forecast.Predictions;
// p10 = [{ Timestamp: "2026-11-17T00:00:00", Value: 72 }, ...]
// p50 = [{ Timestamp: "2026-11-17T00:00:00", Value: 142 }, ...]
// p90 = [{ Timestamp: "2026-11-17T00:00:00", Value: 218 }, ...]
Query calls complete in under 100 ms — fast enough for MCP tool response paths. The result is a list of { Timestamp, Value } objects for each quantile, covering every time step in the forecast horizon.
Understanding and using the percentile bands
Amazon Forecast's probabilistic output is more useful than a single point estimate because it tells you not just what to expect but how certain the model is:
| Quantile | Interpretation | MCP server application |
|---|---|---|
p10 | Lower bound: actual value will exceed this 90% of the time | Minimum capacity floor for resource pre-allocation |
p50 | Median: actual will be above and below this roughly equally | Best single-number estimate for dashboards and reporting |
p90 | Upper bound: actual value will fall below this 90% of the time | Capacity ceiling for autoscaling triggers and incident budgeting |
Three practical applications for AliveMCP-style monitoring:
Forecast-aware alerting thresholds
Instead of alerting when request rate exceeds 500/min (a static threshold that fires every Monday morning), alert when the observed rate exceeds the p90 upper bound for the current hour. That means "current traffic is unusually high relative to what this endpoint typically sees at this time of week" — which is what you actually care about.
// Tool handler: check if current traffic is anomalous
async function isTrafficAnomalous(endpointSlug, currentRpm) {
const response = await forecastQuery.send(new QueryForecastCommand({
ForecastArn,
Filters: { item_id: endpointSlug },
StartDate: new Date().toISOString().slice(0, 19),
EndDate: new Date(Date.now() + 3600_000).toISOString().slice(0, 19),
}));
const p90AtNow = response.Forecast.Predictions.p90[0]?.Value;
return p90AtNow && currentRpm > p90AtNow;
}
Maintenance window identification
Query the p50 forecast for the next 7 days and find the lowest consecutive 2-hour window:
async function findMaintenanceWindow(endpointSlug) {
const response = await forecastQuery.send(new QueryForecastCommand({
ForecastArn,
Filters: { item_id: endpointSlug },
}));
const p50 = response.Forecast.Predictions.p50;
// Find the 2-hour window with the lowest total predicted traffic
let minTotal = Infinity;
let bestWindow = null;
for (let i = 0; i < p50.length - 1; i++) {
const total = p50[i].Value + p50[i + 1].Value;
if (total < minTotal) {
minTotal = total;
bestWindow = { start: p50[i].Timestamp, end: p50[i + 2]?.Timestamp };
}
}
return bestWindow;
}
Confidence interval width as an early warning signal
The gap between p90 and p10 (the interval width) measures model confidence. When this width grows significantly over consecutive forecasts — even when the p50 median looks stable — it means the model's uncertainty is increasing. For MCP endpoints, a widening interval often precedes a performance degradation event that hasn't yet crossed an alert threshold.
Store the p90−p10 width for each endpoint on each nightly forecast run. Alert when today's width is more than 2× the 30-day average width for that endpoint.
What-if analysis for capacity planning scenarios
Forecast supports scenario modeling — "what would the forecast look like if I modified a covariate?" This is useful for MCP server capacity planning questions like "what if we onboard a new enterprise client that doubles traffic on the weather endpoint?":
import {
CreateWhatIfAnalysisCommand,
CreateWhatIfForecastCommand,
} from "@aws-sdk/client-forecast";
// Step 1: create analysis container anchored to an existing forecast
const { WhatIfAnalysisArn } = await forecast.send(new CreateWhatIfAnalysisCommand({
WhatIfAnalysisName: "new-enterprise-client-scenario",
ForecastArn,
}));
// Step 2: define the scenario — multiply traffic by 2.0 for a specific endpoint
const { WhatIfForecastArn } = await forecast.send(new CreateWhatIfForecastCommand({
WhatIfForecastName: "double-traffic-weather-mcp",
WhatIfAnalysisArn,
TimeSeriesTransformations: [{
Action: {
AttributeName: "target_value",
Operation: "MULTIPLY",
Value: 2.0,
},
TimeSeriesConditions: [{
AttributeName: "item_id",
AttributeValue: "weather-mcp-prod",
Condition: "EQUALS",
}],
}],
}));
// Step 3: query the what-if forecast using the query client
// (QueryWhatIfForecastCommand is in @aws-sdk/client-forecastquery)
const { Forecast: { Predictions } } = await forecastQuery.send(
new QueryWhatIfForecastCommand({
WhatIfForecastArn,
Filters: { item_id: "weather-mcp-prod" },
})
);
console.log("2× traffic p90 scenario:", Predictions.p90);
What-if analysis is stateless from your production forecast — it creates a separate artifact you can query independently and then discard. It doesn't affect the base forecast.
Deletion order reference — Gotcha summary table
All five gotchas from this guide at a glance:
| # | Gotcha | Symptom | Fix |
|---|---|---|---|
| 1 | Uppercase schema attribute names | "Invalid schema" error on CreateDatasetCommand | Use item_id, timestamp, target_value — all lowercase |
| 2 | TimestampFormat mismatch | Import job returns ACTIVE with 0 rows; predictor trains on empty data | Verify FieldStatistics.target_value.Count > 0 after every import |
| 3 | ForecastHorizon in wrong units | Forecast covers 24 days instead of 24 hours (or vice versa) | Remember: ForecastHorizon × DataFrequency = total coverage window |
| 4 | DescribePredictorCommand on AutoPredictor ARN | ResourceNotFoundException when polling predictor status | Use DescribeAutoPredictorCommand for predictors created with CreateAutoMLPredictorCommand |
| 5 | ForecastTypes as "p10" labels or integers | Validation error on CreateForecastCommand | Use decimal strings: ["0.1","0.5","0.9"]; response keys are p10, p50, p90 |
Deletion order
All Forecast resources have dependency relationships. Deleting a parent while children exist returns ResourceInUseException. The correct order:
- Forecast export jobs (
DeleteForecastExportJobCommand) - What-if forecasts (
DeleteWhatIfForecastCommand), then what-if analyses (DeleteWhatIfAnalysisCommand) - Forecasts (
DeleteForecastCommand) - Explainability resources (
DeleteExplainabilityCommand) - Predictors (
DeletePredictorCommand) - Dataset import jobs (
DeleteDatasetImportJobCommand) - Datasets (
DeleteDatasetCommand) - Dataset group (
DeleteDatasetGroupCommand)
All delete operations are asynchronous. After calling any Delete*Command, poll the corresponding Describe*Command until it throws ResourceNotFoundException before proceeding to the next deletion step. This is covered in detail in the query and lifecycle guide.
IAM role architecture
Use two distinct roles to follow the principle of least privilege. This matters for MCP server security: an MCP server should never have permissions to modify or delete the forecasting infrastructure it depends on.
// Provisioning role (used in CI/CD or admin scripts — NOT in running MCP servers)
// Permissions: forecast:Create*, forecast:Delete*, forecast:Describe*,
// s3:GetObject, s3:ListBucket, s3:PutObject
// Inference role (used by running MCP server tools — narrow scope)
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["forecast:QueryForecast"],
"Resource": "arn:aws:forecast:us-east-1:123456789012:forecast/mcp-*"
}]
}
The S3 role used by import jobs (the RoleArn inside S3Config) must be assumable by the Forecast service principal ("forecast.amazonaws.com"). It needs s3:GetObject and s3:ListBucket for imports; add s3:PutObject only if you're running export jobs. See the IAM roles for MCP servers guide for the full trust policy pattern.
Pricing snapshot and cost management
Amazon Forecast costs are dominated by training and generation, not queries:
| Activity | Price | Notes |
|---|---|---|
| Dataset import | $0.088 / GB | Based on raw CSV size |
| Predictor training | $0.24 / compute-hour | AutoML trains multiple algorithms in parallel |
| Forecast generation | $1.00 / 1K time steps | Steps = items × horizon length |
| Forecast query | $0.01 / 1K queries | QueryForecastCommand calls at runtime |
| Free tier | First 10K time steps / month | Applies to both generation and query |
For 500 MCP endpoints with a 7-day hourly horizon (168 hours): 500 × 168 = 84,000 time steps = $0.084 per forecast run. Regenerating daily: $0.084 × 30 ≈ $2.52/month for generation, plus $0.01 per 1K queries. Training is the largest one-time cost — a typical AutoPredictor run takes 20–90 minutes at $0.24/hour, so $0.08–$0.36 per training run.
To control costs: use TimeSeriesSelector to generate forecasts only for high-priority endpoints, delete stale forecast artifacts after regeneration (they accumulate storage costs), and avoid scheduling training more frequently than weekly unless your endpoint mix changes significantly.
Rolling forecasts: the nightly regeneration pattern
Forecasts are static artifacts — they represent predictions as of when CreateForecastCommand ran. For rolling horizon predictions, schedule nightly forecast regeneration and swap the ARN your query calls use:
// Nightly job (runs in a separate process, not in the MCP server):
// 1. Run incremental import job (ImportMode: "INCREMENTAL") with the previous day's data
// 2. Create new forecast: CreateForecastCommand → new ForecastArn
// 3. Poll until ACTIVE
// 4. Update your config/environment with the new ForecastArn
// 5. Delete the previous forecast to avoid storage accumulation
// MCP server reads ForecastArn from environment at startup:
const forecastArn = process.env.FORECAST_ARN;
Alternatively, use RetrainingFrequency on the CreateAutoMLPredictorCommand for automatic predictor retraining on a schedule ("D", "W", "M"). Note that retraining updates the predictor but does not automatically generate a new forecast — you still need to create new forecast artifacts explicitly after each retraining cycle.
Connecting this to MCP server observability
Amazon Forecast fits naturally alongside the other observability tools in the MCP monitoring stack:
- CloudWatch for real-time metrics, alarms, and dashboards — the reactive layer. Use CloudWatch to detect current problems; use Forecast to predict future ones.
- Prometheus for multi-endpoint metric aggregation and long-term retention — the data source for Forecast training data. Export Prometheus metrics to S3 as CSVs for Forecast import jobs.
- Kinesis Firehose for real-time event streaming to S3 — a natural pipeline for continuous data delivery to the Forecast import bucket.
- SageMaker endpoints for custom ML models when Amazon Forecast's built-in algorithms don't fit your use case (e.g., anomaly detection models, root-cause analysis).
For teams already using AliveMCP's uptime monitoring, the AliveMCP ping history is itself a time series suitable for Forecast training. If you export your endpoint's uptime history (1 = healthy, 0 = down) at hourly granularity, Forecast can predict which hours have elevated downtime probability — turning historical outage patterns into forward-looking maintenance guidance. For comparison, the Amazon Personalize guide covers a parallel ML service for recommendation use cases rather than forecasting.
Summary: the five gotchas and their fixes
Building with Amazon Forecast for MCP server teams comes down to five non-obvious behaviors that waste hours if you don't know about them:
- Lowercase attribute names —
item_id,timestamp,target_value— not uppercase, not CamelCase. The error message doesn't say this. - TimestampFormat mismatch succeeds silently — the import job returns ACTIVE with zero rows loaded. Always verify
FieldStatistics.target_value.Countafter every import. - ForecastHorizon is in DataFrequency steps, not hours — with daily data,
ForecastHorizon: 24means 24 days. Confirm the coverage window before training. - DescribeAutoPredictorCommand, not DescribePredictorCommand — using the wrong describe command on an AutoPredictor ARN returns ResourceNotFoundException.
- ForecastTypes must be decimal strings —
["0.1","0.5","0.9"]at input time; response keys arep10,p50,p90. Strings, not integers, not "p10" labels.
With these patterns in hand, the full pipeline — from dataset group creation through runtime QueryForecastCommand calls in MCP server tools — runs cleanly on first try. See the individual guides in this series for deeper coverage of each stage.
Full Amazon Forecast series
- Pipeline overview — two-SDK split, five-stage pipeline, domain selection, pricing
- Dataset import and schema design — CreateDatasetCommand, S3 CSV format, timestamp format matching, missing value fills
- Predictor training and AutoML — CreateAutoMLPredictorCommand, ForecastHorizon, weather vs calendar signals, accuracy metrics interpretation
- Generating and querying forecasts — CreateForecastCommand, QueryForecastCommand, percentile bands, batch export, what-if analysis
Related observability guides: CloudWatch for MCP server metrics · Prometheus observability · Kinesis Firehose event streaming · SageMaker endpoints