Skip to main content
Glama
SannketNikam

Demo MCP Server

by SannketNikam

list_expenses

Retrieve expense entries for a specific date range to track spending patterns and manage budgets effectively.

Instructions

List expense entries within an inclusive date range.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes

Implementation Reference

  • main.py:58-75 (handler)
    The handler function for the 'list_expenses' tool, decorated with @mcp.tool() for registration in FastMCP. It asynchronously queries the SQLite database for expenses within the given date range and returns a list of expense dictionaries.
    @mcp.tool()
    async def list_expenses(start_date, end_date):  # Changed: added async
        '''List expense entries within an inclusive date range.'''
        try:
            async with aiosqlite.connect(DB_PATH) as c:  # Changed: added async
                cur = await c.execute(  # Changed: added await
                    """
                    SELECT id, date, amount, category, subcategory, note
                    FROM expenses
                    WHERE date BETWEEN ? AND ?
                    ORDER BY date DESC, id DESC
                    """,
                    (start_date, end_date)
                )
                cols = [d[0] for d in cur.description]
                return [dict(zip(cols, r)) for r in await cur.fetchall()]  # Changed: added await
        except Exception as e:
            return {"status": "error", "message": f"Error listing expenses: {str(e)}"}
Install Server

Other Tools

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/SannketNikam/test-remote-mcp-server'

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