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)}"}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is an 'Add' operation, implying a write/mutation, but doesn't cover critical aspects like required permissions, whether the operation is idempotent, error handling, or what happens on success (e.g., returns an ID). This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it efficient and easy to parse, which is ideal for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with 5 parameters, 0% schema coverage, no annotations, and no output schema, the description is insufficient. It doesn't explain parameter meanings, behavioral traits, or expected outcomes, leaving the agent poorly equipped to use this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, meaning none of the 5 parameters have descriptions in the schema. The tool description adds no information about what each parameter means (e.g., format of 'date', units for 'amount', allowed 'category' values), failing to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add a new expense entry') and the resource ('to the database'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'list_expenses' or 'summarize' beyond the basic verb difference, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_expenses' or 'summarize'. It lacks context about prerequisites, such as when an expense should be added versus when data should be listed or summarized, leaving the agent with minimal usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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