Skip to main content
Glama
Kishore-MK

AI42-MCP X402 Payment Server

by Kishore-MK

Set Payment Limit

set-payment-limit

Configure maximum spending per request in SOL for the X402 Payment Server. Set a limit to control costs or use 0 to remove 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 sets the global paymentLimit based on input, validates non-negative, and returns confirmation or 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 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)
    Registers the 'set-payment-limit' tool with MCP server, including title, description, input schema, and handler reference.
    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
          };
        }
      }
    );
  • Global variable used to store the current payment limit by the handler.
    let paymentLimit: number | null = null;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the action ('Set') and effect ('remove limit'), but lacks details on permissions required, whether changes are reversible, rate limits, or what happens if the limit is exceeded. This is a significant gap for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with two sentences that are front-loaded and waste no words. Every sentence earns its place by clearly stating the tool's purpose and usage rule.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (mutation with no annotations and no output schema), the description is adequate but incomplete. It covers the basic purpose and parameter usage, but lacks behavioral context like error handling or response format, leaving gaps for an agent to operate effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the 'limit' parameter fully. The description adds minimal value by restating the parameter's purpose and the special case of 0, but does not provide additional syntax or format details beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Set maximum amount willing to pay per request') and resource ('payment limit'), with explicit mention of the currency (SOL). It distinguishes from sibling tools like 'get-balance' or 'get-payment-history' by focusing on configuration rather than retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for usage ('Set to 0 to remove limit'), indicating when to use this specific value. However, it does not explicitly mention when to use this tool versus alternatives like 'fetch-with-payment' or any prerequisites, which prevents a perfect score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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