Skip to main content
Glama
Kishore-MK

AI42-MCP X402 Payment Server

by Kishore-MK

Get Payment History

get-payment-history

Retrieve payment records from the current session to track transactions and monitor spending with configurable limits.

Instructions

View all payments made during this session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of records to return (default: all)

Implementation Reference

  • The handler function for get-payment-history tool. Retrieves payment history records, applies optional limit, computes totals, and returns formatted JSON response or error.
    async ({ limit }) => {
      try {
        const records = limit ? paymentHistory.slice(-limit) : paymentHistory;
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              total_payments: paymentHistory.length,
              records: records,
              total_spent: paymentHistory.reduce((sum, r) => sum + r.amount, 0)
            }, null, 2)
          }]
        };
      } catch (err: any) {
        return {
          content: [{
            type: "text",
            text: `Error: ${err.message || "Failed to get payment history"}`
          }],
          isError: true
        };
      }
    }
  • Input schema using Zod: optional 'limit' parameter as number, described as maximum records to return.
    inputSchema: {
      limit: z.number().optional().describe("Maximum number of records to return (default: all)")
    },
  • src/index.ts:75-108 (registration)
    Registration of the 'get-payment-history' tool via server.registerTool, including title, description, inputSchema, and inline handler.
    server.registerTool(
      "get-payment-history",
      {
        title: "Get Payment History",
        description: "View all payments made during this session",
        inputSchema: {
          limit: z.number().optional().describe("Maximum number of records to return (default: all)")
        },
      },
      async ({ limit }) => {
        try {
          const records = limit ? paymentHistory.slice(-limit) : paymentHistory;
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                total_payments: paymentHistory.length,
                records: records,
                total_spent: paymentHistory.reduce((sum, r) => sum + r.amount, 0)
              }, null, 2)
            }]
          };
        } catch (err: any) {
          return {
            content: [{
              type: "text",
              text: `Error: ${err.message || "Failed to get payment history"}`
            }],
            isError: true
          };
        }
      }
    );
  • Global mutable state: paymentHistory array storing PaymentRecord objects, and paymentLimit used by the tool.
    let paymentHistory: PaymentRecord[] = [];
    let paymentLimit: number | null = null;
  • TypeScript interface PaymentRecord defining structure of payment records stored in history.
    interface PaymentRecord {
      url: string;
      amount: number;
      recipient: string;
      timestamp: string;
      signature: string;
    }
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 states 'view all payments made during this session', which implies a read-only operation, but doesn't disclose other traits such as authentication needs, rate limits, error handling, or what 'session' entails. This leaves significant gaps in understanding the tool's behavior beyond basic purpose.

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

Conciseness4/5

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

The description is a single, clear sentence that efficiently states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to parse, though it could be slightly more structured by including usage context or parameter hints.

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

Completeness2/5

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

Given the tool's moderate complexity (a read operation with one parameter) and no annotations or output schema, the description is incomplete. It lacks details on behavioral traits, usage guidelines, and return values, which are crucial for an agent to invoke it correctly. The description alone is insufficient for full contextual understanding.

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?

The input schema has 100% description coverage, with the 'limit' parameter fully documented in the schema. The description adds no additional meaning beyond what the schema provides, as it doesn't mention parameters at all. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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

Purpose3/5

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

The description 'View all payments made during this session' clearly states the tool's purpose with a specific verb ('view') and resource ('payments'), but it doesn't differentiate from sibling tools like 'fetch-with-payment' or 'get-balance'. The scope 'during this session' provides some specificity, but the purpose remains somewhat vague regarding what distinguishes it from similar tools.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'fetch-with-payment' or 'get-balance'. It implies usage for viewing payments in the current session, but lacks explicit when/when-not instructions or named alternatives, leaving the agent to infer context without clear direction.

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