PayPal Java MCP server

Integrates with PayPal's Java API to provide payment processing analysis tools, including authorization rate analysis and a basic calculator, supporting both REST and JSON-RPC interfaces for versatile deployment.
Back to servers
Setup instructions
Provider
Ashwani Kumar
Release date
Mar 06, 2025
Language
Java

This Java implementation of a PayPal MCP (Merchant Capability Platform) server provides tools for analyzing and improving payment processing, with both REST API and JSON-RPC interfaces for client integration.

Running the Server

Web Mode (Default)

To run the server in web mode with a REST API on port 8080:

java -jar target/paypal-java-mcp-server-0.0.1-SNAPSHOT.jar

You can access the API at http://localhost:8080/api/mcp.

JSON-RPC over stdio Mode

For JSON-RPC over standard input/output:

java -Dspring.profiles.active=stdio -Dspring.main.web-application-type=NONE -Djsonrpc.stdio.interactive=true -jar target/paypal-java-mcp-server-0.0.1-SNAPSHOT-stdio.jar

This mode reads JSON-RPC requests from stdin and writes responses to stdout. All logs go to stderr and a log file.

Important: The JSON-RPC stdio interface requires stdin/stdout connectivity. When deploying, ensure the process has access to stdin/stdout by running in interactive mode.

Test the stdio mode with:

./test-stdio.sh

Running in Non-Interactive Environments

For environments without stdin/stdout connectivity, use:

./start-non-interactive.sh

This script:

  1. Creates named pipes for stdin and stdout
  2. Starts background processes to handle the pipes
  3. Starts the server with -Djsonrpc.stdio.interactive=false
  4. Sends an initialize request automatically
  5. Provides pipe paths for interaction

Interact with the server by writing to the input pipe and reading from the output pipe:

# Send a request
echo '{"jsonrpc":"2.0","method":"getTools","id":"1"}' > /path/to/input_pipe

# Read responses
cat /path/to/output_pipe

Running with Docker

When using Docker, you must use the -i flag for stdin connectivity:

docker run -i paypal-mcp-jsonrpc

Or use the provided script:

./run-docker.sh

Prerequisites

  • Java 17 or higher
  • Maven 3.6 or higher

Installation

Configuration

Configure the application in application.properties:

# Server configuration
server.port=8080

# Logging
logging.level.com.example.mcpserver=DEBUG

Building

Build the application:

mvn clean package

JSON-RPC Protocol

The server supports these JSON-RPC methods:

initialize

Initializes the server and returns its capabilities:

{"jsonrpc":"2.0","method":"initialize","id":"1"}

getTools

Returns a list of available tools:

{"jsonrpc":"2.0","method":"getTools","id":"2"}

executeFunction

Executes a function with specified arguments:

{"jsonrpc":"2.0","method":"executeFunction","params":{"function":"calculate","arguments":{"operation":"add","a":5,"b":3}},"id":"3"}

API Usage

REST API

Health Check

curl http://localhost:8080/api/v1/health

Completions Endpoint

curl -X POST http://localhost:8080/api/v1/completions \
  -H "Content-Type: application/json" \
  -d '{
    "query": "How can I improve my authorization rate?",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful PayPal assistant."
      },
      {
        "role": "user",
        "content": "I need to improve my authorization rate. My merchant ID is MERCH123."
      }
    ],
    "context": {
      "merchantId": "MERCH123"
    }
  }'

Authorization Rate Improvement Tool

curl -X POST http://localhost:8080/api/v1/tools/improveAuthorizationRate/execute \
  -H "Content-Type: application/json" \
  -d '{
    "merchantId": "MERCH123",
    "timeframe": "last_30_days",
    "transactionType": "card"
  }'

Calculator Tool

curl -X POST http://localhost:8080/api/v1/tools/calculate/execute \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "multiply",
    "a": 6,
    "b": 7
  }'

JSON-RPC over stdio

The JSON-RPC over stdio interface accepts requests on stdin and writes responses to stdout, each as a single line of JSON.

Completions Request

{"jsonrpc":"2.0","method":"completions","params":{"query":"How can I improve my authorization rate?","messages":[{"role":"system","content":"You are a helpful PayPal assistant."},{"role":"user","content":"I need to improve my authorization rate. My merchant ID is MERCH123."}],"context":{"merchantId":"MERCH123"}},"id":"1"}

Execute Function Request

{"jsonrpc":"2.0","method":"executeFunction","params":{"function":"improveAuthorizationRate","arguments":{"merchantId":"MERCH123","timeframe":"last_30_days","transactionType":"card"}},"id":"2"}
{"jsonrpc":"2.0","method":"executeFunction","params":{"function":"calculate","arguments":{"operation":"multiply","a":6,"b":7}},"id":"3"}

Available Tools

Authorization Rate Improvement Tool

Analyzes transaction data and provides recommendations to improve authorization rates.

Parameters:

  • merchantId (required): The merchant ID to analyze
  • timeframe (optional): The timeframe for analysis (default: "last_30_days")
  • transactionType (optional): Transaction type filter (default: "all")

Calculator Tool

Performs basic math operations.

Parameters:

  • operation (required): The operation to perform (add, subtract, multiply, divide)
  • a (required): First operand
  • b (required): Second operand

Docker Deployment

The project includes Docker support for both servers.

Building Docker Images

Build Both Images Using Docker Compose

docker-compose build

Build REST API Server Image Only

docker build --target rest-api -t paypal-mcp-rest-api .

Build JSON-RPC Server Image Only

docker build -f Dockerfile.smithery -t paypal-mcp-jsonrpc .

Running with Docker

Run REST API Server

docker run -p 8080:8080 paypal-mcp-rest-api

Run JSON-RPC Server

docker run -i paypal-mcp-jsonrpc

Troubleshooting

Common Issues

"The server's tool list is not accessible"

This typically happens when:

  1. You're trying to access the server via HTTP when it's running in stdio mode
  2. The server isn't running in interactive mode
  3. The -Djsonrpc.stdio.interactive=true flag is missing

Solution:

  • Use the JSON-RPC over stdio interface
  • Run with the -i flag if using Docker
  • Add the -Djsonrpc.stdio.interactive=true flag
  • Use start-non-interactive.sh script for non-interactive environments

"Server fails to initialize in a non-interactive environment"

If initialization fails in a non-interactive environment:

Solution:

./start-non-interactive.sh

"No response from server"

If the server doesn't respond:

Solution:

  • Run with test-stdio.sh to verify operation
  • Use start-non-interactive.sh and check the named pipes
  • Check the log file for any errors

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-java-mcp-server" '{"command":"java","args":["-Dspring.profiles.active=stdio","-Dspring.main.web-application-type=NONE","-Djsonrpc.stdio.interactive=true","-jar","target/paypal-java-mcp-server-0.0.1-SNAPSHOT-stdio.jar"]}'

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-java-mcp-server": {
            "command": "java",
            "args": [
                "-Dspring.profiles.active=stdio",
                "-Dspring.main.web-application-type=NONE",
                "-Djsonrpc.stdio.interactive=true",
                "-jar",
                "target/paypal-java-mcp-server-0.0.1-SNAPSHOT-stdio.jar"
            ]
        }
    }
}

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-java-mcp-server": {
            "command": "java",
            "args": [
                "-Dspring.profiles.active=stdio",
                "-Dspring.main.web-application-type=NONE",
                "-Djsonrpc.stdio.interactive=true",
                "-jar",
                "target/paypal-java-mcp-server-0.0.1-SNAPSHOT-stdio.jar"
            ]
        }
    }
}

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