Skip to main content
Glama
SannketNikam

Demo MCP Server

by SannketNikam

add_expense

Record new expense entries in the database by specifying date, amount, and category. Use this tool to track spending and maintain financial records.

Instructions

Add a new expense entry to the database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
amountYes
categoryYes
subcategoryNo
noteNo

Implementation Reference

  • main.py:41-57 (handler)
    The handler function decorated with @mcp.tool() that implements the logic to insert a new expense into the SQLite database asynchronously using aiosqlite. It takes date, amount, category, optional subcategory and note, and returns success or error status.
    @mcp.tool() async def add_expense(date, amount, category, subcategory="", note=""): # Changed: added async '''Add a new expense entry to the database.''' try: async with aiosqlite.connect(DB_PATH) as c: # Changed: added async cur = await c.execute( # Changed: added await "INSERT INTO expenses(date, amount, category, subcategory, note) VALUES (?,?,?,?,?)", (date, amount, category, subcategory, note) ) expense_id = cur.lastrowid await c.commit() # Changed: added await return {"status": "success", "id": expense_id, "message": "Expense added successfully"} except Exception as e: # Changed: simplified exception handling if "readonly" in str(e).lower(): return {"status": "error", "message": "Database is in read-only mode. Check file permissions."} return {"status": "error", "message": f"Database error: {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