Guide · AWS Budgets · Cost Management

AWS Budgets for MCP Servers — Cost Thresholds, Alerts, and Budget Management

AWS Budgets lets you set spending or usage thresholds and receive notifications when actual or forecasted costs approach or exceed them. For MCP server builders who expose AWS cost operations as tools, Budgets provides the alert layer that complements Cost Explorer's query layer: Cost Explorer tells you what you spent; Budgets tells you when spending is about to become a problem. The @aws-sdk/client-budgets package exposes the full Budgets API — create cost/usage/reservation budgets, attach email or SNS notifications, and query existing budget status. This guide covers the SDK end-to-end with working TypeScript examples.

TL;DR

Create a budget with CreateBudgetCommand, specifying AccountId, Budget (type, limit, time unit), and NotificationsWithSubscribers (threshold + notification type + subscriber list). The Budgets API endpoint is region-agnostic — always use region: "us-east-1". The minimum IAM permissions are budgets:CreateBudget, budgets:DescribeBudgets, and budgets:DescribeBudgetActionsForBudget. Free tier allows 2 budgets at no cost; additional budgets cost $0.02/day each.

Package installation and client setup

npm install @aws-sdk/client-budgets
import { BudgetsClient, CreateBudgetCommand } from "@aws-sdk/client-budgets";

// Budgets is a global service — always us-east-1
const budgets = new BudgetsClient({ region: "us-east-1" });

// Your 12-digit AWS account ID is required for all Budgets API calls
const ACCOUNT_ID = process.env.AWS_ACCOUNT_ID!;

Budget types

AWS Budgets supports four distinct budget types:

Type Tracks Limit field
COST Dollar spend BudgetLimit.Amount in USD
USAGE Service usage units (GB, hours, requests) BudgetLimit.Amount + BudgetLimit.Unit (e.g., "GB")
RI_UTILIZATION % of Reserved Instance capacity used BudgetLimit.Amount as % threshold (e.g., "80" = alert when <80%)
RI_COVERAGE % of instance hours covered by RIs vs on-demand BudgetLimit.Amount as % threshold (e.g., "70" = alert when <70%)
SAVINGS_PLANS_UTILIZATION % of Savings Plans commitment used % threshold
SAVINGS_PLANS_COVERAGE % of spend covered by Savings Plans % threshold

CreateBudget — cost budget with email notifications

The simplest budget: alert when monthly cost reaches 80% and 100% of a $500 limit:

import {
  BudgetsClient,
  CreateBudgetCommand,
} from "@aws-sdk/client-budgets";

const budgets = new BudgetsClient({ region: "us-east-1" });

await budgets.send(new CreateBudgetCommand({
  AccountId: ACCOUNT_ID,
  Budget: {
    BudgetName: "monthly-total-cost",
    BudgetType: "COST",
    TimeUnit: "MONTHLY",
    BudgetLimit: {
      Amount: "500",   // USD
      Unit:   "USD",
    },
    // CostFilters and CostTypes are optional — omit for account-wide cost
  },
  NotificationsWithSubscribers: [
    {
      Notification: {
        NotificationType:   "ACTUAL",          // vs "FORECASTED"
        ComparisonOperator: "GREATER_THAN",
        Threshold:          80,                // 80% of $500 = $400
        ThresholdType:      "PERCENTAGE",      // vs "ABSOLUTE_VALUE"
      },
      Subscribers: [
        { SubscriptionType: "EMAIL", Address: "ops-team@example.com" },
      ],
    },
    {
      Notification: {
        NotificationType:   "ACTUAL",
        ComparisonOperator: "GREATER_THAN",
        Threshold:          100,
        ThresholdType:      "PERCENTAGE",
      },
      Subscribers: [
        { SubscriptionType: "EMAIL", Address: "ops-team@example.com" },
        { SubscriptionType: "EMAIL", Address: "cfo@example.com" },
      ],
    },
  ],
}));

ACTUAL vs FORECASTED notifications

ACTUAL notifications fire when the current-month spend crosses the threshold. FORECASTED notifications fire when Cost Explorer's forecast for the current month is projected to exceed the threshold — giving early warning before the month ends. Use both for best coverage: FORECASTED at 80% triggers early action, ACTUAL at 100% confirms the budget was breached.

Budget with CostFilters — scope to a service or tag

Scoped budgets track spend for a subset of your account rather than the total. The CostFilters map uses the same key names as Cost Explorer GroupBy dimensions:

// Budget for Lambda spend only
await budgets.send(new CreateBudgetCommand({
  AccountId: ACCOUNT_ID,
  Budget: {
    BudgetName: "lambda-monthly-budget",
    BudgetType: "COST",
    TimeUnit: "MONTHLY",
    BudgetLimit: { Amount: "100", Unit: "USD" },
    CostFilters: {
      Service: ["AWS Lambda"],           // array of service name strings
    },
  },
  NotificationsWithSubscribers: [{
    Notification: {
      NotificationType:   "ACTUAL",
      ComparisonOperator: "GREATER_THAN",
      Threshold:          90,
      ThresholdType:      "PERCENTAGE",
    },
    Subscribers: [{ SubscriptionType: "EMAIL", Address: "alerts@example.com" }],
  }],
}));

// Budget scoped to a cost allocation tag value
await budgets.send(new CreateBudgetCommand({
  AccountId: ACCOUNT_ID,
  Budget: {
    BudgetName: "team-platform-monthly",
    BudgetType: "COST",
    TimeUnit: "MONTHLY",
    BudgetLimit: { Amount: "2000", Unit: "USD" },
    CostFilters: {
      "TagKeyValue": ["user:team$platform"],  // tag filter format
    },
  },
  NotificationsWithSubscribers: [{
    Notification: {
      NotificationType:   "FORECASTED",
      ComparisonOperator: "GREATER_THAN",
      Threshold:          85,
      ThresholdType:      "PERCENTAGE",
    },
    Subscribers: [
      { SubscriptionType: "EMAIL", Address: "platform-lead@example.com" },
    ],
  }],
}));

Tag filter values use the format "user:<tagKey>$<tagValue>" — matching the Cost Explorer tag value format but prefixed with "user:".

SNS notifications for budget alerts

Beyond email, Budgets can publish to an SNS topic. The SNS topic policy must explicitly allow budgets.amazonaws.com to publish:

// SNS topic policy (add to your CDK/Terraform/CloudFormation):
// {
//   "Effect": "Allow",
//   "Principal": { "Service": "budgets.amazonaws.com" },
//   "Action": "SNS:Publish",
//   "Resource": "arn:aws:sns:us-east-1:123456789012:budget-alerts",
//   "Condition": {
//     "StringEquals": { "aws:SourceAccount": "123456789012" },
//     "ArnLike": { "aws:SourceArn": "arn:aws:budgets::123456789012:budget/*" }
//   }
// }

await budgets.send(new CreateBudgetCommand({
  AccountId: ACCOUNT_ID,
  Budget: {
    BudgetName: "infra-cost-with-sns",
    BudgetType: "COST",
    TimeUnit: "MONTHLY",
    BudgetLimit: { Amount: "1000", Unit: "USD" },
  },
  NotificationsWithSubscribers: [{
    Notification: {
      NotificationType:   "ACTUAL",
      ComparisonOperator: "GREATER_THAN",
      Threshold:          95,
      ThresholdType:      "PERCENTAGE",
    },
    Subscribers: [
      {
        SubscriptionType: "SNS",
        Address: "arn:aws:sns:us-east-1:123456789012:budget-alerts",
      },
    ],
  }],
}));

DescribeBudgets — query existing budgets

List all budgets for the account, including their current spend and limit:

import {
  BudgetsClient,
  DescribeBudgetsCommand,
} from "@aws-sdk/client-budgets";

const budgets = new BudgetsClient({ region: "us-east-1" });

async function listAllBudgets() {
  const results = [];
  let nextToken: string | undefined;

  do {
    const response = await budgets.send(new DescribeBudgetsCommand({
      AccountId: ACCOUNT_ID,
      MaxResults: 100,
      NextToken: nextToken,
    }));
    results.push(...(response.Budgets ?? []));
    nextToken = response.NextToken;
  } while (nextToken);

  return results;
}

const allBudgets = await listAllBudgets();

for (const b of allBudgets) {
  const spent   = b.CalculatedSpend?.ActualSpend?.Amount ?? "0";
  const limit   = b.BudgetLimit?.Amount ?? "?";
  const pct     = limit !== "?" ? ((parseFloat(spent) / parseFloat(limit)) * 100).toFixed(1) : "?";
  console.log(`${b.BudgetName}: $${spent} / $${limit} (${pct}%)`);
}

Key fields in each Budget object:

Field Description
BudgetName Unique name within the account
BudgetType COST, USAGE, RI_UTILIZATION, etc.
BudgetLimit { Amount: string, Unit: string } — the ceiling
CalculatedSpend.ActualSpend Current-period actual spend
CalculatedSpend.ForecastedSpend Cost Explorer projection for the period
TimePeriod Start/end dates for the current budget period
LastUpdatedTime When the budget was last modified

DescribeBudgetNotificationsForAccount

List all notifications across all budgets — useful for auditing what alerts are configured:

import { DescribeBudgetNotificationsForAccountCommand } from "@aws-sdk/client-budgets";

const notifs = await budgets.send(
  new DescribeBudgetNotificationsForAccountCommand({
    AccountId: ACCOUNT_ID,
    MaxResults: 100,
  })
);

for (const bn of notifs.BudgetNotificationsForAccount ?? []) {
  console.log(`Budget: ${bn.BudgetName}`);
  for (const n of bn.Notifications ?? []) {
    console.log(
      `  ${n.NotificationType} ${n.ComparisonOperator} ${n.Threshold}${n.ThresholdType === "PERCENTAGE" ? "%" : " USD"}`
    );
  }
}

UpdateBudget — change limits mid-period

UpdateBudgetCommand replaces the full budget definition. Fetch the current budget first to avoid overwriting fields you don't intend to change:

import {
  DescribeBudgetCommand,
  UpdateBudgetCommand,
} from "@aws-sdk/client-budgets";

// Fetch current definition
const { Budget: current } = await budgets.send(new DescribeBudgetCommand({
  AccountId: ACCOUNT_ID,
  BudgetName: "monthly-total-cost",
}));

if (!current) throw new Error("Budget not found");

// Increase limit by 20%
const newAmount = (parseFloat(current.BudgetLimit!.Amount!) * 1.2).toFixed(2);

await budgets.send(new UpdateBudgetCommand({
  AccountId: ACCOUNT_ID,
  NewBudget: {
    ...current,
    BudgetLimit: { Amount: newAmount, Unit: current.BudgetLimit!.Unit },
  },
}));

Budget Actions — automate responses to budget breaches

Budget Actions go beyond notifications: they can automatically apply an IAM policy, attach an SCP to an OU, or run an SSM Automation document when a threshold is crossed. This lets you programmatically restrict IAM permissions when spend is too high:

import { CreateBudgetActionCommand } from "@aws-sdk/client-budgets";

// When monthly cost hits 95%, automatically attach a deny-all policy
// to the "developers" IAM group, blocking further resource creation
await budgets.send(new CreateBudgetActionCommand({
  AccountId: ACCOUNT_ID,
  BudgetName: "monthly-total-cost",
  NotificationType:  "ACTUAL",
  ActionType:        "APPLY_IAM_POLICY",
  ActionThreshold: {
    ActionThresholdValue: 95,
    ActionThresholdType:  "PERCENTAGE",
  },
  Definition: {
    IamActionDefinition: {
      PolicyArn: "arn:aws:iam::123456789012:policy/DenyResourceCreation",
      Groups:    ["developers"],   // IAM group names
    },
  },
  ExecutionRoleArn: "arn:aws:iam::123456789012:role/BudgetActionRole",
  ApprovalModel: "AUTOMATIC",   // vs "MANUAL" (requires human approval in console)
  Subscribers: [
    { SubscriptionType: "EMAIL", Address: "ops@example.com" },
  ],
}));

AUTOMATIC approval executes the action immediately when the threshold is crossed. MANUAL sends a notification to approvers who must confirm in the AWS console before the action runs. The IAM execution role needs iam:AttachGroupPolicy and iam:DetachGroupPolicy for IAM actions, and must trust budgets.amazonaws.com.

Complete MCP tool: budget status dashboard

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import {
  BudgetsClient,
  DescribeBudgetsCommand,
} from "@aws-sdk/client-budgets";
import { z } from "zod";

const budgets = new BudgetsClient({ region: "us-east-1" });
const ACCOUNT_ID = process.env.AWS_ACCOUNT_ID!;
const server = new McpServer({ name: "budgets-tool", version: "1.0.0" });

server.tool(
  "get_budget_status",
  "Return the current spend vs limit for all AWS Budgets in the account",
  {
    alert_threshold_pct: z.number().min(0).max(100).default(80)
      .describe("Highlight budgets that are at or above this % of their limit"),
  },
  async ({ alert_threshold_pct }) => {
    const all: any[] = [];
    let nextToken: string | undefined;

    do {
      const response = await budgets.send(new DescribeBudgetsCommand({
        AccountId: ACCOUNT_ID,
        MaxResults: 100,
        NextToken: nextToken,
      }));
      all.push(...(response.Budgets ?? []));
      nextToken = response.NextToken;
    } while (nextToken);

    if (all.length === 0) {
      return { content: [{ type: "text", text: "No budgets found in this account." }] };
    }

    const lines: string[] = [];
    let alertCount = 0;

    for (const b of all.sort((a, b) => a.BudgetName.localeCompare(b.BudgetName))) {
      const actual  = parseFloat(b.CalculatedSpend?.ActualSpend?.Amount ?? "0");
      const fcast   = parseFloat(b.CalculatedSpend?.ForecastedSpend?.Amount ?? "0");
      const limit   = parseFloat(b.BudgetLimit?.Amount ?? "0");
      const unit    = b.BudgetLimit?.Unit ?? "USD";
      const actPct  = limit > 0 ? (actual / limit * 100) : 0;
      const fcstPct = limit > 0 ? (fcast  / limit * 100) : 0;
      const alert   = actPct >= alert_threshold_pct || fcstPct >= alert_threshold_pct;
      if (alert) alertCount++;

      lines.push(
        `${alert ? "⚠ " : "  "}${b.BudgetName} [${b.BudgetType}]` +
        ` actual: ${actual.toFixed(2)} ${unit} (${actPct.toFixed(0)}%)` +
        ` forecast: ${fcast.toFixed(2)} ${unit} (${fcstPct.toFixed(0)}%)` +
        ` / limit: ${limit.toFixed(2)} ${unit}`
      );
    }

    return {
      content: [{
        type: "text",
        text: [
          `Budget status (${all.length} budgets, ${alertCount} at/above ${alert_threshold_pct}% threshold):`,
          "",
          ...lines,
        ].join("\n"),
      }],
    };
  }
);

IAM permissions

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "budgets:CreateBudget",
        "budgets:UpdateBudget",
        "budgets:DeleteBudget",
        "budgets:DescribeBudget",
        "budgets:DescribeBudgets",
        "budgets:DescribeBudgetNotificationsForAccount",
        "budgets:CreateBudgetAction",
        "budgets:DescribeBudgetActionsForBudget",
        "budgets:ExecuteBudgetAction"
      ],
      "Resource": "*"
    }
  ]
}

Like Cost Explorer, all budgets: actions require Resource: "*" — resource-level scoping is not supported. If your IAM user is in a member account of an AWS Organization, IAM access to billing must be enabled by the management account via "Account Settings → IAM user and role access to Billing information."

Common errors

Error Cause and fix
InvalidParameterException: AccountId is invalid The 12-digit account ID is wrong or the credential's account does not match. Retrieve programmatically via STSClient.send(new GetCallerIdentityCommand({})).
CreationLimitExceededException Default limit is 20,000 budgets per account. Very rarely hit in practice — contact AWS Support to raise the limit.
DuplicateRecordException BudgetName already exists in the account. Use UpdateBudgetCommand instead, or choose a different name.
AccessDeniedException Missing budgets: permissions or IAM billing access not enabled. Also check that the SNS topic policy allows budgets.amazonaws.com to publish when using SNS subscribers.
NotFoundException Budget name does not exist for DescribeBudget or UpdateBudget — budget names are case-sensitive.

TimeUnit and budget reset behavior

Budget limits reset at the start of each period according to TimeUnit:

TimeUnit Reset behavior Use case
DAILY Resets every day at midnight UTC Tight daily compute cost tracking
MONTHLY Resets on the 1st of each month Standard AWS billing period — most common
QUARTERLY Resets Jan 1, Apr 1, Jul 1, Oct 1 Quarterly planning cycles
ANNUALLY Resets Jan 1 each year Annual IT budgets

For non-recurring one-time budgets (e.g., a project budget), specify TimePeriod with explicit Start and End dates instead of a TimeUnit. The budget does not reset and notifications fire once when the cumulative spend crosses the threshold within that date range.