list_usage_records
Retrieve billing usage records from CloudStack MCP Server by specifying a start date, end date, and optional usage type for accurate cost tracking and analysis.
Instructions
List usage records for billing
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| enddate | Yes | End date (YYYY-MM-DD) | |
| startdate | Yes | Start date (YYYY-MM-DD) | |
| type | No | Usage type |
Implementation Reference
- Main handler function that fetches usage records from CloudStack, processes them, and formats a response with details like usageid, description, usagetype, usage, startdate, enddate.async handleListUsageRecords(args: any) { const result = await this.cloudStackClient.listUsageRecords(args); const records = result.listusagerecordsresponse?.usagerecord || []; const recordList = records.map((record: any) => ({ usageid: record.usageid, description: record.description, usagetype: record.usagetype, rawusage: record.rawusage, usage: record.usage, startdate: record.startdate, enddate: record.enddate })); return { content: [ { type: 'text', text: `Found ${recordList.length} usage records:\n\n${recordList .map((record: any) => `• ${record.description} (${record.usageid})\n Type: ${record.usagetype}\n Usage: ${record.usage}\n Start: ${record.startdate}\n End: ${record.enddate}\n` ) .join('\n')}` } ] }; }
- Tool definition including name, description, and input schema requiring startdate and enddate, with optional type.name: 'list_usage_records', description: 'List usage records for billing', inputSchema: { type: 'object', properties: { startdate: { type: 'string', description: 'Start date (YYYY-MM-DD)', }, enddate: { type: 'string', description: 'End date (YYYY-MM-DD)', }, type: { type: 'number', description: 'Usage type', }, }, required: ['startdate', 'enddate'], additionalProperties: false, }, },
- src/server.ts:174-175 (registration)Switch case in server that registers and dispatches the tool call to the monitoring handler.case 'list_usage_records': return await this.monitoringHandlers.handleListUsageRecords(args);
- src/cloudstack-client.ts:251-253 (helper)CloudStack client method that makes the actual API request to listUsageRecords endpoint.async listUsageRecords(params: CloudStackParams): Promise<CloudStackResponse> { return this.request('listUsageRecords', params); }