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.
First, install Wrangler CLI if you haven't already:
npm install -g wrangler
Authenticate with your Cloudflare account:
wrangler login
git clone https://github.com/your-username/PayPal-MCP.git
cd PayPal-MCP
npm install
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"
wrangler publish
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.
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();
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);
}
});
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();
View logs from your worker to diagnose issues:
wrangler tail
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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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