get_assets
Retrieve asset cost and allocation data from Kubecost for specified time periods, with options to aggregate results and apply filters for detailed cost analysis.
Instructions
Get asset data from Kubecost
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aggregate | No | ||
| filters | No | ||
| window | Yes |
Implementation Reference
- src/index.ts:199-221 (registration)MCP tool registration for "get_assets" including description, Zod input schema, and inline async handler that delegates to KubecostClient.getAssets and formats response as JSON text.this.tool( 'get_assets', 'Get asset data from Kubecost', { window: z.string(), aggregate: z.string().optional(), filters: z.record(z.string()).optional(), }, async (params) => { try { const result = await this.kubecostClient.getAssets(params); return { isError: false, content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { isError: true, content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }] }; } } );
- src/client/kubecost-client.ts:74-81 (handler)Core handler logic in KubecostClient.getAssets method: makes authenticated HTTP GET request to Kubecost /model/assets API endpoint with query params and returns parsed AssetResponse data.async getAssets(params: { window: string; aggregate?: string; filters?: Record<string, string>; }): Promise<AssetResponse> { const response = await this.client.get('/model/assets', { params }); return response.data; }
- src/types/kubecost.ts:82-106 (schema)TypeScript interface defining the structure of the AssetResponse returned by the getAssets API call, used for type safety in the tool implementation.export interface AssetResponse { data: { name: string; properties: { cluster: string; type: string; provider: string; providerId: string; account: string; project: string; service: string; category: string; labels: Record<string, string>; }; window: { start: string; end: string; }; totals: { cost: number; adjustment: number; totalCost: number; }; }[]; }