Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions modelcontextprotocol/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node

import {PayPalAgentToolkit} from '@paypal/agent-toolkit/mcp';
// If you are developing mcp tools locally, you can update this import to point to your local mcp changes
// import {PayPalAgentToolkit} from '../../typescript/mcp';
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
import {green, red, yellow} from 'colors';

Expand Down Expand Up @@ -50,6 +52,31 @@ const ACCEPTED_TOOLS = [
'transactions.list',
'payments.createRefund',
'payments.getRefunds',
// UBB tools
'ubbMetrics.list',
'ubbMetrics.create',
'ubbMetrics.get',
'ubbMetrics.update',
'ubbMetrics.delete',
'ubbPlans.list',
'ubbPlans.create',
'ubbPlans.get',
'ubbPlans.update',
'ubbCustomers.list',
'ubbCustomers.create',
'ubbCustomers.get',
'ubbCustomers.update',
'ubbCustomers.delete',
'ubbCustomerUsage.getCurrent',
'ubbCustomerUsage.getPast',
'ubbSubscriptions.list',
'ubbSubscriptions.create',
'ubbSubscriptions.get',
'ubbSubscriptions.update',
'ubbSubscriptions.cancel',
'ubbEvents.list',
'ubbEvents.create',
'ubbEvents.createBatch',
];

export function parseArgs(args: string[]): Options {
Expand Down
4 changes: 3 additions & 1 deletion typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"clean": "rm -rf dist ai-sdk mcp",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npm i && tsup",
"build:debug": "TSUP_DEBUG=true npm run build"
"build:debug": "TSUP_DEBUG=true npm run build",
"dev": "npm run build && node ./mcp/index.js"
},
"exports": {
"./ai-sdk": {
Expand Down Expand Up @@ -40,6 +41,7 @@
"dependencies": {
"@dotenvx/dotenvx": "^1.32.0",
"@modelcontextprotocol/sdk": "^1.6.1",
"@paypal/agent-toolkit": "^1.3.5",
"@paypal/paypal-server-sdk": "^1.0.0",
"ai": "^4.0.23",
"axios": "^1.8.4",
Expand Down
76 changes: 75 additions & 1 deletion typescript/src/shared/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,32 @@ import {
updatePlan,
createRefund,
getRefund,
updateSubscription
updateSubscription,
// UBB function imports
getUBBMetrics,
createUBBMetric,
getUBBMetricById,
updateUBBMetric,
deleteUBBMetric,
getUBBPlans,
createUBBPlan,
getUBBPlanById,
updateUBBPlan,
getUBBCustomers,
createUBBCustomer,
getUBBCustomerById,
updateUBBCustomer,
deleteUBBCustomer,
getUBBCustomerCurrentUsage,
getUBBCustomerPastUsage,
getUBBSubscriptions,
createUBBSubscription,
getUBBSubscriptionById,
updateUBBSubscription,
cancelUBBSubscription,
getUBBEvents,
createUBBEvent,
createUBBEventsBatch
} from './functions';

import type { Context } from './configuration';
Expand Down Expand Up @@ -132,6 +157,55 @@ class PayPalAPI {
return createRefund(this.paypalClient, this.context, arg);
case 'get_refund':
return getRefund(this.paypalClient, this.context, arg);
// UBB method cases
case 'get_ubb_metrics':
return getUBBMetrics(this.paypalClient, this.context, arg);
case 'create_ubb_metric':
return createUBBMetric(this.paypalClient, this.context, arg);
case 'get_ubb_metric_by_id':
return getUBBMetricById(this.paypalClient, this.context, arg);
case 'update_ubb_metric':
return updateUBBMetric(this.paypalClient, this.context, arg);
case 'delete_ubb_metric':
return deleteUBBMetric(this.paypalClient, this.context, arg);
case 'get_ubb_plans':
return getUBBPlans(this.paypalClient, this.context, arg);
case 'create_ubb_plan':
return createUBBPlan(this.paypalClient, this.context, arg);
case 'get_ubb_plan_by_id':
return getUBBPlanById(this.paypalClient, this.context, arg);
case 'update_ubb_plan':
return updateUBBPlan(this.paypalClient, this.context, arg);
case 'get_ubb_customers':
return getUBBCustomers(this.paypalClient, this.context, arg);
case 'create_ubb_customer':
return createUBBCustomer(this.paypalClient, this.context, arg);
case 'get_ubb_customer_by_id':
return getUBBCustomerById(this.paypalClient, this.context, arg);
case 'update_ubb_customer':
return updateUBBCustomer(this.paypalClient, this.context, arg);
case 'delete_ubb_customer':
return deleteUBBCustomer(this.paypalClient, this.context, arg);
case 'get_ubb_customer_current_usage':
return getUBBCustomerCurrentUsage(this.paypalClient, this.context, arg);
case 'get_ubb_customer_past_usage':
return getUBBCustomerPastUsage(this.paypalClient, this.context, arg);
case 'get_ubb_subscriptions':
return getUBBSubscriptions(this.paypalClient, this.context, arg);
case 'create_ubb_subscription':
return createUBBSubscription(this.paypalClient, this.context, arg);
case 'get_ubb_subscription_by_id':
return getUBBSubscriptionById(this.paypalClient, this.context, arg);
case 'update_ubb_subscription':
return updateUBBSubscription(this.paypalClient, this.context, arg);
case 'cancel_ubb_subscription':
return cancelUBBSubscription(this.paypalClient, this.context, arg);
case 'get_ubb_events':
return getUBBEvents(this.paypalClient, this.context, arg);
case 'create_ubb_event':
return createUBBEvent(this.paypalClient, this.context, arg);
case 'create_ubb_events_batch':
return createUBBEventsBatch(this.paypalClient, this.context, arg);
default:
throw new Error(`Invalid method: ${method}`);
}
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/shared/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PayPalClient {
}

this._baseUrl = this._isSandbox
? 'https://api.sandbox.paypal.com'
? 'https://api-m.sandbox.paypal.com'
: 'https://api.paypal.com';

logger(`[PayPal Setttings] Environment: ${this._isSandbox ? "Sandbox" : "Live"}`);
Expand Down
Loading