|
| 1 | +# PayPal |
| 2 | + |
| 3 | +The [PayPal MCP Server](https://github.com/paypal/paypal-mcp-server) connects |
| 4 | +your ADK agent to the [PayPal](https://www.paypal.com/) ecosystem. This |
| 5 | +integration gives your agent the ability to manage payments, invoices, |
| 6 | +subscriptions, and disputes using natural language, enabling automated commerce |
| 7 | +workflows and business insights. |
| 8 | + |
| 9 | +## Use cases |
| 10 | + |
| 11 | +- **Streamline Financial Operations**: Create orders, send invoices, and process |
| 12 | + refunds directly through chat without switching context. You can instruct your |
| 13 | + agent to "bill Client X" or "refund order Y" immediately. |
| 14 | + |
| 15 | +- **Manage Subscriptions & Products**: Handle the full lifecycle of recurring |
| 16 | + billing by creating products, setting up subscription plans, and managing |
| 17 | + subscriber details using natural language. |
| 18 | + |
| 19 | +- **Resolve Issues & Track Performance**: Summarize and accept dispute claims, |
| 20 | + track shipment statuses, and retrieve merchant insights to make data-driven |
| 21 | + decisions on the fly. |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +- Create a [PayPal Developer account](https://developer.paypal.com/) |
| 26 | +- Create an app and retrieve your credentials from the |
| 27 | + [PayPal Developer Dashboard](https://developer.paypal.com/) |
| 28 | +- [Generate an access token](https://developer.paypal.com/reference/get-an-access-token/) |
| 29 | + from your credentials |
| 30 | + |
| 31 | +## Use with agent |
| 32 | + |
| 33 | +=== "Local MCP Server" |
| 34 | + |
| 35 | + ```python |
| 36 | + from google.adk.agents import Agent |
| 37 | + from google.adk.tools.mcp_tool import McpToolset |
| 38 | + from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams |
| 39 | + from mcp import StdioServerParameters |
| 40 | + |
| 41 | + PAYPAL_ENVIRONMENT = "SANDBOX" # Options: "SANDBOX" or "PRODUCTION" |
| 42 | + PAYPAL_ACCESS_TOKEN = "YOUR_PAYPAL_ACCESS_TOKEN" |
| 43 | + |
| 44 | + root_agent = Agent( |
| 45 | + model="gemini-2.5-pro", |
| 46 | + name="paypal_agent", |
| 47 | + instruction="Help users manage their PayPal account", |
| 48 | + tools=[ |
| 49 | + McpToolset( |
| 50 | + connection_params=StdioConnectionParams( |
| 51 | + server_params=StdioServerParameters( |
| 52 | + command="npx", |
| 53 | + args=[ |
| 54 | + "-y", |
| 55 | + "@paypal/mcp", |
| 56 | + "--tools=all", |
| 57 | + # (Optional) Specify which tools to enable |
| 58 | + # "--tools=subscriptionPlans.list,subscriptionPlans.show", |
| 59 | + ], |
| 60 | + env={ |
| 61 | + "PAYPAL_ACCESS_TOKEN": PAYPAL_ACCESS_TOKEN, |
| 62 | + "PAYPAL_ENVIRONMENT": PAYPAL_ENVIRONMENT, |
| 63 | + } |
| 64 | + ), |
| 65 | + timeout=300, |
| 66 | + ), |
| 67 | + ) |
| 68 | + ], |
| 69 | + ) |
| 70 | + ``` |
| 71 | + |
| 72 | +=== "Remote MCP Server" |
| 73 | + |
| 74 | + ```python |
| 75 | + from google.adk.agents import Agent |
| 76 | + from google.adk.tools.mcp_tool import McpToolset |
| 77 | + from google.adk.tools.mcp_tool.mcp_session_manager import SseConnectionParams |
| 78 | + |
| 79 | + PAYPAL_MCP_ENDPOINT = "https://mcp.sandbox.paypal.com/sse" # Production: https://mcp.paypal.com/sse |
| 80 | + PAYPAL_ACCESS_TOKEN = "YOUR_PAYPAL_ACCESS_TOKEN" |
| 81 | + |
| 82 | + root_agent = Agent( |
| 83 | + model="gemini-2.5-pro", |
| 84 | + name="paypal_agent", |
| 85 | + instruction="Help users manage their PayPal account", |
| 86 | + tools=[ |
| 87 | + McpToolset( |
| 88 | + connection_params=SseConnectionParams( |
| 89 | + url=PAYPAL_MCP_ENDPOINT, |
| 90 | + headers={ |
| 91 | + "Authorization": f"Bearer {PAYPAL_ACCESS_TOKEN}", |
| 92 | + }, |
| 93 | + ), |
| 94 | + ) |
| 95 | + ], |
| 96 | + ) |
| 97 | + ``` |
| 98 | + |
| 99 | +!!! note |
| 100 | + |
| 101 | + **Token Expiration**: PayPal Access Tokens have a limited lifespan of 3-8 |
| 102 | + hours. If your agent stops working, ensure your token has not expired and |
| 103 | + generate a new one if necessary. You should implement token refresh logic to |
| 104 | + handle token expiration. |
| 105 | + |
| 106 | +## Available tools |
| 107 | + |
| 108 | +### Catalog management |
| 109 | + |
| 110 | +Tool | Description |
| 111 | +---- | ----------- |
| 112 | +`create_product` | Create a new product in the PayPal catalog |
| 113 | +`list_products` | List products from the PayPal catalog |
| 114 | +`show_product_details` | Show details of a specific product from the PayPal catalog |
| 115 | +`update_product` | Update an existing product in the PayPal catalog |
| 116 | + |
| 117 | +### Dispute management |
| 118 | + |
| 119 | +Tool | Description |
| 120 | +---- | ----------- |
| 121 | +`list_disputes` | Retrieve a summary of all disputes with optional filtering |
| 122 | +`get_dispute` | Retrieve detailed information about a specific dispute |
| 123 | +`accept_dispute_claim` | Accept a dispute claim, resolving it in favor of the buyer |
| 124 | + |
| 125 | +### Invoices |
| 126 | + |
| 127 | +Tool | Description |
| 128 | +---- | ----------- |
| 129 | +`create_invoice` | Create a new invoice in the PayPal system |
| 130 | +`list_invoices` | List invoices |
| 131 | +`get_invoice` | Retrieve details about a specific invoice |
| 132 | +`send_invoice` | Send an existing invoice to the specified recipient |
| 133 | +`send_invoice_reminder` | Send a reminder for an existing invoice |
| 134 | +`cancel_sent_invoice` | Cancel a sent invoice |
| 135 | +`generate_invoice_qr_code` | Generate a QR code for an invoice |
| 136 | + |
| 137 | +### Payments |
| 138 | + |
| 139 | +Tool | Description |
| 140 | +---- | ----------- |
| 141 | +`create_order` | Create an order in the PayPal system based on the provided details |
| 142 | +`create_refund` | Process a refund for a captured payment |
| 143 | +`get_order` | Get details of a specific payment |
| 144 | +`get_refund` | Get the details for a specific refund |
| 145 | +`pay_order` | Capture payment for an authorized order |
| 146 | + |
| 147 | +### Reporting and insights |
| 148 | + |
| 149 | +Tool | Description |
| 150 | +---- | ----------- |
| 151 | +`get_merchant_insights` | Retrieve business intelligence metrics and analytics for a merchant |
| 152 | +`list_transactions` | List all transactions |
| 153 | + |
| 154 | +### Shipment tracking |
| 155 | + |
| 156 | +Tool | Description |
| 157 | +---- | ----------- |
| 158 | +`create_shipment_tracking` | Create shipment tracking information for a PayPal transaction |
| 159 | +`get_shipment_tracking` | Get shipment tracking information for a specific shipment |
| 160 | +`update_shipment_tracking` | Update shipment tracking information for a specific shipment |
| 161 | + |
| 162 | +### Subscription management |
| 163 | + |
| 164 | +Tool | Description |
| 165 | +---- | ----------- |
| 166 | +`cancel_subscription` | Cancel an active subscription |
| 167 | +`create_subscription` | Create a new subscription |
| 168 | +`create_subscription_plan` | Create a new subscription plan |
| 169 | +`update_subscription` | Update an existing subscription |
| 170 | +`list_subscription_plans` | List subscription plans |
| 171 | +`show_subscription_details` | Show details of a specific subscription |
| 172 | +`show_subscription_plan_details` | Show details of a specific subscription plan |
| 173 | + |
| 174 | +## Configuration |
| 175 | + |
| 176 | +You can control which tools are enabled using the `--tools` command-line |
| 177 | +argument. This is useful for limiting the scope of the agent's permissions. |
| 178 | + |
| 179 | +You can enable all tools with `--tools=all` or specify a comma-separated list of |
| 180 | +specific tool identifiers. |
| 181 | + |
| 182 | +**Note**: The configuration identifiers below use dot notation (e.g., |
| 183 | +`invoices.create`) which differs from the tool names exposed to the agent (e.g., |
| 184 | +`create_invoice`). |
| 185 | + |
| 186 | +**Products**: `products.create`, `products.list`, `products.update`, |
| 187 | +`products.show` |
| 188 | + |
| 189 | +**Disputes**: |
| 190 | +`disputes.list`, `disputes.get`, `disputes.create` |
| 191 | + |
| 192 | +**Invoices**: `invoices.create`, `invoices.list`, `invoices.get`, |
| 193 | +`invoices.send`, `invoices.sendReminder`, `invoices.cancel`, |
| 194 | +`invoices.generateQRC` |
| 195 | + |
| 196 | +**Orders & Payments**: `orders.create`, `orders.get`, `orders.capture`, |
| 197 | +`payments.createRefund`, `payments.getRefunds` |
| 198 | + |
| 199 | +**Transactions**: |
| 200 | +`transactions.list` |
| 201 | + |
| 202 | +**Shipment**: |
| 203 | +`shipment.create`, `shipment.get` |
| 204 | + |
| 205 | +**Subscriptions**: `subscriptionPlans.create`, `subscriptionPlans.list`, |
| 206 | +`subscriptionPlans.show`, `subscriptions.create`, `subscriptions.show`, |
| 207 | +`subscriptions.cancel` |
| 208 | + |
| 209 | +## Additional resources |
| 210 | + |
| 211 | +- [PayPal MCP Server Documentation](https://docs.paypal.ai/developer/tools/ai/mcp-quickstart) |
| 212 | +- [PayPal MCP Server Repository](https://github.com/paypal/paypal-mcp-server) |
| 213 | +- [PayPal Agent Tools Reference](https://docs.paypal.ai/developer/tools/ai/agent-tools-ref) |
0 commit comments