Skip to main content
Glama
leafeye

lunchmoney-mcp

get-budget-summary

Retrieve budget summaries for specific time periods to track spending patterns and monitor financial goals using your Lunchmoney data.

Instructions

Get budget summary for a specific time period

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYesStart date (YYYY-MM-DD, should be start of month)
end_dateYesEnd date (YYYY-MM-DD, should be end of month)

Implementation Reference

  • src/index.ts:101-142 (registration)
    Registration of the 'get-budget-summary' tool, including input schema with Zod validation for dates and the inline asynchronous handler that fetches budgets and returns a formatted text summary or error.
    this.server.tool(
        "get-budget-summary",
        "Get budget summary for a specific time period",
        {
            start_date: z.string().describe("Start date (YYYY-MM-DD, should be start of month)"),
            end_date: z.string().describe("End date (YYYY-MM-DD, should be end of month)"),
        },
        async ({ start_date, end_date }) => {
            try {
                const budgets = await this.fetchBudgets(start_date, end_date);
                
                if (!budgets.length) {
                    return {
                        content: [
                            {
                                type: "text",
                                text: "No budget data found for the specified period.",
                            },
                        ],
                    };
                }
    
                return {
                    content: [
                        {
                            type: "text",
                            text: this.formatBudgetSummary(budgets),
                        },
                    ],
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `Error fetching budget data: ${error}`,
                        },
                    ],
                };
            }
        }
    );
  • Helper function 'fetchBudgets' that makes an API call to retrieve budget data for the specified date range from Lunchmoney API.
    private async fetchBudgets(start_date: string, end_date: string): Promise<Budget[]> {
        const response = await fetch(`${API_BASE}/budgets?start_date=${start_date}&end_date=${end_date}`, {
            headers: {
                Authorization: `Bearer ${this.token}`,
                Accept: "application/json",
            }
        });
    
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
    
        return await response.json() as Budget[];
    }
  • Helper function 'formatBudgetSummary' that processes the budget data into a detailed text summary including category info, monthly spending vs budget, remaining amounts, and recurring expenses.
    private formatBudgetSummary(budgets: Budget[]): string {
        let summary: string[] = [];
    
        for (const budget of budgets) {
            const categoryHeader = `Category: ${budget.category_name}${budget.category_group_name ? ` (${budget.category_group_name})` : ''}`;
            let budgetInfo: string[] = [categoryHeader];
    
            // Add monthly data
            Object.entries(budget.data).forEach(([date, data]) => {
                const monthData = [
                    `\nMonth: ${date}`,
                    `Transactions: ${data.num_transactions || 0}`,
                    `Spending: ${data.spending_to_base?.toFixed(2) || '0.00'} ${data.budget_currency?.toUpperCase() || 'USD'}`,
                ];
    
                if (data.budget_amount) {
                    monthData.push(`Budget: ${data.budget_amount.toFixed(2)} ${data.budget_currency?.toUpperCase() || 'USD'}`);
                    const remainingBudget = (data.budget_amount - (data.spending_to_base || 0)).toFixed(2);
                    monthData.push(`Remaining: ${remainingBudget} ${data.budget_currency?.toUpperCase() || 'USD'}`);
                }
    
                budgetInfo.push(monthData.join('\n'));
            });
    
            // Add recurring items if any
            if (budget.recurring && budget.recurring.list && budget.recurring.list.length > 0) {
                budgetInfo.push('\nRecurring Items:');
                budget.recurring.list.forEach(item => {
                    budgetInfo.push(`- ${item.payee}: ${item.amount} ${item.currency.toUpperCase()}`);
                });
            }
    
            summary.push(budgetInfo.join('\n'));
        }
    
        return summary.join('\n\n---\n\n');
    }
  • Type definition for BudgetParams matching the tool's input parameters.
    interface BudgetParams {
        start_date: string;
        end_date: string;
    }
  • Type definition for Budget, describing the structure of budget data returned by the API.
    interface Budget {
        category_name: string;
        category_id: number;
        category_group_name: string | null;
        group_id: number | null;
        is_group: boolean | null;
        is_income: boolean;
        exclude_from_budget: boolean;
        exclude_from_totals: boolean;
        data: Record<string, BudgetData>;
        config: BudgetConfig | null;
        order: number;
        archived: boolean;
        recurring: Recurring | null;
    }
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 the tool retrieves a 'budget summary' but doesn't explain what that summary includes (e.g., categories, totals, trends), whether it's read-only (implied but not explicit), or any limitations like rate limits or authentication needs. This leaves significant gaps for an agent to understand the tool's behavior.

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 that directly states the tool's purpose without unnecessary words. 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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the 'budget summary' output contains, how it's structured, or any behavioral traits like error handling. For a tool with two parameters and no structured output documentation, this leaves the agent with insufficient context to use it effectively.

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 schema description coverage is 100%, with both parameters ('start_date' and 'end_date') fully documented in the schema. The description adds minimal value by mentioning 'time period,' which aligns with the schema but doesn't provide additional context like format examples or edge cases beyond what's already specified.

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 ('Get') and resource ('budget summary') with a specific scope ('for a specific time period'), which makes the purpose understandable. However, it doesn't differentiate this tool from its siblings like 'get-category-spending' or 'get-recent-transactions', which likely provide related but different budget/transaction data.

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 sibling tools like 'get-category-spending' or 'get-recent-transactions', nor does it specify prerequisites, exclusions, or appropriate contexts for usage beyond the time period requirement.

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