Skip to main content
Glama
PK-SANGAMESWAR

Expense Tracker MCP Server

summarize

Summarize expenses by category within a specified date range to analyze spending patterns and track financial data from the Expense Tracker MCP Server.

Instructions

Summarize expenses by category within the inclusive date range. Returns list of {"category": ..., "total": ...} ordered by total descending.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes
categoryNo

Implementation Reference

  • main.py:88-110 (handler)
    The implementation of the 'summarize' MCP tool which queries a SQLite database to aggregate expenses by category.
    @mcp.tool()
    def summarize(start_date, end_date, category=None):
        """
        Summarize expenses by category within the inclusive date range.
        Returns list of {"category": ..., "total": ...} ordered by total descending.
        """
        try:
            with sqlite3.connect(DB_PATH) as conn:
                params = [start_date, end_date]
                query = """
                    SELECT category, SUM(amount) as total
                    FROM expenses
                    WHERE date BETWEEN ? AND ?
                """
                if category:
                    query += " AND category = ?"
                    params.append(category)
    
                query += " GROUP BY category ORDER BY total DESC"
                cursor = conn.cursor()
                cursor.execute(query, params)
                cols = [desc[0] for desc in cursor.description]
                return {"status": "ok", "summary": [dict(zip(cols, row)) for row in cursor.fetchall()]}

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