list_products
Retrieve and display all available products from your PayPal account. Use pagination parameters to manage large product lists effectively.
Instructions
List all products
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_size | No | ||
| page | No |
Implementation Reference
- src/index.ts:1274-1290 (handler)The handler function for the 'list_products' tool. It validates pagination parameters, constructs a query string, makes a GET request to the PayPal API to list products, and returns the JSON response.case 'list_products': { const args = this.validatePaginationParams(request.params.arguments); const params = new URLSearchParams({ page_size: args.page_size?.toString() || '10', page: args.page?.toString() || '1' }); const response = await axios.get<PayPalResponse>( `https://api-m.sandbox.paypal.com/v1/catalogs/products?${params}`, { headers } ); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }] }; }
- src/index.ts:1074-1084 (registration)Registration of the 'list_products' tool in the listTools response, including name, description, and input schema.{ name: 'list_products', description: 'List all products', inputSchema: { type: 'object', properties: { page_size: { type: 'number', minimum: 1, maximum: 100 }, page: { type: 'number', minimum: 1 } } } },
- src/index.ts:1077-1083 (schema)Input schema definition for the 'list_products' tool, specifying optional pagination parameters.inputSchema: { type: 'object', properties: { page_size: { type: 'number', minimum: 1, maximum: 100 }, page: { type: 'number', minimum: 1 } } }
- src/index.ts:681-697 (helper)Helper function to validate and sanitize pagination parameters (page_size and page) for the list_products tool.private validatePaginationParams(args: unknown): { page_size?: number; page?: number } { if (typeof args !== 'object' || !args) { return {}; } const params = args as Record<string, unknown>; const validated: { page_size?: number; page?: number } = {}; if (typeof params.page_size === 'number' && params.page_size >= 1 && params.page_size <= 100) { validated.page_size = params.page_size; } if (typeof params.page === 'number' && params.page >= 1) { validated.page = params.page; } return validated; }