Skip to main content
Glama

get-payment-history

Retrieve payment records from the current session to track transaction history and monitor spending activity 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 that retrieves the payment history from the global paymentHistory array, applies an optional limit, computes totals, and returns formatted JSON 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 for optional 'limit' parameter.
    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 with McpServer, including title, description, input schema, and handler reference.
    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 }; } } );
  • Type definition for PaymentRecord used in paymentHistory.
    interface PaymentRecord { url: string; amount: number; recipient: string; timestamp: string; signature: string; }
  • Global state for storing payment history records and payment limit.
    let paymentHistory: PaymentRecord[] = []; let paymentLimit: number | null = null;

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