Skip to main content
Glama

Create Alert Rule

create_alert_rule

Create a cost-alert rule (POST /api/reports/cost-dashboard/alerts) — the same rule the Alerts page's form builds. Required: alert_name, alert_type, the threshold for that type, and at least one recipient. By type: trend → threshold_percent (fires when total spend rises ≥ that % vs the previous period); anomaly → threshold_percent + optional threshold_amount minimum impact (per-service spike vs a 4-window baseline); budget → threshold_amount in the org's currency (spend over the analysis period reaches it — standalone, NOT a create_budget budget); expiry → threshold_amount = days notice, whole 1-365: every commitment on the Commitments page with an end date (AWS RIs and Savings Plans; Azure reservations and savings plans when their end dates are available; not Google Cloud CUDs) ending within that many days, listed by commitment id and end date, each notified once (service / account / tag filters do not apply); tokens_per_request ("Tokens per Request Rise", OpenAI only) → threshold_percent (> 0; the Alerts form suggests 50): fires when the 7-day average input tokens per request (uncached + cached input tokens ÷ requests) of an OpenAI API key or model is more than that % above its prior 28-day average on 3 consecutive days. It runs daily only (frequency daily, analysis_period 7d_vs_28d — both the defaults), is evaluated per per (api_key, the default, or model), skips any key / model with fewer than min_requests requests in the 7 days (default 1000), and values limits it to given key ids or model names; it watches every OpenAI connection, or one OpenAI integration_id, and takes no services / accounts / tags. frequency is the evaluation cadence at 08:00 UTC (daily | weekly = Mondays | monthly = the 3rd; default weekly); analysis_period the window (defaults per type). Scope: omit integration_id for the whole organization across every provider, or pin one connection; services, accounts, tags narrow it (empty = everything). Cost center (budget and trend only): cost_center_id (list_cost_centers) measures the rule on that cost center — its allocation rules decide what counts, child cost centers included, and the figures match the Allocation page's cost-center breakdown for the same window; it is organization-wide and takes no integration_id, services, accounts or tags. Recipients: notification_channel_ids (list_notification_channels) and/or emails (up to 5). A rule with nowhere to deliver is refused. Validation errors come back from the backend verbatim — fix the field it names. Returns the created rule as list_alert_rules shows it. In the app any active member can create alert rules and manage the ones they created, contributors and admins manage every rule, viewers can attach saved channels but not ad-hoc emails, and the public demo organization is read-only; over MCP every write additionally needs the admin gate below. Alert rules need a paid plan. WRITE TOOL — MCP WRITES ARE OFF BY DEFAULT FOR EVERY ORGANIZATION. This call needs ALL FOUR of: the admin:write scope, the organization switch turned on (an org admin enables it in Settings → Organization → AI agent access), an admin or super_admin org role, and confirm:true. Missing any one of them it refuses and changes nothing, and the error names which one — relay that to the user rather than retrying. Read-only cak_ API keys can never perform it. Example: { "alert_name": "EC2 weekly spike", "alert_type": "trend", "threshold_percent": 20, "frequency": "daily", "services": ["AmazonEC2"], "notification_channel_ids": ["<channel_id>"], "confirm": true }; { "alert_name": "Prompt bloat", "alert_type": "tokens_per_request", "threshold_percent": 50, "per": "model", "emails": ["ml@example.com"], "confirm": true }.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "alert_name": "<alert_name>",
      "alert_type": "<alert_type>"
    },
    "name": "create_alert_rule"
  }
}

Input Schema

NameRequiredDescriptionDefault
perNotokens_per_request only: evaluate each OpenAI API key (api_key, the default) or each model (model) on its own.
tagsNoOnly resources carrying ALL of these tags, e.g. [{ "key": "env", "value": "prod" }]. One value per key. [] or omitted = no tag filter.
emailsNoUp to 5 email addresses to notify directly, without a channel. For a longer list, create an email channel and attach its id.
valuesNotokens_per_request only: limit the rule to these OpenAI API key ids (per api_key — get_ai_spend group_by "api_key" lists them) or model names (per model). Omit (or []) for every key / model.
confirmNoSet to true to actually perform this write. Required: the tool refuses the mutation unless confirm:true is present. Authorization for the change itself is your org role, checked server-side.
accountsNoOnly these sub-accounts — AWS linked accounts, Azure subscriptions, GCP projects — as raw ids (get_available_linked_accounts). [] or omitted = all accounts.
servicesNoOnly these provider services (e.g. ["AmazonEC2"]; get_available_services lists them). [] or omitted = all services.
frequencyNoHow often the rule is evaluated, at 08:00 UTC: daily (every day) | weekly (Mondays) | monthly (the 3rd). Default weekly; tokens_per_request must be (and defaults to) daily.
alert_nameYesDisplay name for the rule (1-200 characters). Required.
alert_typeYestrend = total spend for the scope rose by ≥ threshold_percent vs the previous period; anomaly = per-service scan, each service vs its own baseline (average of the 4 prior windows), flagged when it rises ≥ threshold_percent AND the increase is ≥ threshold_amount (minimum impact, default 50); budget = total spend for the analysis period reached threshold_amount (a standalone spend threshold — NOT linked to budgets from create_budget); expiry = a commitment on the Commitments page in the rule's provider and connection scope (AWS Reserved Instances and Savings Plans; Azure reservations and savings plans when their end dates are available; never Google Cloud CUDs, which have no end date in Google's billing export) expires within threshold_amount days, day N included; each commitment notifies once, and services / accounts / tags do not apply; tokens_per_request = OpenAI only: the 7-day average input tokens per request (uncached + cached input tokens ÷ requests) of each OpenAI API key or model rose more than threshold_percent above its prior 28-day average on 3 consecutive days, counting only keys / models with at least min_requests requests in the 7 days (daily frequency only).
min_requestsNotokens_per_request only: a key or model needs at least this many requests in the 7-day window before it can fire (default 1000), so low-volume keys do not trip it.
cost_center_idNobudget (Spend Threshold) and trend (Trend Spike) only: measure the rule on this cost center (cost center id from list_cost_centers). Its allocation rules decide what counts, child cost centers included, so the figures match get_allocation_breakdown / the Allocation page for the same window. A cost-center rule is organization-wide: it takes no integration_id, services, accounts or tags. A cost center an alert rule uses cannot be deleted.
integration_idNoEvaluate only this provider connection's spend (integration id from list_integrations). Omit for the whole organization — combined spend across every connected provider. tokens_per_request: an OpenAI integration only; omit for every OpenAI connection. Not allowed with cost_center_id.
analysis_periodNoThe spend window evaluated, in whole UTC days of settled cost data: the last day counted is the day before yesterday for AWS, Azure and GCP and yesterday for Snowflake, OpenAI and Anthropic (an organization-wide rule follows the slowest provider it has recent data from). trend/anomaly compare it with the window before: daily (day over day) | weekly (7 days) | monthly (30 days). budget sums spend over last_24h (one day) | last_7d | last_30d | current_month (month to date; on a monthly-frequency rule, the last full calendar month). tokens_per_request takes only 7d_vs_28d (the last 7 days vs the 28 days before). Other type/period pairs are refused. expiry ignores it. Defaults: trend/anomaly weekly, budget current_month, expiry last_30d, tokens_per_request 7d_vs_28d.
threshold_amountNobudget: the spend amount (org display currency) that fires the rule, > 0. expiry: days of notice, a whole number 1-365. anomaly: optional minimum impact — the smallest increase worth flagging (default 50). Ignored by trend and tokens_per_request.
threshold_percentNotrend, anomaly and tokens_per_request: the % rise that fires the rule (must be > 0; required). For tokens_per_request the Alerts form suggests 50. Ignored by budget/expiry.
notification_channel_idsNoIds of the organization's notification channels (any number, any type — email, Slack, Teams) to notify, from list_notification_channels.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations, it discloses the full authorization model (admin:write scope, org AI-agent switch, admin/super_admin role, confirm:true — all four required), the paid-plan gate, the read-only demo org, role-specific limits for viewers/contributors, and that read-only cak_ keys can never perform it. It also explains failure behavior (refusals name the missing gate, backend validation errors returned verbatim, rules with no recipients refused) and a side effect (a cost center in use cannot be deleted).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The first clause front-loads the action and endpoint, and the required-fields and auth paragraphs are well placed. But the middle is a single sprawling block that re-explains each alert type at length, duplicating the alert_type and threshold_* schema descriptions rather than pointing to them, which makes the definition harder to scan than it needs to be.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 17-parameter tool with five divergent modes and no output schema, the description covers the mutation's prerequisites, scope interactions, per-type constraints, recipient requirements, and even the return value ("the created rule as list_alert_rules shows it"). Two worked examples anchor the two most divergent modes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds cross-parameter meaning the schema cannot express: which threshold field applies per alert_type, per-type defaults, ignored fields, and invalid type/analysis_period pairings being refused. It loses a point only because much of the per-field text restates the schema's own parameter descriptions near-verbatim.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ("Create a cost-alert rule") plus the exact endpoint POST /api/reports/cost-dashboard/alerts, then enumerates all five alert types with their firing semantics. An agent can distinguish this from create_budget, create_notification_channel, and the update/get/delete alert-rule siblings without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states explicit exclusions and alternatives: budget alerts are "standalone, NOT a create_budget budget", tokens_per_request is OpenAI-only, expiry ignores services/accounts/tags, cost-center rules take no integration_id. It also names the helper tools to call first (list_cost_centers, list_notification_channels, list_integrations, get_available_services) and gives the required preconditions for a successful call.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources