Skip to main content
Glama

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
NameRequiredDescriptionDefault
limitYesMaximum payment amount in SOL (0 to remove limit)

Implementation Reference

  • 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 }; } }
  • 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 }; } } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Kishore-MK/ai42-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server