Skip to main content
Glama
leafeye

lunchmoney-mcp

search-transactions

Search your Lunch Money transactions by keyword to find specific purchases or payments within a customizable date range.

Instructions

Search transactions by keyword

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYesSearch term to look for
daysNoNumber of days to look back
limitNoMaximum number of transactions to return

Implementation Reference

  • The handler function for the 'search-transactions' tool. It calculates the date range, fetches transactions from the Lunchmoney API, filters them by keyword in payee or notes, limits the results, and formats them for output.
    async ({ keyword, days, limit }) => {
        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.payee.toLowerCase().includes(keyword.toLowerCase()) ||
                (tx.notes && tx.notes.toLowerCase().includes(keyword.toLowerCase())),
        );
    
        return {
            content: [
                {
                    type: "text",
                    text: this.formatTransactions(matchingTransactions.slice(0, limit)),
                },
            ],
        };
    },
  • Zod input schema defining parameters for the 'search-transactions' tool: keyword (required string), days (default 90), limit (default 10).
    {
        keyword: z.string().describe("Search term to look for"),
        days: z.number().default(90).describe("Number of days to look back"),
        limit: z.number().default(10).describe("Maximum number of transactions to return"),
    },
  • src/index.ts:174-209 (registration)
    Registration of the 'search-transactions' tool on the MCP server, including name, description, input schema, and inline handler function.
    this.server.tool(
        "search-transactions",
        "Search transactions by keyword",
        {
            keyword: z.string().describe("Search term to look for"),
            days: z.number().default(90).describe("Number of days to look back"),
            limit: z.number().default(10).describe("Maximum number of transactions to return"),
        },
        async ({ keyword, days, limit }) => {
            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.payee.toLowerCase().includes(keyword.toLowerCase()) ||
                    (tx.notes && tx.notes.toLowerCase().includes(keyword.toLowerCase())),
            );
    
            return {
                content: [
                    {
                        type: "text",
                        text: this.formatTransactions(matchingTransactions.slice(0, limit)),
                    },
                ],
            };
        },
    );
  • Helper method used by search-transactions to fetch transactions from the Lunchmoney API given query parameters.
    private async fetchTransactions(params: Record<string, any>): Promise<Transaction[]> {
        const queryParams = new URLSearchParams();
        for (const [key, value] of Object.entries(params)) {
            queryParams.append(key, value.toString());
        }
    
        const response = await fetch(`${API_BASE}/transactions?${queryParams}`, {
            headers: {
                Authorization: `Bearer ${this.token}`,
                Accept: "application/json",
            }
        });
    
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
    
        const data = await response.json() as TransactionResponse;
        return data.transactions || [];
    }
  • Helper method used by search-transactions to format the list of matching transactions into a readable text string.
    private formatTransactions(transactions: Transaction[]): string {
        return transactions
            .map(tx => {
                let summary = [
                    `Date: ${tx.date}`,
                    `Amount: ${tx.amount} ${tx.currency.toUpperCase()}`,
                    `Payee: ${tx.payee}`,
                    `Category: ${tx.category_name} (${tx.category_group_name})`,
                    `Account: ${tx.account_display_name || "N/A"}`,
                    `Status: ${tx.status}`,
                ];
    
                if (tx.tags && tx.tags.length > 0) {
                    summary.push(`Tags: ${tx.tags.map((t: Tag) => t.name).join(", ")}`);
                }
    
                if (tx.notes) {
                    summary.push(`Notes: ${tx.notes}`);
                }
    
                return summary.join("\n");
            })
            .join("\n\n---\n\n");
    }
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. While 'search' implies a read operation, the description doesn't address important behavioral aspects like whether this requires authentication, what happens with no results, whether results are paginated, or any rate limits. For a search tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 extremely concise at just three words, with zero wasted language. It's front-loaded with the essential information (search transactions) and specifies the mechanism (by keyword) efficiently. Every word serves a clear purpose in this minimal description.

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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what constitutes a 'transaction' in this context, what fields are searched, the format of results, or how the search algorithm works. The agent would need to guess about the tool's behavior and output based on minimal information.

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 mentions searching 'by keyword' which aligns with one of the three parameters. However, with 100% schema description coverage, all parameters are already well-documented in the schema itself. The description adds minimal value beyond what's in the structured schema, meeting the baseline expectation when schema coverage is complete.

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 tool's purpose with a specific verb ('search') and resource ('transactions'), and specifies the search mechanism ('by keyword'). However, it doesn't differentiate this tool from its sibling 'get-recent-transactions' which also deals with transactions, leaving some ambiguity about when to use one versus the other.

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 the sibling tools (get-budget-summary, get-category-spending, get-recent-transactions) or explain when keyword searching is preferable to other transaction retrieval methods. The agent receives no contextual usage information.

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