set-payment-limit
Configure maximum spending per request in SOL for the X402 Payment Server. Set a specific limit or use 0 to disable payment restrictions.
Instructions
Set maximum amount willing to pay per request (in SOL). Set to 0 to remove limit.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | Yes | Maximum payment amount in SOL (0 to remove limit) |
Implementation Reference
- src/index.ts:120-148 (handler)Handler function that validates the input limit, updates the global paymentLimit variable, and returns a success message with the current limit or an error.async ({ limit }) => { try { if (limit < 0) { throw new Error("Limit must be non-negative"); } paymentLimit = limit === 0 ? null : limit; return { content: [{ type: "text", text: JSON.stringify({ message: paymentLimit === null ? "Payment limit removed" : `Payment limit set to ${paymentLimit} SOL`, current_limit: paymentLimit }, null, 2) }] }; } catch (err: any) { return { content: [{ type: "text", text: `Error: ${err.message || "Failed to set payment limit"}` }], isError: true }; } }
- src/index.ts:116-118 (schema)Input schema for the tool defining the 'limit' parameter as a number with description.inputSchema: { limit: z.number().describe("Maximum payment amount in SOL (0 to remove limit)") },
- src/index.ts:111-149 (registration)Registration of the 'set-payment-limit' tool using server.registerTool, including title, description, schema, and handler.server.registerTool( "set-payment-limit", { title: "Set Payment Limit", description: "Set maximum amount willing to pay per request (in SOL). Set to 0 to remove limit.", inputSchema: { limit: z.number().describe("Maximum payment amount in SOL (0 to remove limit)") }, }, async ({ limit }) => { try { if (limit < 0) { throw new Error("Limit must be non-negative"); } paymentLimit = limit === 0 ? null : limit; return { content: [{ type: "text", text: JSON.stringify({ message: paymentLimit === null ? "Payment limit removed" : `Payment limit set to ${paymentLimit} SOL`, current_limit: paymentLimit }, null, 2) }] }; } catch (err: any) { return { content: [{ type: "text", text: `Error: ${err.message || "Failed to set payment limit"}` }], isError: true }; } } );