PayPal MCP server

Integrates with PayPal's APIs for payment processing, order management, invoicing, and subscription handling through TypeScript/Node.js implementation with OAuth 2.0 authentication and comprehensive validation.
Back to servers
Setup instructions
Provider
arbuthnot-eth
Release date
Mar 21, 2025
Language
TypeScript
Stats
6 stars

PayPal MCP is a serverless integration solution that runs on Cloudflare Workers, offering low-latency payment processing at the edge. This implementation handles API requests, authentication, and secure payment operations through PayPal's Model Context Protocol.

Installation

Prerequisites

  • A Cloudflare account
  • Wrangler CLI tool installed
  • PayPal Developer account

Setting Up Wrangler

First, install Wrangler CLI if you haven't already:

npm install -g wrangler

Authenticate with your Cloudflare account:

wrangler login

Deploying the MCP Server

  1. Clone the repository:
git clone https://github.com/your-username/PayPal-MCP.git
cd PayPal-MCP
  1. Install dependencies:
npm install
  1. Configure your PayPal credentials in a wrangler.toml file:
name = "paypal-mcp"
type = "javascript"
account_id = "your-cloudflare-account-id"
workers_dev = true

[vars]
PAYPAL_CLIENT_ID = "your-paypal-client-id"
PAYPAL_CLIENT_SECRET = "your-paypal-client-secret"
  1. Deploy to Cloudflare Workers:
wrangler publish

Usage

Basic Configuration

To configure the MCP server for your application, you'll need to set up the proper environment variables either through the wrangler.toml file or via the Cloudflare dashboard.

Handling Payment Requests

Make a POST request to your worker endpoint to process a payment:

const response = await fetch('https://paypal-mcp.your-account.workers.dev/pay', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    amount: '10.00',
    currency: 'USD',
    intent: 'CAPTURE',
    return_url: 'https://your-app.com/success',
    cancel_url: 'https://your-app.com/cancel'
  })
});

const data = await response.json();

Verifying Webhooks

Set up webhook verification to process PayPal event notifications:

// Example webhook handler in your application
app.post('/paypal-webhook', async (req, res) => {
  const webhookData = req.body;
  
  const verificationResponse = await fetch('https://paypal-mcp.your-account.workers.dev/verify-webhook', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      webhook_id: 'your-webhook-id',
      webhook_event: webhookData
    })
  });
  
  const verificationResult = await verificationResponse.json();
  
  if (verificationResult.verified === true) {
    // Process the verified webhook
    console.log('Webhook verified');
    res.sendStatus(200);
  } else {
    console.error('Webhook verification failed');
    res.sendStatus(400);
  }
});

Checking Transaction Status

To check the status of a previous transaction:

const response = await fetch('https://paypal-mcp.your-account.workers.dev/transaction/ABC123XYZ', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer your-access-token'
  }
});

const transactionData = await response.json();

Troubleshooting

Common Issues

  • Authentication Errors: Ensure your PayPal credentials are correctly set in the environment variables.
  • CORS Issues: If you're calling the MCP server from a browser, make sure CORS is properly configured in your worker.
  • Rate Limiting: PayPal imposes rate limits on API calls. Implement proper error handling for 429 responses.

Checking Logs

View logs from your worker to diagnose issues:

wrangler tail

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "paypal-mcp" '{"command":"npx","args":["-y","paypal-mcp"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "paypal-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "paypal-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "paypal-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "paypal-mcp"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later