Skip to main content
Glama
Sudhanvaha

Expense Tracker MCP Server

by Sudhanvaha

update

Modify existing expense records by updating specific fields like amount, date, category, or notes while keeping other information unchanged.

Instructions

Update an expense.Only provided fields will be updated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYes
dateNo
amountNo
categoryNo
subcategoryNo
noteNo

Implementation Reference

  • main.py:81-129 (handler)
    The @mcp.tool() decorated 'update' function implements the MCP tool named 'update'. It conditionally updates fields (date, amount, category, subcategory, note) for an expense by ID in the SQLite database and returns the updated record or error.
    @mcp.tool() def update( cid: int, date: Optional[str] = None, amount: Optional[float] = None, category: Optional[str] = None, subcategory: Optional[str] = None, note: Optional[str] = None ) -> list[dict]: """Update an expense.Only provided fields will be updated.""" with sqlite3.connect(DB_PATH) as c: update_fields=[] params=[] if date is not None: update_fields.append("date=?") params.append(date) if amount is not None: update_fields.append("amount=?") params.append(amount) if category is not None: update_fields.append("category=?") params.append(category) if subcategory is not None: update_fields.append("subcategory=?") params.append(subcategory) if note is not None: update_fields.append("note=?") params.append(note) if not update_fields: return {"No fields provided to update"} params.append(cid) query=f"UPDATE expenses SET {', '.join(update_fields)} WHERE id=?" c.execute(query,params) c.commit() select_query="select * from expenses where id=?" cur=c.execute(select_query,[cid]) cols = [d[0] for d in cur.description] rows = cur.fetchall() if rows: return [dict(zip(cols, r)) for r in rows] else: return {"error": f"No expense found with id {cid}"}

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