Skip to main content
Glama
DynamicEndpoints

PayPal MCP

create_order

Create a new PayPal order for payment authorization or capture, specifying purchase amounts and details to initiate transactions.

Instructions

Create a new order in PayPal

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
intentYes
purchase_unitsYes

Implementation Reference

  • The handler logic for the 'create_order' tool within the CallToolRequestSchema handler. It validates the arguments using validatePayPalOrder, makes a POST request to PayPal's orders endpoint, and returns the JSON response.
    case 'create_order': {
      const args = this.validatePayPalOrder(request.params.arguments);
      const response = await axios.post<PayPalOrder>(
        'https://api-m.sandbox.paypal.com/v2/checkout/orders',
        args,
        { headers }
      );
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(response.data, null, 2)
        }]
      };
    }
  • src/index.ts:944-976 (registration)
    Tool registration for 'create_order' in the ListToolsRequestSchema handler, defining the tool's name, description, and input schema.
    {
      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']
      }
    },
  • validatePayPalOrder: Schema validation function that parses and validates the input arguments for the create_order tool, ensuring correct structure and types matching PayPalOrder interface.
    private validatePayPalOrder(args: unknown): PayPalOrder {
      if (typeof args !== 'object' || !args) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid order data');
      }
    
      const order = args as Record<string, unknown>;
      
      if (!['CAPTURE', 'AUTHORIZE'].includes(order.intent as string) ||
          !Array.isArray(order.purchase_units) ||
          order.purchase_units.length === 0) {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required order fields');
      }
    
      const purchase_units = order.purchase_units.map(unit => {
        const unitObj = unit as Record<string, unknown>;
        if (!unitObj.amount || typeof unitObj.amount !== 'object') {
          throw new McpError(ErrorCode.InvalidParams, 'Invalid purchase unit amount');
        }
    
        const amount = unitObj.amount as Record<string, unknown>;
        if (typeof amount.currency_code !== 'string' || typeof amount.value !== 'string') {
          throw new McpError(ErrorCode.InvalidParams, 'Invalid amount fields');
        }
    
        const validatedUnit: PayPalOrder['purchase_units'][0] = {
          amount: {
            currency_code: amount.currency_code,
            value: amount.value
          }
        };
    
        if (typeof unitObj.description === 'string') {
          validatedUnit.description = unitObj.description;
        }
        if (typeof unitObj.reference_id === 'string') {
          validatedUnit.reference_id = unitObj.reference_id;
        }
    
        return validatedUnit;
      });
    
      return {
        intent: order.intent as 'CAPTURE' | 'AUTHORIZE',
        purchase_units
      };
    }
  • PayPalOrder TypeScript interface defining the expected structure for order data used in create_order tool.
    interface PayPalOrder {
      id?: string;
      intent: 'CAPTURE' | 'AUTHORIZE';
      purchase_units: Array<{
        amount: {
          currency_code: string;
          value: string;
        };
        description?: string;
        reference_id?: string;
      }>;
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states the action without behavioral details. It doesn't disclose if this requires specific permissions, has side effects like charging money, involves rate limits, or what the response entails, which is inadequate for a mutation tool.

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 a single, efficient sentence with no wasted words, making it highly concise and front-loaded. Every word contributes directly to stating the tool's purpose.

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

Completeness2/5

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

For a mutation tool with no annotations, 0% schema coverage, and no output schema, the description is incomplete. It lacks details on behavior, parameters, and expected outcomes, failing to provide sufficient context for effective use.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but adds no parameter information. It doesn't explain 'intent' (CAPTURE vs AUTHORIZE) or 'purchase_units', leaving semantics unclear beyond the schema's structure.

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

Purpose4/5

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

The description clearly states the action ('Create') and resource ('new order in PayPal'), making the purpose evident. It doesn't explicitly differentiate from siblings like 'create_invoice' or 'create_payment', but the specificity to 'order' provides some distinction.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'create_invoice' or 'create_payment'. The description lacks context about prerequisites, such as authentication or account setup, leaving the agent without usage direction.

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