delete_expense
Remove an expense entry from the Expense Tracker database by specifying its unique identifier to maintain accurate financial records.
Instructions
Delete an expense from the database.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- main.py:135-146 (handler)The handler function 'delete_expense' is registered as an MCP tool and performs a SQL DELETE operation on the expenses table.
@mcp.tool() def delete_expense(id): """Delete an expense from the database.""" try: with sqlite3.connect(DB_PATH) as conn: cursor = conn.cursor() cursor.execute("DELETE FROM expenses WHERE id = ?", (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)}