Skip to main content
Glama

get_cost_forecast

Predict AWS costs for specified time ranges to plan budgets and manage cloud spending effectively.

Instructions

Predicts future costs for a specified time range.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYesStart date (YYYY-MM-DD).
end_dateYesEnd date (YYYY-MM-DD).
granularityNoGranularity (default: DAILY).
prediction_interval_levelNoPrediction interval confidence (51-99, default: 80).

Implementation Reference

  • Handler function that calls AWS CostExplorer GetCostForecastCommand with provided parameters, processes the forecast results by time, and returns formatted JSON response including total and daily forecasts with prediction intervals.
    if (name === "get_cost_forecast") { const command = new GetCostForecastCommand({ TimePeriod: { Start: (args as any).start_date, End: (args as any).end_date }, Granularity: (args as any)?.granularity || "DAILY", Metric: "UNBLENDED_COST", PredictionIntervalLevel: (args as any)?.prediction_interval_level || 80 }); const response = await costExplorerClient.send(command); const forecast = response.ForecastResultsByTime?.map(f => ({ Date: f.TimePeriod?.Start, MeanValue: f.MeanValue, PredictionIntervalLower: f.PredictionIntervalLowerBound, PredictionIntervalUpper: f.PredictionIntervalUpperBound })) || []; return { content: [{ type: "text", text: JSON.stringify({ Total: response.Total, Forecast: forecast }, null, 2) }] };
  • Tool definition in ListTools response, including name, description, and Zod-like input schema defining required start_date/end_date and optional granularity/prediction_interval_level.
    name: "get_cost_forecast", description: "Predicts future costs for a specified time range.", inputSchema: { type: "object", properties: { start_date: { type: "string", description: "Start date (YYYY-MM-DD)." }, end_date: { type: "string", description: "End date (YYYY-MM-DD)." }, granularity: { type: "string", enum: ["DAILY", "MONTHLY", "HOURLY"], description: "Granularity (default: DAILY)." }, prediction_interval_level: { type: "number", description: "Prediction interval confidence (51-99, default: 80)." } }, required: ["start_date", "end_date"] }
  • src/index.ts:221-232 (registration)
    Registration of the tool in the list of available tools returned by ListToolsRequestHandler, which defines its metadata and input schema.
    name: "get_cost_forecast", description: "Predicts future costs for a specified time range.", inputSchema: { type: "object", properties: { start_date: { type: "string", description: "Start date (YYYY-MM-DD)." }, end_date: { type: "string", description: "End date (YYYY-MM-DD)." }, granularity: { type: "string", enum: ["DAILY", "MONTHLY", "HOURLY"], description: "Granularity (default: DAILY)." }, prediction_interval_level: { type: "number", description: "Prediction interval confidence (51-99, default: 80)." } }, required: ["start_date", "end_date"] }
  • Import of GetCostForecastCommand and CostExplorerClient from AWS SDK.
    import { CostExplorerClient, GetCostAndUsageCommand, GetCostForecastCommand, GetAnomaliesCommand, GetSavingsPlansUtilizationCommand, GetReservationUtilizationCommand } from "@aws-sdk/client-cost-explorer";
  • Initialization of the CostExplorerClient used by the get_cost_forecast handler.
    const costExplorerClient = new CostExplorerClient({});

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