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";
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it 'retrieves' anomalies, implying a read-only operation, but doesn't mention authentication requirements, rate limits, pagination, return format, or what constitutes an 'anomaly'. This leaves significant gaps for a tool that presumably returns structured anomaly data.

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

Conciseness5/5

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

The description is a single, efficient sentence that immediately conveys the core purpose without any wasted words. It's appropriately sized for a simple retrieval tool and is perfectly front-loaded with the essential information.

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

Completeness2/5

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

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain what data is returned, how anomalies are structured, whether results are paginated, or any behavioral constraints. Given the complexity of cost anomaly data and the lack of structured output documentation, more context is needed for effective use.

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

Parameters3/5

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

Schema description coverage is 100%, with both parameters clearly documented as date strings in YYYY-MM-DD format. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 for adequate coverage through the schema alone.

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

Purpose4/5

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

The description clearly states the action ('Retrieves') and resource ('cost anomalies detected by AWS Cost Anomaly Detection'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'get_cost_breakdown' or 'get_cost_by_service', but the specific focus on 'anomalies' provides inherent distinction.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get_cost_breakdown' or 'get_recent_cost'. It mentions AWS Cost Anomaly Detection as the source, but doesn't specify use cases, prerequisites, or exclusions that would help an agent choose appropriately among cost-related tools.

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

Install Server

Other Tools

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/bhaveshopss/MCP-server'

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