spending_trends
Analyze monthly spending trends over a specified number of months to identify financial patterns and adjust budgets.
Instructions
Get spending trends. Get monthly spending trends for the specified number of months.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"months": "<months>"
},
"name": "spending_trends"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| months | Yes | Number of months to include |
Implementation Reference
- src/tools.js:281-286 (handler)Handler case for spending_trends tool in the handleTool switch statement. It calls client.getSpendingTrends with months argument (default 6) and formats the result via formatSpendingTrends.
case "spending_trends": { const result = await client.getSpendingTrends({ months: args.months || 6, }); return formatSpendingTrends(result.data.trends); } - src/tools.js:184-196 (schema)Tool definition and input schema for spending_trends. Defines name, description, and inputSchema with a 'months' numeric parameter (default 6).
{ name: "spending_trends", description: "Get monthly spending trends over time. Use this to answer 'How has my spending changed?' or 'Show me spending trends'", inputSchema: { type: "object", properties: { months: { type: "number", description: "Number of months to include (default 6)", }, }, }, }, - src/tools.js:409-421 (helper)formatSpendingTrends helper function that formats the trend data into a human-readable text output with a bar chart visualization.
function formatSpendingTrends(trends) { if (!trends?.length) return "No trend data found."; let text = `Monthly Spending Trends\n`; text += `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`; trends.forEach((t) => { const bar = "█".repeat(Math.min(20, Math.round(t.total / 100))); text += `${t.month}: ${formatCurrency(t.total)} ${bar}\n`; }); return text; } - src/index.js:308-310 (registration)Case handler for spending_trends in the formatResponse function within the OpenAPI-based MCP server (src/index.js). Formats trend data as month: currency lines.
case "spending_trends": if (!data.trends?.length) return "No trend data found."; return data.trends.map(t => `${t.month}: ${fmt(t.total)}`).join("\n"); - src/client.js:111-116 (registration)getSpendingTrends API client method that sends a GET request to /api/analytics/trends with optional 'months' query parameter.
async getSpendingTrends(params = {}) { const query = new URLSearchParams(); if (params.months) query.set("months", params.months); const qs = query.toString(); return request("GET", `/api/analytics/trends${qs ? `?${qs}` : ""}`); },