Skip to main content
Glama
DynamicEndpoints

PayPal MCP

create_payment

Process PayPal payments by specifying payment intent, payer details, and transaction amounts to complete online transactions.

Instructions

Create a payment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
intentYes
payerYes
transactionsYes

Implementation Reference

  • The core handler logic for the 'create_payment' tool. It validates the input arguments, makes a POST request to the PayPal v2/payments/payment endpoint using axios, and returns the API response as formatted JSON text.
    case 'create_payment': {
      const args = this.validatePayment(request.params.arguments);
      const response = await axios.post<PayPalPayment>(
        'https://api-m.sandbox.paypal.com/v2/payments/payment',
        args,
        { headers }
      );
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(response.data, null, 2)
        }]
      };
    }
  • src/index.ts:819-873 (registration)
    Tool registration in the ListTools response, defining name, description, and detailed JSON input schema for parameter validation.
      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']
      }
    },
  • TypeScript interface defining the structure of PayPalPayment used for type safety in the handler and validation.
    interface PayPalPayment {
      id?: string;
      intent: string;
      payer: {
        payment_method: string;
        funding_instruments?: Array<{
          credit_card?: {
            number: string;
            type: string;
            expire_month: number;
            expire_year: number;
            cvv2: string;
            first_name: string;
            last_name: string;
          };
        }>;
      };
      transactions: Array<{
        amount: {
          total: string;
          currency: string;
        };
        description?: string;
      }>;
    }
  • Helper function validatePayment that parses, validates, and structures the tool arguments according to the PayPalPayment interface, throwing MCP errors on invalid input.
    private validatePayment(args: unknown): PayPalPayment {
      if (typeof args !== 'object' || !args) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid payment data');
      }
    
      const payment = args as Record<string, unknown>;
      
      if (typeof payment.intent !== 'string' ||
          !payment.payer || typeof payment.payer !== 'object' ||
          !Array.isArray(payment.transactions) ||
          payment.transactions.length === 0) {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required payment fields');
      }
    
      const payer = payment.payer as Record<string, unknown>;
      if (typeof payer.payment_method !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid payment method');
      }
    
      const transactions = payment.transactions.map(transaction => {
        const trans = transaction as Record<string, unknown>;
        if (!trans.amount || typeof trans.amount !== 'object') {
          throw new McpError(ErrorCode.InvalidParams, 'Invalid transaction amount');
        }
    
        const amount = trans.amount as Record<string, unknown>;
        if (typeof amount.total !== 'string' || typeof amount.currency !== 'string') {
          throw new McpError(ErrorCode.InvalidParams, 'Invalid amount fields');
        }
    
        const validatedTransaction = {
          amount: {
            total: amount.total,
            currency: amount.currency
          }
        };
    
        if (typeof trans.description === 'string') {
          (validatedTransaction as any).description = trans.description;
        }
    
        return validatedTransaction;
      });
    
      return {
        intent: payment.intent,
        payer: {
          payment_method: payer.payment_method,
          funding_instruments: payer.funding_instruments as PayPalPayment['payer']['funding_instruments']
        },
        transactions
      };
    }
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers nothing beyond the basic action. It doesn't indicate whether this is a live transaction, a draft, a test payment, what permissions are required, whether it's reversible, what happens on failure, or any rate limits. For a financial transaction tool with significant implications, this complete lack of behavioral context is inadequate.

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 maximally concise with just two words. While this represents severe under-specification rather than ideal conciseness, from a pure structural perspective, there's no wasted language or unnecessary elaboration. Every word (both of them) directly relates to the tool's purpose.

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 of the input schema (3 required parameters with nested objects for payment processing), the absence of annotations, and no output schema, the description is completely inadequate. A payment creation tool requires significant contextual information about authentication requirements, transaction behavior, error handling, and parameter usage that is entirely missing here.

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?

The schema description coverage is 0%, meaning none of the 3 parameters (intent, payer, transactions) or their complex nested structures are documented in the schema. The description adds zero information about what these parameters mean, their expected formats, or how they should be used. This leaves the agent with no semantic understanding of the required inputs for a financial transaction.

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' is a tautology that merely restates the tool name without adding any meaningful context. It doesn't specify what type of payment, through which system, or what resources are involved. While it includes a verb ('Create') and resource ('payment'), it lacks the specificity needed to distinguish this from sibling tools like create_invoice or create_order.

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 provides absolutely no guidance about when to use this tool versus alternatives. With multiple sibling tools for creating financial transactions (create_invoice, create_order, create_payment_token, create_payout), the agent receives no indication of what distinguishes this payment creation tool from those other options or when it would be the appropriate choice.

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