edit_expense
Update existing expense records in the Expense Tracker database to correct errors, modify categories, adjust amounts, or add notes.
Instructions
Edit an existing expense in the database.
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": {
"id": "<id>",
"date": "<date>",
"amount": "<amount>",
"category": "<category>"
},
"name": "edit_expense"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| date | Yes | ||
| amount | Yes | ||
| category | Yes | ||
| subcategory | No | ||
| note | No |
Implementation Reference
- main.py:116-131 (handler)The edit_expense tool is defined and registered using the @mcp.tool() decorator, and contains the logic to update an existing expense entry in the SQLite database.
@mcp.tool() def edit_expense(id, date, amount, category, subcategory="", note=""): """Edit an existing expense in the database.""" try: with sqlite3.connect(DB_PATH) as conn: cursor = conn.cursor() cursor.execute(""" UPDATE expenses SET date = ?, amount = ?, category = ?, subcategory = ?, note = ? WHERE id = ? """, (date, float(amount), category, subcategory, note, id)) if cursor.rowcount == 0: return {"status": "error", "error": "No expense with that id"} return {"status": "ok"} except Exception as e: return {"status": "error", "error": str(e)}