delete_product_rate_plan
Remove a product rate plan by providing its rate plan ID. This action permanently deletes the specified rate plan from your subscription billing system.
Instructions
Delete a rate plan. DELETE /product-rateplans/{ratePlanId}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ratePlanId | Yes | Rate plan ID (URI: /product-rateplans/{ratePlanId}) |
Implementation Reference
- The handler function for the delete_product_rate_plan tool. Parses the 'ratePlanId' argument from the input, validates it using Zod, and delegates to the service layer's deleteRatePlan function.
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } return handleToolCall(() => ratePlanService.deleteRatePlan(client, parsed.data.ratePlanId)); } - Zod schema and MCP inputSchema definition for the delete_product_rate_plan tool. Expects a required 'ratePlanId' string.
const schema = z.object({ ratePlanId: z.string().min(1, "ratePlanId is required"), }); const definition = { name: "delete_product_rate_plan", description: "Delete a rate plan. DELETE /product-rateplans/{ratePlanId}.", inputSchema: { type: "object" as const, properties: { ratePlanId: { type: "string", description: "Rate plan ID (URI: /product-rateplans/{ratePlanId})" }, }, required: ["ratePlanId"], }, }; - src/tools/product_rate_plans/index.ts:14-24 (registration)Registration of the deleteRatePlanTool (which includes delete_product_rate_plan) in the product rate plan tools array, collected into the main tool registry.
/** All 7 product rate plan tools. */ export function registerProductRatePlanTools(): Tool[] { return [ listRatePlansTool, getRatePlanTool, createRatePlanTool, updateRatePlanTool, deleteRatePlanTool, updateRatePlanStatusTool, syncRatePlanTool, ]; - src/tools/index.ts:26-57 (registration)Main tool registry where registerProductRatePlanTools() is called and tools are stored. The executeTool function looks up tools by name (including 'delete_product_rate_plan') to dispatch calls.
const tools: Tool[] = [ ...registerCustomerTools(), ...registerProductTools(), ...registerProductRatePlanTools(), ...registerProductRatePlanChargeTools(), ...registerSubscriptionTools(), ...registerInvoiceTools(), ...registerTransactionTools(), ...registerBillRunTools(), ...registerGatewayTools(), ...registerCurrencyTools(), ...registerIntegrationTools(), ...registerShippingTools(), ...registerFilterTools(), ...registerDocsTools(), ]; /** All tool definitions for tools/list */ export function getToolDefinitions(): ToolDefinition[] { return tools.map((t) => t.definition); } /** Execute a tool by name. Returns result or undefined if tool not found. */ export async function executeTool( name: string, args: Record<string, unknown> | undefined, client: RebilliaClient ): Promise<ToolResult | undefined> { const tool = tools.find((t) => t.definition.name === name); if (!tool) return undefined; return tool.handler(client, args); } - The actual service function that performs the DELETE HTTP request to /product-rateplans/{ratePlanId}. Called by the handler.
export async function deleteRatePlan( client: Client, ratePlanId: string ): Promise<Record<string, unknown>> { const result = await client.delete<Record<string, unknown>>( `/product-rateplans/${ratePlanId}` ); return Object.keys(result ?? {}).length ? result : { success: true, message: "Rate plan deleted" }; }