list_expenses
Retrieve expense records from the database within a specified date range to review spending history and track financial activity.
Instructions
List all expenses in the database between start_date and end_date (inclusive).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | Yes | ||
| end_date | Yes |
Implementation Reference
- main.py:71-84 (handler)The `list_expenses` tool is registered using the `@mcp.tool()` decorator and implemented as a function that queries the SQLite database for records between `start_date` and `end_date`.
@mcp.tool() def list_expenses(start_date, end_date): """List all expenses in the database between start_date and end_date (inclusive).""" try: with sqlite3.connect(DB_PATH) as conn: cursor = conn.cursor() cursor.execute( "SELECT id, date, amount, category, subcategory, note FROM expenses WHERE date BETWEEN ? AND ? ORDER BY id ASC", (start_date, end_date) ) cols = [desc[0] for desc in cursor.description] return {"status": "ok", "expenses": [dict(zip(cols, row)) for row in cursor.fetchall()]} except Exception as e: return {"status": "error", "error": str(e)}