Skip to main content
Glama
Sudhanvaha

Expense Tracker MCP Server

by Sudhanvaha

delete

Remove expenses from the Expense Tracker MCP Server by specifying criteria such as ID, date, category, amount, or notes to manage your financial records.

Instructions

Delete expenses based on any column criteria. like id,date,category,subcategory,amount,note,start_date,end_date

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo
dateNo
categoryNo
subcategoryNo
amountNo
noteNo
start_dateNo
end_dateNo

Implementation Reference

  • main.py:130-222 (handler)
    The main handler function for the 'delete' tool. It constructs a DELETE SQL query based on optional filter parameters (id, date, category, etc., or date range), executes it on the expenses table, commits the change, and returns a success/warning response with the count of deleted rows.
    @mcp.tool() def delete( id: Optional[int] = None, date: Optional[str] = None, category: Optional[str] = None, subcategory: Optional[str] = None, amount: Optional[float] = None, note: Optional[str] = None, start_date: Optional[str] = None, end_date: Optional[str] = None ) -> dict: """ Delete expenses based on any column criteria. like id,date,category,subcategory,amount,note,start_date,end_date """ with sqlite3.connect(DB_PATH) as c: conditions = [] params = [] # Handle date range separately if start_date is not None and end_date is not None: conditions.append("date BETWEEN ? AND ?") params.extend([start_date, end_date]) elif start_date is not None or end_date is not None: return { "status": "error", "message": "Both start_date and end_date must be provided for date range" } # Handle individual column filters if id is not None: conditions.append("id = ?") params.append(id) if date is not None: conditions.append("date = ?") params.append(date) if category is not None: conditions.append("category = ?") params.append(category) if subcategory is not None: conditions.append("subcategory = ?") params.append(subcategory) if amount is not None: conditions.append("amount = ?") params.append(amount) if note is not None: conditions.append("note = ?") params.append(note) if not conditions: return { "status": "error", "message": "At least one filter parameter must be provided" } query = "DELETE FROM expenses WHERE " + " AND ".join(conditions) cur = c.execute(query, params) c.commit() deleted_count = cur.rowcount if deleted_count > 0: return { "status": "success", "message": f"Successfully deleted {deleted_count} expense(s)", "deleted_count": deleted_count, "criteria": {k: v for k, v in { "id": id, "date": date, "category": category, "subcategory": subcategory, "amount": amount, "note": note, "start_date": start_date, "end_date": end_date }.items() if v is not None} } else: return { "status": "warning", "message": "No expenses found matching the criteria", "deleted_count": 0 }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Sudhanvaha/expense-tracker-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server