create_budget
Create budget rules in Kubecost to monitor and control Kubernetes cluster spending by setting spending limits and configuring alerts for cost overruns.
Instructions
Create a new budget rule in Kubecost
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| actions | Yes | ||
| interval | Yes | ||
| intervalDay | Yes | ||
| kind | Yes | ||
| name | Yes | ||
| spendLimit | Yes | ||
| values | Yes |
Implementation Reference
- src/index.ts:96-109 (handler)Executes the create_budget tool by calling the Kubecost client's createOrUpdateBudget method with the input budgetData and formats the success or error response.async (budgetData) => { try { const result = await this.kubecostClient.createOrUpdateBudget(budgetData); return { isError: false, content: [{ type: 'text', text: `Budget created successfully: ${JSON.stringify(result, null, 2)}` }] }; } catch (error) { return { isError: true, content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }] }; } }
- src/index.ts:78-95 (schema)Zod schema for validating the input parameters of the create_budget tool, defining the structure for budget creation data.{ name: z.string(), values: z.object({ cluster: z.array(z.string()).optional(), namespace: z.array(z.string()).optional(), label: z.record(z.array(z.string())).optional(), }), kind: z.enum(['soft', 'hard']), interval: z.enum(['weekly', 'monthly']), intervalDay: z.number(), spendLimit: z.number(), actions: z.array(z.object({ percentage: z.number(), emails: z.array(z.string()).optional(), slackWebhooks: z.array(z.string()).optional(), msTeamsWebhooks: z.array(z.string()).optional(), })), },
- src/index.ts:75-110 (registration)Registers the create_budget tool with the MCP server using this.tool, including name, description, input schema, and handler function.this.tool( 'create_budget', 'Create a new budget rule in Kubecost', { name: z.string(), values: z.object({ cluster: z.array(z.string()).optional(), namespace: z.array(z.string()).optional(), label: z.record(z.array(z.string())).optional(), }), kind: z.enum(['soft', 'hard']), interval: z.enum(['weekly', 'monthly']), intervalDay: z.number(), spendLimit: z.number(), actions: z.array(z.object({ percentage: z.number(), emails: z.array(z.string()).optional(), slackWebhooks: z.array(z.string()).optional(), msTeamsWebhooks: z.array(z.string()).optional(), })), }, async (budgetData) => { try { const result = await this.kubecostClient.createOrUpdateBudget(budgetData); return { isError: false, content: [{ type: 'text', text: `Budget created successfully: ${JSON.stringify(result, null, 2)}` }] }; } catch (error) { return { isError: true, content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }] }; } } );