Skip to main content
Glama
akutishevsky

LunchMoney MCP Server

get_recurring_items

Retrieve recurring financial items for a specified month to help forecast expected income and expenses.

Instructions

Retrieve a list of recurring items to expect for a specified month

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYes

Implementation Reference

  • The handler function that fetches recurring items from the Lunchmoney API using the provided parameters.
    async ({ input }) => {
        const { baseUrl, lunchmoneyApiToken } = getConfig();
        
        const params = new URLSearchParams();
        if (input.start_date) params.append("start_date", input.start_date);
        if (input.end_date) params.append("end_date", input.end_date);
        if (input.debit_as_negative !== undefined) {
            params.append("debit_as_negative", input.debit_as_negative.toString());
        }
        
        const url = params.toString() 
            ? `${baseUrl}/recurring_items?${params}`
            : `${baseUrl}/recurring_items`;
            
        const response = await fetch(url, {
            headers: {
                Authorization: `Bearer ${lunchmoneyApiToken}`,
            },
        });
    
        if (!response.ok) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Failed to get recurring items: ${response.statusText}`,
                    },
                ],
            };
        }
    
        const recurringItems: RecurringItem[] = await response.json();
        
        return {
            content: [
                {
                    type: "text",
                    text: JSON.stringify(recurringItems),
                },
            ],
        };
    }
  • Zod schema defining the input parameters for the get_recurring_items tool.
    input: z.object({
        start_date: z
            .string()
            .optional()
            .describe("Start date in YYYY-MM-DD format. Defaults to first day of current month"),
        end_date: z
            .string()
            .optional()
            .describe("End date in YYYY-MM-DD format"),
        debit_as_negative: z
            .boolean()
            .optional()
            .describe("Pass true to return debit amounts as negative"),
    }),
  • The registration function that calls server.tool() to register the get_recurring_items tool.
    export function registerRecurringItemsTools(server: McpServer) {
        server.tool(
            "get_recurring_items",
            "Retrieve a list of recurring items to expect for a specified month",
            {
                input: z.object({
                    start_date: z
                        .string()
                        .optional()
                        .describe("Start date in YYYY-MM-DD format. Defaults to first day of current month"),
                    end_date: z
                        .string()
                        .optional()
                        .describe("End date in YYYY-MM-DD format"),
                    debit_as_negative: z
                        .boolean()
                        .optional()
                        .describe("Pass true to return debit amounts as negative"),
                }),
            },
            async ({ input }) => {
                const { baseUrl, lunchmoneyApiToken } = getConfig();
                
                const params = new URLSearchParams();
                if (input.start_date) params.append("start_date", input.start_date);
                if (input.end_date) params.append("end_date", input.end_date);
                if (input.debit_as_negative !== undefined) {
                    params.append("debit_as_negative", input.debit_as_negative.toString());
                }
                
                const url = params.toString() 
                    ? `${baseUrl}/recurring_items?${params}`
                    : `${baseUrl}/recurring_items`;
                    
                const response = await fetch(url, {
                    headers: {
                        Authorization: `Bearer ${lunchmoneyApiToken}`,
                    },
                });
    
                if (!response.ok) {
                    return {
                        content: [
                            {
                                type: "text",
                                text: `Failed to get recurring items: ${response.statusText}`,
                            },
                        ],
                    };
                }
    
                const recurringItems: RecurringItem[] = await response.json();
                
                return {
                    content: [
                        {
                            type: "text",
                            text: JSON.stringify(recurringItems),
                        },
                    ],
                };
            }
        );
    }
  • src/index.ts:27-27 (registration)
    Top-level call to register the recurring items tools on the MCP server.
    registerRecurringItemsTools(server);

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

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