Skip to main content
Glama
PK-SANGAMESWAR

Expense Tracker MCP Server

add_expense

Add a new expense to the Expense Tracker MCP Server database by specifying date, amount, category, and optional details to record financial transactions.

Instructions

Add a new expense to the database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
amountYes
categoryYes
subcategoryNo
noteNo

Implementation Reference

  • main.py:55-67 (handler)
    The add_expense tool is defined with the @mcp.tool() decorator and uses sqlite3 to insert new entries into the expenses table.
    @mcp.tool()
    def add_expense(date, amount, category, subcategory="", note=""):
        """Add a new expense to the database."""
        try:
            with sqlite3.connect(DB_PATH) as conn:
                cursor = conn.cursor()
                cursor.execute("""
                INSERT INTO expenses (date, amount, category, subcategory, note)
                VALUES (?, ?, ?, ?, ?)
                """, (date, float(amount), category, subcategory, note))
                return {"status": "ok", "id": cursor.lastrowid}
        except Exception as e:
            return {"status": "error", "error": str(e)}

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/PK-SANGAMESWAR/mcp-expense-tracker'

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