Skip to main content
Glama
leafeye

lunchmoney-mcp

get-category-spending

Analyze spending patterns for a specific category over a selected time period to track expenses and monitor budget performance.

Instructions

Get spending in a category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory name
daysNoNumber of days to look back

Implementation Reference

  • The async handler function for the 'get-category-spending' tool. It fetches transactions over the specified days, filters by category name (case-insensitive), aggregates total spending by currency, generates a text summary of totals, and lists up to 5 recent matching transactions.
    async ({ category, days }) => {
        const endDate = new Date().toISOString().split('T')[0];
        const startDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000)
            .toISOString()
            .split('T')[0];
    
        const transactions = await this.fetchTransactions({
            start_date: startDate,
            end_date: endDate,
            limit: 1000,
        });
    
        const matchingTransactions = transactions.filter(
            (tx: Transaction) => tx.category_name.toLowerCase() === category.toLowerCase(),
        );
    
        const totals = matchingTransactions.reduce((acc: Record<string, number>, tx: Transaction) => {
            const currency = tx.currency.toUpperCase();
            acc[currency] = (acc[currency] || 0) + Number(tx.amount);
            return acc;
        }, {});
    
        let summary = `Spending in '${category}' over the past ${days} days:\n\n`;
        Object.entries(totals).forEach(([currency, total]) => {
            summary += `${currency}: ${total.toFixed(2)}\n`;
        });
    
        if (matchingTransactions.length > 0) {
            summary += "\nRecent transactions in this category:\n";
            summary += this.formatTransactions(matchingTransactions.slice(0, 5));
        }
    
        return {
            content: [
                {
                    type: "text",
                    text: summary,
                },
            ],
        };
    },
  • Zod input schema defining parameters: 'category' (string) and 'days' (number, default 30).
    {
        category: z.string().describe("Category name"),
        days: z.number().default(30).describe("Number of days to look back"),
    },
  • src/index.ts:211-259 (registration)
    The full tool registration using McpServer.tool(), including name, description, input schema, and inline handler function.
    this.server.tool(
        "get-category-spending",
        "Get spending in a category",
        {
            category: z.string().describe("Category name"),
            days: z.number().default(30).describe("Number of days to look back"),
        },
        async ({ category, days }) => {
            const endDate = new Date().toISOString().split('T')[0];
            const startDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000)
                .toISOString()
                .split('T')[0];
    
            const transactions = await this.fetchTransactions({
                start_date: startDate,
                end_date: endDate,
                limit: 1000,
            });
    
            const matchingTransactions = transactions.filter(
                (tx: Transaction) => tx.category_name.toLowerCase() === category.toLowerCase(),
            );
    
            const totals = matchingTransactions.reduce((acc: Record<string, number>, tx: Transaction) => {
                const currency = tx.currency.toUpperCase();
                acc[currency] = (acc[currency] || 0) + Number(tx.amount);
                return acc;
            }, {});
    
            let summary = `Spending in '${category}' over the past ${days} days:\n\n`;
            Object.entries(totals).forEach(([currency, total]) => {
                summary += `${currency}: ${total.toFixed(2)}\n`;
            });
    
            if (matchingTransactions.length > 0) {
                summary += "\nRecent transactions in this category:\n";
                summary += this.formatTransactions(matchingTransactions.slice(0, 5));
            }
    
            return {
                content: [
                    {
                        type: "text",
                        text: summary,
                    },
                ],
            };
        },
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get spending' implies a read operation, but it doesn't specify if this requires authentication, has rate limits, returns historical or real-time data, or what format the spending data is in. This is a significant gap for a tool with no annotation coverage.

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, efficient sentence with zero waste. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 tool's complexity (a read operation with two parameters) and the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'spending' entails (e.g., total amount, list of transactions), how results are returned, or any behavioral traits, leaving the agent with insufficient context.

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

Parameters3/5

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

The description doesn't add any parameter semantics beyond what the schema provides. With 100% schema description coverage, the schema already documents 'category' as 'Category name' and 'days' as 'Number of days to look back' with a default of 30. The baseline score of 3 is appropriate since the schema does the heavy lifting.

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 'Get spending in a category' clearly states the verb 'Get' and resource 'spending in a category', making the purpose understandable. However, it doesn't distinguish this tool from siblings like 'get-budget-summary' or 'get-recent-transactions' which might also involve spending data, so it lacks sibling differentiation.

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. It doesn't mention siblings like 'search-transactions' for broader queries or 'get-budget-summary' for aggregated data, leaving the agent without context for tool selection.

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/leafeye/lunchmoney-mcp-server'

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