Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

Update Category Budget

ynab_update_category_budget

Adjust budgeted amounts for specific categories in YNAB to allocate funds or reallocate money between spending areas for precise financial planning.

Instructions

Updates the budgeted amount for a category in a specific month. Use this to allocate funds to categories or move money between categories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budgetIdNoThe ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)
monthYesThe budget month in ISO format (e.g. 2024-01-01). Must be the first day of the month.
categoryIdYesThe ID of the category to update
budgetedYesThe amount to budget in dollars (e.g. 500.00). This sets the total budgeted amount, not an increment.

Implementation Reference

  • The execute function that handles the tool logic: resolves budget ID, converts amount to milliunits, calls YNAB API to update category budget, and returns success/error response.
    export async function execute(input: UpdateCategoryBudgetInput, api: ynab.API) {
      try {
        const budgetId = getBudgetId(input.budgetId);
        const budgetedMilliunits = Math.round(input.budgeted * 1000);
    
        const response = await api.categories.updateMonthCategory(
          budgetId,
          input.month,
          input.categoryId,
          {
            category: {
              budgeted: budgetedMilliunits,
            },
          }
        );
    
        if (!response.data.category) {
          throw new Error("Failed to update category - no category data returned");
        }
    
        const category = response.data.category;
    
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              success: true,
              category: {
                id: category.id,
                name: category.name,
                budgeted: (category.budgeted / 1000).toFixed(2),
                activity: (category.activity / 1000).toFixed(2),
                balance: (category.balance / 1000).toFixed(2),
              },
              message: `Successfully updated ${category.name} budget to $${(category.budgeted / 1000).toFixed(2)}`,
            }, null, 2),
          }],
        };
      } catch (error) {
        console.error("Error updating category budget:", error);
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              success: false,
              error: getErrorMessage(error),
            }, null, 2),
          }],
        };
      }
    }
  • Zod-based input schema defining parameters for the tool: budgetId (optional), month (ISO date), categoryId, budgeted amount.
    export const inputSchema = {
      budgetId: z.string().optional().describe("The ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)"),
      month: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("The budget month in ISO format (e.g. 2024-01-01). Must be the first day of the month."),
      categoryId: z.string().describe("The ID of the category to update"),
      budgeted: z.number().describe("The amount to budget in dollars (e.g. 500.00). This sets the total budgeted amount, not an increment."),
    };
  • src/index.ts:63-67 (registration)
    Registers the tool with the MCP server using the name, title, description, inputSchema from the tool module, and a wrapper async handler that invokes the tool's execute function with the YNAB API instance.
    server.registerTool(UpdateCategoryBudgetTool.name, {
      title: "Update Category Budget",
      description: UpdateCategoryBudgetTool.description,
      inputSchema: UpdateCategoryBudgetTool.inputSchema,
    }, async (input) => UpdateCategoryBudgetTool.execute(input, api));
  • Helper function to retrieve the budget ID from input parameter or YNAB_BUDGET_ID environment variable.
    function getBudgetId(inputBudgetId?: string): string {
      const budgetId = inputBudgetId || process.env.YNAB_BUDGET_ID || "";
      if (!budgetId) {
        throw new Error("No budget ID provided. Please provide a budget ID or set the YNAB_BUDGET_ID environment variable.");
      }
      return budgetId;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions the tool 'Updates' (implying mutation) and describes the action, it doesn't disclose important behavioral traits like required permissions, whether changes are reversible, rate limits, or what happens to existing budget amounts. For a mutation tool with zero annotation coverage, this is a significant gap.

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 perfectly concise with two sentences that each earn their place. The first sentence states the core purpose, and the second provides usage context. No wasted words, and it's front-loaded with the essential information.

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?

For a mutation tool with no annotations and no output schema, the description is adequate but has clear gaps. It explains what the tool does and when to use it, but doesn't cover behavioral aspects like permissions, side effects, or return values. Given the complexity of budget updates, more context would be helpful.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond what the schema provides - it mentions 'budgeted amount' and 'specific month' which are already in the schema. The baseline score of 3 is appropriate when the schema does the heavy lifting.

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 the specific action ('Updates the budgeted amount'), target resource ('for a category in a specific month'), and scope ('allocates funds to categories or move money between categories'). It distinguishes this from sibling tools like ynab_list_categories (read-only) and ynab_update_transaction (different resource).

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 provides clear context for when to use this tool ('to allocate funds to categories or move money between categories'), but doesn't explicitly state when not to use it or name specific alternatives. It implies usage for budget adjustments rather than transaction management, which differentiates it from sibling tools like ynab_create_transaction.

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/calebl/ynab-mcp-server'

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