Installation
Install the Payo SDK in your MCP server project:- npm
- pnpm
- yarn
Requirements
- Node.js 18+
@modelcontextprotocol/sdk(peer dependency)- A Payo provider API key
Basic Setup
ImportwithPayments and wrap your MCP server:
server.ts
How It Works
withPayments() returns your server with payment logic injected:
- Intercepts tool registration - Wraps your tool handlers
- Checks pricing on each call - Looks up the tool’s price
- Charges before execution - Calls Payo API for paid tools
- Executes your handler - Only after successful charge
Environment Variables
Set your API key as an environment variable:Production Deployment
Vercel
vercel.json
Railway
Add environment variable in your Railway dashboard under Variables.Docker
Dockerfile
TypeScript Support
The SDK is fully typed. Import types if needed:Verifying Setup
Test your integration:-
Start your server locally
-
Call a tool without a token
You should see a
TOKEN_MISSINGerror (expected behavior) -
Call with a valid agent token
Set
AGENT_TOKENin your test client. The tool should execute and you should see a charge in your dashboard.
Troubleshooting
'Cannot find module @payo/mcp'
'Cannot find module @payo/mcp'
Ensure you’ve installed the package:
'apiKey is required'
'apiKey is required'
The SDK requires an API key. Check:
PAYO_API_KEYenvironment variable is set- You’re reading it correctly:
process.env.PAYO_API_KEY
Charges not appearing in dashboard
Charges not appearing in dashboard
- 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