Skip to main content
Glama
PK-SANGAMESWAR

Expense Tracker MCP Server

list_expenses

Retrieve expense records from the database within a specified date range to review spending history and track financial activity.

Instructions

List all expenses in the database between start_date and end_date (inclusive).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes

Implementation Reference

  • main.py:71-84 (handler)
    The `list_expenses` tool is registered using the `@mcp.tool()` decorator and implemented as a function that queries the SQLite database for records between `start_date` and `end_date`.
    @mcp.tool()
    def list_expenses(start_date, end_date):
        """List all expenses in the database between start_date and end_date (inclusive)."""
        try:
            with sqlite3.connect(DB_PATH) as conn:
                cursor = conn.cursor()
                cursor.execute(
                    "SELECT id, date, amount, category, subcategory, note FROM expenses WHERE date BETWEEN ? AND ? ORDER BY id ASC",
                    (start_date, end_date)
                )
                cols = [desc[0] for desc in cursor.description]
                return {"status": "ok", "expenses": [dict(zip(cols, row)) for row in cursor.fetchall()]}
        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