withPayments() and the SDK handles authentication, charging, and error handling automatically.
Installation
- npm
- pnpm
- yarn
Requirements
- Node.js 18+
- @modelcontextprotocol/sdk - The MCP SDK (peer dependency)
- Provider API key - From your Payo dashboard
Quick Example
Exports
The SDK exports the following:Main Function
| Export | Description |
|---|---|
withPayments() | Wraps an MCP server with payment logic |
Types
| Export | Description |
|---|---|
PaymentConfig | Configuration options for withPayments() |
PricingConfig | Tool name → USD price mapping |
PaymentError | Error class for payment failures |
PaymentErrorCode | Enum of error codes |
LogLevel | Logging verbosity levels |
ErrorVerbosity | 'detailed' or 'concise' |
Utilities
| Export | Description |
|---|---|
PlatformClient | Direct access to Payo API (advanced) |
SessionManager | Token extraction utilities (advanced) |
TypeScript Support
The SDK is written in TypeScript with full type definitions:Architecture
The SDK:- Proxies your server to intercept handler registration
- Wraps tool handlers with payment logic
- Calls the Payo platform API for charges
- Executes your handler only after successful payment