get_reservation_utilization
Retrieve Reserved Instance utilization percentages for AWS resources to analyze cost efficiency and optimize cloud spending.
Instructions
Retrieves Reserved Instance (RI) utilization percentages.
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": {
"start_date": "<start_date>",
"end_date": "<end_date>"
},
"name": "get_reservation_utilization"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | Yes | Start date (YYYY-MM-DD). | |
| end_date | Yes | End date (YYYY-MM-DD). |
Implementation Reference
- src/index.ts:1115-1131 (handler)The main handler function for the 'get_reservation_utilization' tool. It uses AWS Cost Explorer's GetReservationUtilizationCommand to fetch Reserved Instance (RI) utilization data for a given time period and formats the response into a time-series of utilization percentages and hours.
if (name === "get_reservation_utilization") { const command = new GetReservationUtilizationCommand({ TimePeriod: { Start: (args as any).start_date, End: (args as any).end_date } }); const response = await costExplorerClient.send(command); const utils = response.UtilizationsByTime?.map(u => ({ Date: u.TimePeriod?.Start, TotalPotentialRIHours: u.Total?.TotalPotentialRISavings, // Approximate proxy if direct hours not shown in all interfaces UtilizationPercentage: u.Total?.UtilizationPercentage + "%", PurchasedUnits: u.Total?.PurchasedHours, TotalActualHours: u.Total?.TotalActualHours, UnusedHours: u.Total?.UnusedHours })) || []; return { content: [{ type: "text", text: JSON.stringify(utils, null, 2) }] }; } - src/index.ts:269-280 (registration)Registration of the tool in the ListTools response, defining its name, description, and input schema requirements.
{ name: "get_reservation_utilization", description: "Retrieves Reserved Instance (RI) utilization percentages.", 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"] } }, - src/index.ts:272-279 (schema)Input schema definition for the tool, specifying required start_date and end_date parameters in YYYY-MM-DD format.
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"] } - src/index.ts:24-24 (helper)Import statement for the GetReservationUtilizationCommand and CostExplorerClient used by the tool.
import { CostExplorerClient, GetCostAndUsageCommand, GetCostForecastCommand, GetAnomaliesCommand, GetSavingsPlansUtilizationCommand, GetReservationUtilizationCommand } from "@aws-sdk/client-cost-explorer"; - src/index.ts:58-58 (helper)Initialization of the AWS CostExplorerClient instance used to send the GetReservationUtilizationCommand.
const costExplorerClient = new CostExplorerClient({});