get_budget
Retrieve detailed information about a specific budget rule in Kubecost to monitor and manage cloud spending effectively.
Instructions
Get detailed information about a specific budget rule
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| budgetId | Yes |
Implementation Reference
- src/index.ts:55-72 (registration)Registration of the 'get_budget' MCP tool, including description, input schema requiring 'budgetId' as string, and inline handler function that executes kubecostClient.getBudget(budgetId) and returns the JSON-formatted result or error.this.tool( 'get_budget', 'Get detailed information about a specific budget rule', { budgetId: z.string() }, async ({ budgetId }) => { try { const result = await this.kubecostClient.getBudget(budgetId); 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/index.ts:59-71 (handler)The core handler logic for the 'get_budget' tool: extracts budgetId from arguments, calls the Kubecost client to fetch the budget, stringifies the result as JSON text content for MCP response.async ({ budgetId }) => { try { const result = await this.kubecostClient.getBudget(budgetId); 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/index.ts:58-58 (schema)Input schema definition for the 'get_budget' tool using Zod: requires a 'budgetId' string parameter.{ budgetId: z.string() },
- src/client/kubecost-client.ts:48-51 (helper)Helper method in KubecostClient that implements the actual API call to retrieve budget details via GET /model/budget/{budgetId}, returning BudgetResponse.async getBudget(budgetId: string): Promise<BudgetResponse> { const response = await this.client.get(`/model/budget/${budgetId}`); return response.data; }
- src/tools/budget-tools.ts:19-31 (schema)Detailed JSON schema definition for 'get_budget' tool input (appears unused in current registration).get_budget: { description: 'Get detailed information about a specific budget rule', inputSchema: { type: 'object', properties: { budgetId: { type: 'string', description: 'The ID of the budget rule to retrieve', }, }, required: ['budgetId'], }, },