Skip to main content

Installation

Install the Payo SDK in your MCP server project:

Requirements

  • Node.js 18+
  • @modelcontextprotocol/sdk (peer dependency)
  • A Payo provider API key

Basic Setup

Import withPayments and wrap your MCP server:
server.ts

How It Works

withPayments() returns your server with payment logic injected:
  1. Intercepts tool registration - Wraps your tool handlers
  2. Checks pricing on each call - Looks up the tool’s price
  3. Charges before execution - Calls Payo API for paid tools
  4. Executes your handler - Only after successful charge
Your tool code doesn’t change at all.

Environment Variables

Set your API key as an environment variable:
Never commit your API key to version control. Use environment variables or secrets management.

Production Deployment

Vercel

vercel.json
Add the secret via Vercel dashboard or CLI:

Railway

Add environment variable in your Railway dashboard under Variables.

Docker

Dockerfile
Pass at runtime:

TypeScript Support

The SDK is fully typed. Import types if needed:

Verifying Setup

Test your integration:
  1. Start your server locally
  2. Call a tool without a token You should see a TOKEN_MISSING error (expected behavior)
  3. Call with a valid agent token Set AGENT_TOKEN in your test client. The tool should execute and you should see a charge in your dashboard.

Troubleshooting

Ensure you’ve installed the package:
The SDK requires an API key. Check:
  • PAYO_API_KEY environment variable is set
  • You’re reading it correctly: process.env.PAYO_API_KEY
  • Verify the API key is a provider key (not agent)
  • Check you’re calling paid tools (not free ones)
  • Ensure the agent token is valid

Next Steps

Setting Prices

How to set and update prices

Configuration

All SDK options