Skip to main content
Glama
DynamicEndpoints

PayPal MCP

create_payment_token

Generate a secure payment token for storing customer payment methods, enabling recurring transactions and one-click checkouts in PayPal integrations.

Instructions

Create a payment token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customerYes
payment_sourceYes

Implementation Reference

  • src/index.ts:780-817 (registration)
    Registration of the 'create_payment_token' tool with its input schema definition.
    {
      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']
      }
    },
  • The handler function for 'create_payment_token' that calls the PayPal API to create a payment token.
    case 'create_payment_token': {
      const args = this.validatePaymentToken(request.params.arguments);
      const response = await axios.post<PayPalPaymentToken>(
        'https://api-m.sandbox.paypal.com/v3/payment-tokens',
        args,
        { headers }
      );
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(response.data, null, 2)
        }]
      };
    }
  • Helper function to validate and sanitize input parameters for the create_payment_token tool.
    private validatePaymentToken(args: unknown): PayPalPaymentToken {
      if (typeof args !== 'object' || !args) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid payment token data');
      }
    
      const token = args as Record<string, unknown>;
      
      if (!token.customer || typeof token.customer !== 'object' ||
          !token.payment_source || typeof token.payment_source !== 'object') {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required payment token fields');
      }
    
      const customer = token.customer as Record<string, unknown>;
      if (typeof customer.id !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid customer ID');
      }
    
      const validatedToken: PayPalPaymentToken = {
        customer: {
          id: customer.id
        },
        payment_source: {}
      };
    
      if (typeof customer.email_address === 'string') {
        validatedToken.customer.email_address = customer.email_address;
      }
    
      const source = token.payment_source as Record<string, unknown>;
      if (source.card && typeof source.card === 'object') {
        const card = source.card as Record<string, unknown>;
        if (typeof card.name === 'string' &&
            typeof card.number === 'string' &&
            typeof card.expiry === 'string' &&
            typeof card.security_code === 'string') {
          validatedToken.payment_source.card = {
            name: card.name,
            number: card.number,
            expiry: card.expiry,
            security_code: card.security_code
          };
        }
      }
    
      if (source.paypal && typeof source.paypal === 'object') {
        const paypal = source.paypal as Record<string, unknown>;
        if (typeof paypal.email_address === 'string') {
          validatedToken.payment_source.paypal = {
            email_address: paypal.email_address
          };
          if (typeof paypal.account_id === 'string') {
            validatedToken.payment_source.paypal.account_id = paypal.account_id;
          }
        }
      }
    
      return validatedToken;
    }
  • TypeScript interface defining the structure of a PayPal payment token, used in the tool implementation.
    interface PayPalPaymentToken {
      id?: string;
      customer: {
        id: string;
        email_address?: string;
        phone?: {
          phone_type: string;
          phone_number: {
            national_number: string;
          };
        };
      };
      payment_source: {
        card?: {
          name: string;
          number: string;
          expiry: string;
          security_code: string;
        };
        paypal?: {
          email_address: string;
          account_id?: string;
        };
      };
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the action 'create' without any details about permissions required, whether this is a sensitive operation (handling payment data), rate limits, error conditions, or what happens after creation (e.g., token storage, expiration). This is inadequate for a tool that likely involves financial transactions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just three words, making it front-loaded and free of unnecessary elaboration. However, this conciseness comes at the cost of being under-specified, but as per the scoring rules, it earns full points for brevity and structure.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (payment-related tool with nested parameters), lack of annotations, 0% schema coverage, and no output schema, the description is severely incomplete. It fails to explain what a payment token is, how to use it, what the inputs mean, or what to expect as output, making it inadequate for safe and effective tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning parameters are undocumented in the schema. The description adds no information about the parameters (customer and payment_source), their purposes, or how they should be structured (e.g., customer ID format, card details). For a tool with 2 required parameters and nested objects, this leaves critical semantics unexplained.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Create a payment token' is essentially a tautology that restates the tool name without elaboration. It specifies the verb 'create' and resource 'payment token', but provides no additional context about what a payment token is, how it differs from other payment-related tools (like create_payment), or what system it operates within. This leaves the purpose vague compared to sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives like create_payment or create_invoice. It does not mention prerequisites, context, or exclusions, leaving the agent with no information to make an informed choice among the payment-related sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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