Get subscription plan details
deonpay_get_subscriptionRetrieve a subscription plan by UUID to see aggregated subscriber counts and the 10 most recent charges. Use this to get a quick health overview of a plan.
Instructions
Fetch a single subscription plan by UUID, including aggregated stats (active_subscribers, total_subscribers) and the most recent 10 recurring charges across all subscribers. Use this when the user wants a quick health view of a specific plan ('how is the Premium plan doing this month'). For per-subscriber detail use deonpay_list_customer_subscriptions filtered by subscription_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Subscription plan UUID. |
Implementation Reference
- src/tools/subscriptions.ts:56-58 (handler)Handler function for deonpay_get_subscription: a safeHandler wrapping a GET request to /subscriptions/{id}. It takes a 'id' (UUID) parameter, URL-encodes it, and calls the DeonPay API client to fetch the subscription plan details.
safeHandler(async ({ id }) => { return client.get(`/subscriptions/${encodeURIComponent(id)}`); }), - src/tools/subscriptions.ts:52-54 (schema)Input schema for deonpay_get_subscription: requires a single 'id' parameter of type string with UUID format validation, described as 'Subscription plan UUID.'
inputSchema: { id: z.string().uuid().describe("Subscription plan UUID."), }, - src/tools/subscriptions.ts:46-59 (registration)Registration of the 'deonpay_get_subscription' tool on the MCP server via server.registerTool(), with title 'Get subscription plan details' and a description explaining its purpose.
server.registerTool( "deonpay_get_subscription", { title: "Get subscription plan details", description: "Fetch a single subscription plan by UUID, including aggregated stats (active_subscribers, total_subscribers) and the most recent 10 recurring charges across all subscribers. Use this when the user wants a quick health view of a specific plan ('how is the Premium plan doing this month'). For per-subscriber detail use deonpay_list_customer_subscriptions filtered by subscription_id.", inputSchema: { id: z.string().uuid().describe("Subscription plan UUID."), }, }, safeHandler(async ({ id }) => { return client.get(`/subscriptions/${encodeURIComponent(id)}`); }), ); - src/tools/index.ts:20-29 (registration)The registerAllTools function calls registerSubscriptionTools(server, client) which registers the deonpay_get_subscription tool among others.
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-91 (helper)The safeHandler utility wraps the tool handler with try/catch, converting results to pretty-printed JSON and errors to MCP-shaped error results.
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); } /** * Strips undefined / null / empty-string entries from a body before sending. * The DeonPay API accepts missing fields cleanly but treating "" as a valid * value would override server-side defaults — usually not what the LLM means. */ export function compact<T extends Record<string, unknown>>(obj: T): Partial<T> { const out: Record<string, unknown> = {}; for (const [key, value] of Object.entries(obj)) { if (value === undefined || value === null) continue; if (typeof value === "string" && value.trim() === "") continue; out[key] = value; } return out as Partial<T>; }