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
| 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 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 }; } }
- src/index.ts:80-82 (schema)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 }; } } );
- src/index.ts:12-18 (helper)Type definition for PaymentRecord used in paymentHistory.interface PaymentRecord { url: string; amount: number; recipient: string; timestamp: string; signature: string; }
- src/index.ts:20-21 (helper)Global state for storing payment history records and payment limit.let paymentHistory: PaymentRecord[] = []; let paymentLimit: number | null = null;