Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

Update Transaction

ynab_update_transaction

Update an existing YNAB transaction by providing its ID and any fields to change, such as amount, date, payee, category, memo, or flagged status.

Instructions

Updates an existing transaction. All fields except transactionId are optional - only provide fields you want to change.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budgetIdNoThe ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)
transactionIdYesThe ID of the transaction to update
accountIdNoMove transaction to a different account
dateNoThe date of the transaction in ISO format (e.g. 2024-03-24)
amountNoThe amount in dollars (e.g. -10.99 for outflow, 10.99 for inflow)
payeeIdNoThe ID of the payee
payeeNameNoThe name of the payee (creates new payee if doesn't exist)
categoryIdNoThe category ID for the transaction
memoNoA memo/note for the transaction
clearedNoThe cleared status
approvedNoWhether the transaction is approved
flagColorNoThe transaction flag color

Implementation Reference

  • The main execute function that handles the 'ynab_update_transaction' tool logic. It builds an update object with only provided fields, calls the YNAB API's updateTransaction, and returns a formatted response.
    export async function execute(input: UpdateTransactionInput, api: ynab.API) {
      try {
        const budgetId = getBudgetId(input.budgetId);
    
        // Build the update object with only provided fields
        const transactionUpdate: ynab.SaveTransactionWithOptionalFields = {};
    
        if (input.accountId !== undefined) {
          transactionUpdate.account_id = input.accountId;
        }
        if (input.date !== undefined) {
          transactionUpdate.date = input.date;
        }
        if (input.amount !== undefined) {
          transactionUpdate.amount = Math.round(input.amount * 1000);
        }
        if (input.payeeId !== undefined) {
          transactionUpdate.payee_id = input.payeeId;
        }
        if (input.payeeName !== undefined) {
          transactionUpdate.payee_name = input.payeeName;
        }
        if (input.categoryId !== undefined) {
          transactionUpdate.category_id = input.categoryId;
        }
        if (input.memo !== undefined) {
          transactionUpdate.memo = input.memo;
        }
        if (input.cleared !== undefined) {
          transactionUpdate.cleared = mapClearedStatus(input.cleared);
        }
        if (input.approved !== undefined) {
          transactionUpdate.approved = input.approved;
        }
        if (input.flagColor !== undefined) {
          transactionUpdate.flag_color = input.flagColor as ynab.TransactionFlagColor;
        }
    
        const response = await api.transactions.updateTransaction(
          budgetId,
          input.transactionId,
          { transaction: transactionUpdate }
        );
    
        if (!response.data.transaction) {
          throw new Error("Failed to update transaction - no transaction data returned");
        }
    
        const txn = response.data.transaction;
    
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              success: true,
              transaction: {
                id: txn.id,
                date: txn.date,
                amount: (txn.amount / 1000).toFixed(2),
                payee_name: txn.payee_name,
                category_name: txn.category_name,
                memo: txn.memo,
                cleared: txn.cleared,
                approved: txn.approved,
                account_name: txn.account_name,
                flag_color: txn.flag_color,
              },
              message: "Transaction updated successfully",
            }, null, 2),
          }],
        };
      } catch (error) {
        console.error("Error updating transaction:", error);
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              success: false,
              error: getErrorMessage(error),
            }, null, 2),
          }],
        };
      }
    }
  • Input schema using Zod for the 'ynab_update_transaction' tool. Defines all optional fields (budgetId, accountId, date, amount, payeeId, payeeName, categoryId, memo, cleared, approved, flagColor) plus required transactionId.
    export const inputSchema = {
      budgetId: z.string().optional().describe("The ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)"),
      transactionId: z.string().describe("The ID of the transaction to update"),
      accountId: z.string().optional().describe("Move transaction to a different account"),
      date: z.string().optional().describe("The date of the transaction in ISO format (e.g. 2024-03-24)"),
      amount: z.number().optional().describe("The amount in dollars (e.g. -10.99 for outflow, 10.99 for inflow)"),
      payeeId: z.string().optional().describe("The ID of the payee"),
      payeeName: z.string().optional().describe("The name of the payee (creates new payee if doesn't exist)"),
      categoryId: z.string().optional().describe("The category ID for the transaction"),
      memo: z.string().optional().describe("A memo/note for the transaction"),
      cleared: z.enum(["cleared", "uncleared", "reconciled"]).optional().describe("The cleared status"),
      approved: z.boolean().optional().describe("Whether the transaction is approved"),
      flagColor: z.enum(["red", "orange", "yellow", "green", "blue", "purple"]).optional().describe("The transaction flag color"),
    };
  • TypeScript interface UpdateTransactionInput defining the shape of input parameters for the update transaction tool.
    interface UpdateTransactionInput {
      budgetId?: string;
      transactionId: string;
      accountId?: string;
      date?: string;
      amount?: number;
      payeeId?: string;
      payeeName?: string;
      categoryId?: string;
      memo?: string;
      cleared?: "cleared" | "uncleared" | "reconciled";
      approved?: boolean;
      flagColor?: "red" | "orange" | "yellow" | "green" | "blue" | "purple";
    }
  • src/index.ts:69-73 (registration)
    Registration of the 'ynab_update_transaction' tool with the MCP server using server.registerTool(), wiring up the name, description, inputSchema, and execute function.
    server.registerTool(UpdateTransactionTool.name, {
      title: "Update Transaction",
      description: UpdateTransactionTool.description,
      inputSchema: UpdateTransactionTool.inputSchema,
    }, async (input) => UpdateTransactionTool.execute(input, api));
  • Two helper functions: getBudgetId() resolves the budget ID from input or env var, and mapClearedStatus() maps string cleared status to YNAB enum.
    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;
    }
    
    function mapClearedStatus(cleared: string): ynab.TransactionClearedStatus {
      switch (cleared) {
        case "cleared":
          return ynab.TransactionClearedStatus.Cleared;
        case "reconciled":
          return ynab.TransactionClearedStatus.Reconciled;
        default:
          return ynab.TransactionClearedStatus.Uncleared;
      }
    }
Behavior2/5

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

With no annotations, the description should disclose behavior beyond 'updates'. It omits whether it returns the updated transaction, what happens on invalid IDs, or how it handles nested data. Only provides a merge hint.

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, first gives purpose, second gives usage nuance. No filler, 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?

Adequate for a straightforward update tool with well-documented schema. Lacks output description and error behavior, but sibling tools cover other operations.

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 covers all 12 parameters with descriptions (100% coverage). Description adds only that all optional fields are for partial updates, which is minimal added value beyond schema.

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 it updates an existing transaction, differentiating it from create and delete siblings. The optionality hint distinguishes it from a full replacement update.

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?

Explains that all fields except transactionId are optional, guiding sparse updates. Does not explicitly exclude scenarios (e.g., creating transactions) but name and sibling list make it clear.

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