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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of records to return (default: all) |
Implementation Reference
- src/index.ts:84-107 (handler)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 }; } }
- src/index.ts:80-82 (schema)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 }; } } );
- src/index.ts:20-21 (helper)Global mutable state: paymentHistory array storing PaymentRecord objects, and paymentLimit used by the tool.let paymentHistory: PaymentRecord[] = []; let paymentLimit: number | null = null;
- src/index.ts:12-18 (helper)TypeScript interface PaymentRecord defining structure of payment records stored in history.interface PaymentRecord { url: string; amount: number; recipient: string; timestamp: string; signature: string; }