add_expense
Add new expenses to your personal expense tracker by specifying date, amount, and category. This tool helps you record spending details with optional subcategory and note fields for better financial management.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | ||
| amount | Yes | ||
| category | Yes | ||
| subcategory | No | ||
| note | No |
Implementation Reference
- main.py:39-46 (handler)The implementation of the 'add_expense' tool. This function is decorated with @mcp.tool(), which registers it as an MCP tool and defines its handler logic. It inserts a new expense record into the SQLite database table 'expenses' and returns the status and generated ID.@mcp.tool() def add_expense(date, amount, category, subcategory="", note=""): with sqlite3.connect(DB_PATH) as c: cur = c.execute( "INSERT INTO expenses(date, amount, category, subcategory, note) VALUES (?, ?, ?, ?, ?)", (date, amount, category, subcategory, note) ) return {"status": "ok", "id": cur.lastrowid}