Skip to main content
Glama
naveen6768

Expense Tracker MCP

by naveen6768

list_expenses

Filter and retrieve your expense records by category and date range.

Instructions

List expenses with optional category and date filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNo
start_dateNo
end_dateNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:200-214 (handler)
    The `list_expenses` tool handler function, decorated with @mcp.tool. It loads expenses from storage, optionally filters by category/date range, and returns sorted results.
    @mcp.tool
    def list_expenses(
        category: str | None = None,
        start_date: str | None = None,
        end_date: str | None = None,
    ) -> list[Expense]:
        """List expenses with optional category and date filters."""
        expenses = _load_expenses()
        filtered = _filter_expenses(
            expenses,
            category=category,
            start_date=start_date,
            end_date=end_date,
        )
        return sorted(filtered, key=lambda item: (item.expense_date, item.created_at))
  • main.py:18-24 (schema)
    The Expense pydantic model used as the return type of list_expenses.
    class Expense(BaseModel):
        id: str
        amount: str
        category: str
        description: str
        expense_date: str
        created_at: str
  • main.py:200-214 (registration)
    Registration is implicit via the @mcp.tool decorator on the list_expenses function (line 200), using FastMCP.
    @mcp.tool
    def list_expenses(
        category: str | None = None,
        start_date: str | None = None,
        end_date: str | None = None,
    ) -> list[Expense]:
        """List expenses with optional category and date filters."""
        expenses = _load_expenses()
        filtered = _filter_expenses(
            expenses,
            category=category,
            start_date=start_date,
            end_date=end_date,
        )
        return sorted(filtered, key=lambda item: (item.expense_date, item.created_at))
  • The _filter_expenses helper used by list_expenses to apply category and date filters.
    def _filter_expenses(
        expenses: list[Expense],
        category: str | None = None,
        start_date: str | None = None,
        end_date: str | None = None,
    ) -> list[Expense]:
        normalized_category = category.strip().lower() if category else None
        parsed_start = date.fromisoformat(start_date) if start_date else None
        parsed_end = date.fromisoformat(end_date) if end_date else None
    
        if parsed_start and parsed_end and parsed_start > parsed_end:
            raise ValueError("start_date cannot be after end_date.")
    
        filtered: list[Expense] = []
        for expense in expenses:
            expense_day = date.fromisoformat(expense.expense_date)
    
            if normalized_category and expense.category.lower() != normalized_category:
                continue
            if parsed_start and expense_day < parsed_start:
                continue
            if parsed_end and expense_day > parsed_end:
                continue
    
            filtered.append(expense)
    
        return filtered
  • main.py:59-69 (helper)
    The _load_expenses helper used by list_expenses to read expenses from the JSON data file.
    def _load_expenses() -> list[Expense]:
        if not DATA_FILE.exists():
            return []
    
        with DATA_FILE.open("r", encoding="utf-8") as file:
            data = json.load(file)
    
        if not isinstance(data, list):
            raise ValueError("Expense store is invalid. Expected a list of expenses.")
    
        return [Expense.model_validate(item) for item in data]
Behavior2/5

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

No annotations are provided. The description does not disclose behavior such as pagination, sorting, or output format. Despite an output schema existing, the description lacks any behavioral context.

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

Conciseness4/5

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

The description is a single concise sentence that front-loads the core purpose. However, it may be too brief and could benefit from slightly more detail.

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

Completeness3/5

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

Given the existence of an output schema, the description is minimally complete for a simple list tool. However, it lacks context on usage and behavior, making it adequate but not comprehensive.

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

Parameters2/5

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

Schema description coverage is 0%. The description loosely mentions 'category and date filters' corresponding to the parameters, but adds no semantic detail like date format or allowed values.

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

Purpose5/5

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

The description clearly states the action ('List expenses') and the resource, and mentions optional filters. It distinguishes from siblings like add_expense, delete_expense, and get_expense_summary.

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

Usage Guidelines3/5

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

The description implies use for listing with filters, but does not provide explicit guidance on when to use this tool versus alternatives like get_expense_summary, or when not to use it.

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/naveen6768/MCP'

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