Skip to main content
Glama
DynamicEndpoints

PayPal MCP

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
NameRequiredDescriptionDefault
page_sizeNo
pageNo

Implementation Reference

  • 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 }
        }
      }
    },
  • 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 }
      }
    }
  • 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DynamicEndpoints/Paypal-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server