Skip to main content
Glama

get_cost_anomalies

Identify unusual spending patterns in AWS costs by retrieving anomalies detected by AWS Cost Anomaly Detection for specified date ranges.

Instructions

Retrieves cost anomalies detected by AWS Cost Anomaly Detection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYesStart date (YYYY-MM-DD).
end_dateYesEnd date (YYYY-MM-DD).

Implementation Reference

  • src/index.ts:245-256 (registration)
    Tool registration in the ListTools handler, defining name, description, and input schema.
    { name: "get_cost_anomalies", description: "Retrieves cost anomalies detected by AWS Cost Anomaly Detection.", inputSchema: { type: "object", properties: { start_date: { type: "string", description: "Start date (YYYY-MM-DD)." }, end_date: { type: "string", description: "End date (YYYY-MM-DD)." } }, required: ["start_date", "end_date"] } },
  • Input schema for the get_cost_anomalies tool, requiring start_date and end_date.
    inputSchema: { type: "object", properties: { start_date: { type: "string", description: "Start date (YYYY-MM-DD)." }, end_date: { type: "string", description: "End date (YYYY-MM-DD)." } }, required: ["start_date", "end_date"] }
  • Handler implementation in CallToolRequestSchema that fetches cost anomalies using AWS CostExplorerClient's GetAnomaliesCommand and formats the response.
    if (name === "get_cost_anomalies") { const command = new GetAnomaliesCommand({ DateInterval: { StartDate: (args as any).start_date, EndDate: (args as any).end_date }, MaxResults: 20 }); const response = await costExplorerClient.send(command); const anomalies = response.Anomalies?.map(a => ({ AnomalyId: a.AnomalyId, AnomalyScore: a.AnomalyScore, ImpactTotal: a.Impact?.TotalImpact, MonitorArn: a.MonitorArn, RootCauses: a.RootCauses, Date: a.AnomalyEndDate })) || []; return { content: [{ type: "text", text: JSON.stringify(anomalies, null, 2) }] }; }
  • Initialization of the AWS CostExplorerClient used by the get_cost_anomalies handler.
    const costExplorerClient = new CostExplorerClient({});
  • Import of GetAnomaliesCommand and CostExplorerClient from AWS SDK.
    import { CostExplorerClient, GetCostAndUsageCommand, GetCostForecastCommand, GetAnomaliesCommand, GetSavingsPlansUtilizationCommand, GetReservationUtilizationCommand } from "@aws-sdk/client-cost-explorer";

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Bhavesh8890/MCP-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server