get_customer_subscriptions
Retrieve all subscriptions for a customer by ID. Optionally include rate plans, charges, and other details with pagination support.
Instructions
List subscriptions for a customer. GET /customers/{customerId}/subscriptions. Supports pagination and include (e.g. rateplan, rateplanCharge).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | Yes | Customer ID (required) | |
| pageNo | No | Page number (default: 1) | |
| itemPerPage | No | Items per page (default: 25) | |
| include | No | Comma-separated: rateplan, rateplanCharge, chargeTier, etc. |
Implementation Reference
- The handler function that validates inputs via Zod schema, then calls customerService.getCustomerSubscriptions to fetch subscriptions for a given customer.
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("; ")); } const { customerId, pageNo, itemPerPage, include } = parsed.data; return handleToolCall(() => customerService.getCustomerSubscriptions(client, customerId, { pageNo, itemPerPage, include }) ); } - Zod schema defining input validation: customerId (required string), pageNo, itemPerPage, include (optional).
const schema = z.object({ customerId: z.string().min(1, "customerId is required"), pageNo: z.number().optional(), itemPerPage: z.number().optional(), include: z.string().optional(), }); - MCP tool definition with name 'get_customer_subscriptions', description, and input JSON Schema (properties: customerId, pageNo, itemPerPage, include).
const definition = { name: "get_customer_subscriptions", description: "List subscriptions for a customer. GET /customers/{customerId}/subscriptions. Supports pagination and include (e.g. rateplan, rateplanCharge).", inputSchema: { type: "object" as const, properties: { customerId: { type: "string", description: "Customer ID (required)" }, pageNo: { type: "number", description: "Page number (default: 1)" }, itemPerPage: { type: "number", description: "Items per page (default: 25)" }, include: { type: "string", description: "Comma-separated: rateplan, rateplanCharge, chargeTier, etc." }, }, required: ["customerId"], }, }; - src/tools/customers/getCustomerSubscriptions.ts:41-44 (registration)Exported Tool object wrapping definition and handler, used for registration.
export const getCustomerSubscriptionsTool: Tool = { definition, handler, }; - Service-layer function that performs the HTTP GET request to /customers/{customerId}/subscriptions with optional pagination/include params.
export async function getCustomerSubscriptions( client: Client, customerId: string, params?: PaginationIncludeParams ): Promise<PaginatedResponse<unknown>> { const search = new URLSearchParams(); if (params) appendParams(search, params as Record<string, unknown>); return client.get<PaginatedResponse<unknown>>( `/customers/${customerId}/subscriptions${queryString(search)}` ); }