Get customer subscription details
deonpay_get_customer_subscriptionFetch a customer subscription by UUID to review plan details, recent charges with status, and cancellation flags. Use for investigating subscriber history or failed charges.
Instructions
Fetch a single customer subscription by UUID. Includes the plan denormalized, the last 20 recurring charges (each with status success/failed/skipped/completed, charge_type auto/manual/renewal_link, attempt_number, error_message and timestamps), and cancellation flags. Use this when investigating a specific subscriber's history or a failed charge ('why did Juan's subscription go past_due?').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Customer subscription UUID. |
Implementation Reference
- The handler function that executes the tool logic. It takes an object with a single 'id' parameter (UUID), encodes it, and calls client.get() on the /customer-subscriptions/{id} endpoint to fetch a single customer subscription details.
safeHandler(async ({ id }) => { return client.get(`/customer-subscriptions/${encodeURIComponent(id)}`); }), ); - The input schema for the tool, defined inline: requires a single 'id' field typed as a UUID string via Zod (z.string().uuid()).
{ title: "Get customer subscription details", description: "Fetch a single customer subscription by UUID. Includes the plan denormalized, the last 20 recurring charges (each with status success/failed/skipped/completed, charge_type auto/manual/renewal_link, attempt_number, error_message and timestamps), and cancellation flags. Use this when investigating a specific subscriber's history or a failed charge ('why did Juan's subscription go past_due?').", inputSchema: { id: z.string().uuid().describe("Customer subscription UUID."), }, - src/tools/customer-subscriptions.ts:58-71 (registration)The tool is registered via server.registerTool() with the name 'deonpay_get_customer_subscription' within the registerCustomerSubscriptionTools function.
server.registerTool( "deonpay_get_customer_subscription", { title: "Get customer subscription details", description: "Fetch a single customer subscription by UUID. Includes the plan denormalized, the last 20 recurring charges (each with status success/failed/skipped/completed, charge_type auto/manual/renewal_link, attempt_number, error_message and timestamps), and cancellation flags. Use this when investigating a specific subscriber's history or a failed charge ('why did Juan's subscription go past_due?').", inputSchema: { id: z.string().uuid().describe("Customer subscription UUID."), }, }, safeHandler(async ({ id }) => { return client.get(`/customer-subscriptions/${encodeURIComponent(id)}`); }), ); - src/tools/index.ts:16-29 (registration)The registerCustomerSubscriptionTools function is imported from customer-subscriptions.ts and called in registerAllTools() — this is the top-level registration chain.
import { registerCustomerSubscriptionTools } from "./customer-subscriptions.js"; import { registerCustomerTools } from "./customers.js"; import { registerMetricsTools } from "./metrics.js"; export function registerAllTools(server: McpServer, client: DeonpayClient): void { registerLinkTools(server, client); registerCheckoutTools(server, client); registerTransactionTools(server, client); registerProductTools(server, client); registerSubscriptionTools(server, client); registerCustomerSubscriptionTools(server, client); registerCustomerTools(server, client); registerMetricsTools(server, client); } - src/tools/_helpers.ts:57-76 (helper)The safeHandler helper wraps the handler with try/catch, converting thrown errors into MCP-shaped error results via jsonResult/errorResult.
export function safeHandler<TArgs>( fn: (args: TArgs) => Promise<unknown>, ): (args: TArgs) => Promise<CallToolResult> { return async (args: TArgs) => { try { const value = await fn(args); return jsonResult(value); } catch (err) { return errorResult(err); } }; } /** * Encodes the local part / full email for use in path segments. RFC 3986 says * `@` is reserved as a sub-delim, so encodeURIComponent is the safe choice. */ export function encodePathSegment(value: string): string { return encodeURIComponent(value); }