-32042 (Payment Required). wrapMcpClient() wraps a standard MCP Client to handle these payments automatically — detect the challenge, check budget, create credentials, and retry the call.
This is for outgoing payments to third-party MCP servers. It is separate from
@boltzpay/mcp, which is BoltzPay’s own MCP server that exposes tools to Claude Desktop.Setup
How It Works
- The wrapper calls the MCP server normally.
- If the server returns
-32042, the wrapper extracts the payment challenge. - Before creating credentials, the wrapper checks the configured budget limits.
- If budget allows, it signs the payment using the configured MPP wallet method.
- The call is retried with the payment credential attached.
- On success, spending is recorded and the receipt is returned.
Response Format
receipt is undefined.
Budget Enforcement
Budget checks happen before credential creation, not after. If the payment amount would exceed any configured limit, aBudgetExceededError is thrown and the MCP call fails without making a payment.
Events
MCP payments emit a dedicated event:transport: "mcp":
Requirements
- At least one MPP wallet must be configured (
tempoorstripe-mpp).wrapMcpClient()throwsConfigurationErrorif no MPP wallet is available. - The MCP client must implement
callTool()(standard@modelcontextprotocol/sdkClient). - Budget is optional but recommended for autonomous agents.
Security
- The wrapper filters
_metafields using an allowlist. Only the payment receipt key (org.paymentauth/receipt) is passed through. All other_metafields from the MCP server response are stripped. - Payment amounts are validated as non-negative integers before processing.
Next Steps
- Sessions — streaming payments via payment channels
- Budget & Safety — budget enforcement details
- Configuration — wallet setup