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.
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
.
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
For environments without stdin/stdout connectivity, use:
./start-non-interactive.sh
This script:
-Djsonrpc.stdio.interactive=false
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
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
Configure the application in application.properties
:
# Server configuration
server.port=8080
# Logging
logging.level.com.example.mcpserver=DEBUG
Build the application:
mvn clean package
The server supports these JSON-RPC methods:
Initializes the server and returns its capabilities:
{"jsonrpc":"2.0","method":"initialize","id":"1"}
Returns a list of available tools:
{"jsonrpc":"2.0","method":"getTools","id":"2"}
Executes a function with specified arguments:
{"jsonrpc":"2.0","method":"executeFunction","params":{"function":"calculate","arguments":{"operation":"add","a":5,"b":3}},"id":"3"}
curl http://localhost:8080/api/v1/health
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"
}
}'
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"
}'
curl -X POST http://localhost:8080/api/v1/tools/calculate/execute \
-H "Content-Type: application/json" \
-d '{
"operation": "multiply",
"a": 6,
"b": 7
}'
The JSON-RPC over stdio interface accepts requests on stdin and writes responses to stdout, each as a single line of JSON.
{"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"}
{"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"}
Analyzes transaction data and provides recommendations to improve authorization rates.
Parameters:
merchantId
(required): The merchant ID to analyzetimeframe
(optional): The timeframe for analysis (default: "last_30_days")transactionType
(optional): Transaction type filter (default: "all")Performs basic math operations.
Parameters:
operation
(required): The operation to perform (add, subtract, multiply, divide)a
(required): First operandb
(required): Second operandThe project includes Docker support for both servers.
docker-compose build
docker build --target rest-api -t paypal-mcp-rest-api .
docker build -f Dockerfile.smithery -t paypal-mcp-jsonrpc .
docker run -p 8080:8080 paypal-mcp-rest-api
docker run -i paypal-mcp-jsonrpc
This typically happens when:
-Djsonrpc.stdio.interactive=true
flag is missingSolution:
-i
flag if using Docker-Djsonrpc.stdio.interactive=true
flagstart-non-interactive.sh
script for non-interactive environmentsIf initialization fails in a non-interactive environment:
Solution:
./start-non-interactive.sh
If the server doesn't respond:
Solution:
test-stdio.sh
to verify operationstart-non-interactive.sh
and check the named pipesTo 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.
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-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"
]
}
}
}
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-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