Skip to main content
Glama

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

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