get_all_expenses
Retrieve a complete list of all recorded expenses from the Expense Tracker database to review spending history and track financial data.
Instructions
Get all expenses
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_all_expenses"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- main.py:70-76 (handler)This is the handler function for the 'get_all_expenses' tool. It is decorated with @mcp.tool, which registers it with the FastMCP server. The function initializes the database connection if necessary, executes a SQL query to select all expenses ordered by date descending, and returns them as a list of dictionaries.
@mcp.tool async def get_all_expenses() -> List[Dict]: """Get all expenses""" await init_db() cursor = conn.cursor() cursor.execute('SELECT * FROM expenses ORDER BY date DESC') return [dict(row) for row in cursor.fetchall()]