summarize
Generate expense summaries by date range and category to analyze spending patterns and track financial activity within the Expense Tracker MCP Server.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | Yes | ||
| end_date | Yes | ||
| category | No |
Implementation Reference
- main.py:61-80 (handler)The main handler function for the 'summarize' MCP tool. It is registered via the @mcp.tool() decorator. Computes summary of expenses by category between given dates, optionally filtered by a specific category.@mcp.tool() def summarize(start_date, end_date, category=""): with sqlite3.connect(DB_PATH) as c: query = """ select category, sum(amount) as total_amount from expenses where date between ? and ? """ params = [start_date, end_date] if category: query += " AND category=?" params.append(category) query += " group by category order by total_amount asc" cur = c.execute(query, params) cols = [d[0] for d in cur.description] return [dict(zip(cols, r)) for r in cur.fetchall()]