Skip to main content
Glama
akutishevsky

LunchMoney MCP Server

upsert_budget

Idempotent

Create or update a budget for a specific category and budget period. Requires a valid start date from budget settings.

Instructions

Create or update a budget for a category and budget period. The start_date must be a valid budget period start for the account (see get_budget_settings).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYesBudget period start date in YYYY-MM-DD format. Must be a valid budget period start; if not, the API returns the previous and next valid start dates.
category_idYesCategory ID for the budget.
amountYesBudget amount.
currencyNoThree-letter lowercase currency code (defaults to primary currency).
notesNoOptional notes for the budget period.

Implementation Reference

  • The async handler function for the 'upsert_budget' tool. It takes start_date, category_id, amount, optional currency and notes, then sends a PUT request to /budgets and returns the API response.
    async ({ start_date, category_id, amount, currency, notes }) => {
        try {
            const body: Record<string, unknown> = {
                start_date,
                category_id,
                amount,
            };
    
            if (currency) body.currency = currency;
            if (notes !== undefined) body.notes = notes;
    
            const response = await api.put("/budgets", body);
    
            if (!response.ok) {
                return handleApiError(response, "Failed to upsert budget");
            }
    
            return dataResponse(await response.json());
        } catch (error) {
            return catchError(error, "Failed to upsert budget");
        }
    },
  • Input schema for upsert_budget using Zod validations: start_date (regex YYYY-MM-DD), category_id (coerced number), amount (coerced number), optional currency (3-letter), optional notes (max 350 chars).
    description:
        "Create or update a budget for a category and budget period. The start_date must be a valid budget period start for the account (see get_budget_settings).",
    inputSchema: {
        start_date: z
            .string()
            .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
            .describe(
                "Budget period start date in YYYY-MM-DD format. Must be a valid budget period start; if not, the API returns the previous and next valid start dates.",
            ),
        category_id: z.coerce
            .number()
            .describe("Category ID for the budget."),
        amount: z.coerce.number().describe("Budget amount."),
        currency: z
            .string()
            .length(3)
            .optional()
            .describe(
                "Three-letter lowercase currency code (defaults to primary currency).",
            ),
        notes: z
            .string()
            .max(350)
            .optional()
            .describe("Optional notes for the budget period."),
    },
  • Registration of the 'upsert_budget' tool on the MCP server via server.registerTool(), including description, inputSchema, annotations (idempotentHint: true), and the handler function.
    server.registerTool(
        "upsert_budget",
        {
            description:
                "Create or update a budget for a category and budget period. The start_date must be a valid budget period start for the account (see get_budget_settings).",
            inputSchema: {
                start_date: z
                    .string()
                    .regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD format")
                    .describe(
                        "Budget period start date in YYYY-MM-DD format. Must be a valid budget period start; if not, the API returns the previous and next valid start dates.",
                    ),
                category_id: z.coerce
                    .number()
                    .describe("Category ID for the budget."),
                amount: z.coerce.number().describe("Budget amount."),
                currency: z
                    .string()
                    .length(3)
                    .optional()
                    .describe(
                        "Three-letter lowercase currency code (defaults to primary currency).",
                    ),
                notes: z
                    .string()
                    .max(350)
                    .optional()
                    .describe("Optional notes for the budget period."),
            },
            annotations: {
                idempotentHint: true,
            },
        },
        async ({ start_date, category_id, amount, currency, notes }) => {
            try {
                const body: Record<string, unknown> = {
                    start_date,
                    category_id,
                    amount,
                };
    
                if (currency) body.currency = currency;
                if (notes !== undefined) body.notes = notes;
    
                const response = await api.put("/budgets", body);
    
                if (!response.ok) {
                    return handleApiError(response, "Failed to upsert budget");
                }
    
                return dataResponse(await response.json());
            } catch (error) {
                return catchError(error, "Failed to upsert budget");
            }
        },
    );
  • src/index.ts:30-30 (registration)
    The registerBudgetTools(server) call in the main entry point that wires up the tool registration.
    registerBudgetTools(server);
  • The api.put() method used by the handler to send the PUT request to the LunchMoney API. api is a helper exported from src/api.ts.
    export const api = {
        get: (path: string) => apiRequest("GET", path),
        post: (path: string, body?: unknown) => apiRequest("POST", path, body),
        put: (path: string, body: unknown) => apiRequest("PUT", path, body),
        delete: (path: string, body?: unknown) => apiRequest("DELETE", path, body),
        upload: (path: string, formData: FormData) =>
            apiUpload("POST", path, formData),
    };
Behavior4/5

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

Annotations already provide idempotentHint=true, indicating safe retry. The description adds behavioral context about start_date validity and references get_budget_settings, which goes beyond the annotation. No contradiction.

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?

Two sentences, front-loaded with purpose and a critical constraint. No unnecessary words. Every sentence earns its place.

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?

While the description covers the key purpose and constraint, it lacks information about return values (expected to be the upserted budget) and error handling (e.g., invalid date returns previous/next dates, mentioned only in schema). Moderate completeness given the tool's complexity.

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?

Schema coverage is 100%, with descriptions for all 5 parameters. The description restates the start_date constraint already in the schema but adds no new parameter-level details. Baseline score of 3 is appropriate.

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 'Create or update a budget for a category and budget period', specifying the verb (create/update) and resource (budget) with context (category and budget period). It distinguishes from sibling tools like get_budget_settings (read) and remove_budget (delete).

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

Usage Guidelines4/5

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

The description says the start_date must be a valid budget period start and references get_budget_settings, providing context for when to use this tool after checking settings. However, it does not explicitly state when not to use it or mention alternatives like remove_budget for deletion.

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

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