LLM integration
Last updated: Jun 10th, 10:53am
PayPal recently launched a Model Context Protocol (MCP) server that customers can use to access the power of PayPal using natural language with the AI agent of their choice. PayPal's remote MCP server now supports large language models (LLMs) from Anthropic and OpenAI, which brings even greater flexibility to developers to accelerate agentic commerce.
The following topics provide more information about these integrations.
Before you begin
Before you begin, generate a PayPal access token. You can generate an access token by making a POST request to PayPal's token endpoint, or you can generate it programmatically. For more information, see Get client ID and client secret.
1response = requests.post(2 "https://api-m.paypal.com/v1/oauth2/token",3 headers={4 "Accept": "application/json",5 "Accept-Language": "en_US",6 },7 data={"grant_type": "client_credentials"},8 auth=HTTPBasicAuth(client_id, client_secret) # <-- Basic Auth9)10access_token = response.json()["_token"]
Anthropic integration
- When you have your access token, you can connect the remote MCP server with the Anthropic LLM using the steps on this page from Anthropic. For more information about connecting to PayPal's remote MCP server, see MCP server.
- After you connect, you can start using Anthropic's LLM with PayPal's MCP server tools by initializing the client and making a request. For example, you could ask it to create an invoice, as shown in the following code examples.
- Python
- TypeScript
- cURL
1response = anthropic.beta.messages.create(2 model="claude-sonnet-4-20250514",3 max_tokens=1000,4 messages=[{5 "role": "user",6 "content": "Create an invoice for john.doe@example.com for 2 hours of consulting services at the rate of $150 per hour."7 }],8 mcp_servers=[{9 "type": "url",10 "url": "https://mcp.paypal.com/sse",11 "name": "example-mcp",12 "authorization_token": "YOUR_TOKEN"13 }],14 betas=["mcp-client-2025-04-04"]15)
OpenAI integration
For additional information about the OpenAI side of this integration, see this post from OpenAI.
- When you have your access token, you can connect to the MCP server. For details about connecting to PayPal's remote MCP server, see the MCP server page in PayPal's developer documentation.
- After you connect, you can start using OpenAI with PayPal's MCP server tools by initializing the client and making a request. For example, you can ask the client to create an invoice, as shown in the following code examples.
- Python
- cURL
1response = client.responses.create(2 model="gpt-4.1",3 tools=[{4 "type": "mcp",5 "server_label": "paypal-mcp",6 "server_url": "https://mcp.paypal.com/sse",7 }],8 input="Create an invoice for john.doe@example.com for 2 hours of consulting services at the rate of $150 per hour."9)