Skip to main content
Glama
DynamicEndpoints

PayPal MCP

create_product

Create new products in PayPal by specifying name, description, type, and category to manage your inventory.

Instructions

Create a new product in PayPal

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionYes
typeYes
categoryYes
image_urlNo
home_urlNo

Implementation Reference

  • The main handler for the 'create_product' tool. Validates input using validatePayPalProduct, makes a POST request to PayPal's catalog products API, and returns the response.
    case 'create_product': {
      const args = this.validatePayPalProduct(request.params.arguments);
      const response = await axios.post<PayPalResponse>(
        'https://api-m.sandbox.paypal.com/v1/catalogs/products',
        args,
        { headers }
      );
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(response.data, null, 2)
        }]
      };
    }
  • The input schema definition for the 'create_product' tool, registered in the tools list for ListToolsRequest.
    {
      name: 'create_product',
      description: 'Create a new product in PayPal',
      inputSchema: {
        type: 'object',
        properties: {
          name: { type: 'string' },
          description: { type: 'string' },
          type: { 
            type: 'string',
            enum: ['PHYSICAL', 'DIGITAL', 'SERVICE']
          },
          category: { type: 'string' },
          image_url: { type: 'string' },
          home_url: { type: 'string' }
        },
        required: ['name', 'description', 'type', 'category']
      }
  • Helper method that validates and sanitizes the input arguments for the create_product tool, ensuring required fields and types match the schema.
    private validatePayPalProduct(args: unknown): PayPalProduct {
      if (typeof args !== 'object' || !args) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid product data');
      }
    
      const product = args as Record<string, unknown>;
      
      if (typeof product.name !== 'string' ||
          typeof product.description !== 'string' ||
          !['PHYSICAL', 'DIGITAL', 'SERVICE'].includes(product.type as string) ||
          typeof product.category !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required product fields');
      }
    
      const validatedProduct: PayPalProduct = {
        name: product.name,
        description: product.description,
        type: product.type as 'PHYSICAL' | 'DIGITAL' | 'SERVICE',
        category: product.category,
      };
    
      if (typeof product.image_url === 'string') {
        validatedProduct.image_url = product.image_url;
      }
      if (typeof product.home_url === 'string') {
        validatedProduct.home_url = product.home_url;
      }
    
      return validatedProduct;
    }
  • src/index.ts:777-1139 (registration)
    The tool is registered by including its definition in the tools array returned by the ListToolsRequest handler in setupToolHandlers method.
    private setupToolHandlers() {
      this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: [
          {
            name: 'create_payment_token',
            description: 'Create a payment token',
            inputSchema: {
              type: 'object',
              properties: {
                customer: {
                  type: 'object',
                  properties: {
                    id: { type: 'string' },
                    email_address: { type: 'string' }
                  },
                  required: ['id']
                },
                payment_source: {
                  type: 'object',
                  properties: {
                    card: {
                      type: 'object',
                      properties: {
                        name: { type: 'string' },
                        number: { type: 'string' },
                        expiry: { type: 'string' },
                        security_code: { type: 'string' }
                      }
                    },
                    paypal: {
                      type: 'object',
                      properties: {
                        email_address: { type: 'string' }
                      }
                    }
                  }
                }
              },
              required: ['customer', 'payment_source']
            }
          },
          {
            name: 'create_payment',
            description: 'Create a payment',
            inputSchema: {
              type: 'object',
              properties: {
                intent: { type: 'string' },
                payer: {
                  type: 'object',
                  properties: {
                    payment_method: { type: 'string' },
                    funding_instruments: {
                      type: 'array',
                      items: {
                        type: 'object',
                        properties: {
                          credit_card: {
                            type: 'object',
                            properties: {
                              number: { type: 'string' },
                              type: { type: 'string' },
                              expire_month: { type: 'number' },
                              expire_year: { type: 'number' },
                              cvv2: { type: 'string' },
                              first_name: { type: 'string' },
                              last_name: { type: 'string' }
                            }
                          }
                        }
                      }
                    }
                  },
                  required: ['payment_method']
                },
                transactions: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      amount: {
                        type: 'object',
                        properties: {
                          total: { type: 'string' },
                          currency: { type: 'string' }
                        },
                        required: ['total', 'currency']
                      },
                      description: { type: 'string' }
                    },
                    required: ['amount']
                  }
                }
              },
              required: ['intent', 'payer', 'transactions']
            }
          },
          {
            name: 'create_payout',
            description: 'Create a batch payout',
            inputSchema: {
              type: 'object',
              properties: {
                sender_batch_header: {
                  type: 'object',
                  properties: {
                    sender_batch_id: { type: 'string' },
                    email_subject: { type: 'string' },
                    recipient_type: { type: 'string' }
                  },
                  required: ['sender_batch_id']
                },
                items: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      recipient_type: { type: 'string' },
                      amount: {
                        type: 'object',
                        properties: {
                          value: { type: 'string' },
                          currency: { type: 'string' }
                        },
                        required: ['value', 'currency']
                      },
                      receiver: { type: 'string' },
                      note: { type: 'string' },
                      sender_item_id: { type: 'string' }
                    },
                    required: ['recipient_type', 'amount', 'receiver']
                  }
                }
              },
              required: ['sender_batch_header', 'items']
            }
          },
          {
            name: 'create_referenced_payout',
            description: 'Create a referenced payout',
            inputSchema: {
              type: 'object',
              properties: {
                referenced_payouts: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      reference_id: { type: 'string' },
                      reference_type: { type: 'string' },
                      payout_amount: {
                        type: 'object',
                        properties: {
                          currency_code: { type: 'string' },
                          value: { type: 'string' }
                        },
                        required: ['currency_code', 'value']
                      },
                      payout_destination: { type: 'string' }
                    },
                    required: ['reference_id', 'reference_type', 'payout_amount', 'payout_destination']
                  }
                }
              },
              required: ['referenced_payouts']
            }
          },
          {
            name: 'create_order',
            description: 'Create a new order in PayPal',
            inputSchema: {
              type: 'object',
              properties: {
                intent: { 
                  type: 'string',
                  enum: ['CAPTURE', 'AUTHORIZE']
                },
                purchase_units: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      amount: {
                        type: 'object',
                        properties: {
                          currency_code: { type: 'string' },
                          value: { type: 'string' }
                        },
                        required: ['currency_code', 'value']
                      },
                      description: { type: 'string' },
                      reference_id: { type: 'string' }
                    },
                    required: ['amount']
                  }
                }
              },
              required: ['intent', 'purchase_units']
            }
          },
          {
            name: 'create_partner_referral',
            description: 'Create a partner referral',
            inputSchema: {
              type: 'object',
              properties: {
                individual_owners: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      names: {
                        type: 'array',
                        items: {
                          type: 'object',
                          properties: {
                            given_name: { type: 'string' },
                            surname: { type: 'string' }
                          },
                          required: ['given_name', 'surname']
                        }
                      }
                    },
                    required: ['names']
                  }
                },
                business_entity: {
                  type: 'object',
                  properties: {
                    business_type: {
                      type: 'object',
                      properties: {
                        type: { type: 'string' }
                      },
                      required: ['type']
                    },
                    business_name: { type: 'string' }
                  },
                  required: ['business_type', 'business_name']
                },
                email: { type: 'string' }
              },
              required: ['individual_owners', 'business_entity', 'email']
            }
          },
          {
            name: 'create_web_profile',
            description: 'Create a web experience profile',
            inputSchema: {
              type: 'object',
              properties: {
                name: { type: 'string' },
                presentation: {
                  type: 'object',
                  properties: {
                    brand_name: { type: 'string' },
                    logo_image: { type: 'string' },
                    locale_code: { type: 'string' }
                  }
                },
                input_fields: {
                  type: 'object',
                  properties: {
                    no_shipping: { type: 'number' },
                    address_override: { type: 'number' }
                  }
                },
                flow_config: {
                  type: 'object',
                  properties: {
                    landing_page_type: { type: 'string' },
                    bank_txn_pending_url: { type: 'string' }
                  }
                }
              },
              required: ['name']
            }
          },
          {
            name: 'create_product',
            description: 'Create a new product in PayPal',
            inputSchema: {
              type: 'object',
              properties: {
                name: { type: 'string' },
                description: { type: 'string' },
                type: { 
                  type: 'string',
                  enum: ['PHYSICAL', 'DIGITAL', 'SERVICE']
                },
                category: { type: 'string' },
                image_url: { type: 'string' },
                home_url: { type: 'string' }
              },
              required: ['name', 'description', 'type', 'category']
            }
          },
          {
            name: 'list_products',
            description: 'List all products',
            inputSchema: {
              type: 'object',
              properties: {
                page_size: { type: 'number', minimum: 1, maximum: 100 },
                page: { type: 'number', minimum: 1 }
              }
            }
          },
          {
            name: 'get_dispute',
            description: 'Get details of a dispute',
            inputSchema: {
              type: 'object',
              properties: {
                dispute_id: { type: 'string' }
              },
              required: ['dispute_id']
            }
          },
          {
            name: 'get_userinfo',
            description: 'Get user info from identity token',
            inputSchema: {
              type: 'object',
              properties: {
                access_token: { type: 'string' }
              },
              required: ['access_token']
            }
          },
          {
            name: 'create_invoice',
            description: 'Create a new invoice',
            inputSchema: {
              type: 'object',
              properties: {
                invoice_number: { type: 'string' },
                reference: { type: 'string' },
                currency_code: { type: 'string' },
                recipient_email: { type: 'string' },
                items: {
                  type: 'array',
                  items: {
                    type: 'object',
                    properties: {
                      name: { type: 'string' },
                      quantity: { type: 'string' },
                      unit_amount: {
                        type: 'object',
                        properties: {
                          currency_code: { type: 'string' },
                          value: { type: 'string' }
                        }
                      }
                    }
                  }
                }
              },
              required: ['invoice_number', 'reference', 'currency_code', 'recipient_email', 'items']
            }
          }
        ]
      }));

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