Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

Bulk Approve Transactions

ynab_bulk_approve_transactions

Approve multiple YNAB transactions simultaneously by providing transaction IDs in a single API call, saving time on manual approval tasks.

Instructions

Approves multiple transactions at once. Provide an array of transaction IDs to approve them all in a single API call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budgetIdNoThe ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)
transactionIdsYesArray of transaction IDs to approve

Implementation Reference

  • The main handler function that executes the bulk approval of transactions using the YNAB API. It takes transaction IDs, updates them to approved status, and returns the results.
    export async function execute(input: BulkApproveTransactionsInput, api: ynab.API) {
      try {
        const budgetId = getBudgetId(input.budgetId);
    
        if (!input.transactionIds || input.transactionIds.length === 0) {
          throw new Error("No transaction IDs provided");
        }
    
        // Build the update transactions array
        const transactions: ynab.SaveTransactionWithIdOrImportId[] = input.transactionIds.map((id) => ({
          id,
          approved: true,
        }));
    
        const response = await api.transactions.updateTransactions(budgetId, {
          transactions,
        });
    
        if (!response.data.transactions) {
          throw new Error("Failed to update transactions - no transaction data returned");
        }
    
        const updatedTransactions = response.data.transactions.map((txn) => ({
          id: txn.id,
          date: txn.date,
          amount: (txn.amount / 1000).toFixed(2),
          payee_name: txn.payee_name,
          approved: txn.approved,
        }));
    
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              success: true,
              approved_count: updatedTransactions.length,
              transactions: updatedTransactions,
              message: `Successfully approved ${updatedTransactions.length} transaction(s)`,
            }, null, 2),
          }],
        };
      } catch (error) {
        console.error("Error bulk approving transactions:", error);
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              success: false,
              error: getErrorMessage(error),
            }, null, 2),
          }],
        };
      }
    }
  • Tool name, description, and Zod-based input schema definition.
    export const name = "ynab_bulk_approve_transactions";
    export const description = "Approves multiple transactions at once. Provide an array of transaction IDs to approve them all in a single API call.";
    export const inputSchema = {
      budgetId: z.string().optional().describe("The ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)"),
      transactionIds: z.array(z.string()).describe("Array of transaction IDs to approve"),
    };
  • src/index.ts:75-79 (registration)
    Registers the tool with the MCP server, providing title, description, inputSchema, and the execute handler wrapped with the YNAB API instance.
    server.registerTool(BulkApproveTransactionsTool.name, {
      title: "Bulk Approve Transactions",
      description: BulkApproveTransactionsTool.description,
      inputSchema: BulkApproveTransactionsTool.inputSchema,
    }, async (input) => BulkApproveTransactionsTool.execute(input, api));
  • Helper function to retrieve or default the budget ID from input or 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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states the tool 'approves' transactions (implying a write/mutation operation), it lacks critical details such as required permissions, whether approval is reversible, error handling for invalid IDs, or rate limits. 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 extremely concise with two sentences that directly convey purpose and usage without any wasted words. It is front-loaded with the core action and efficiently explains the parameter requirement, making it easy for an agent to parse quickly.

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?

Given this is a mutation tool (approves transactions) with no annotations and no output schema, the description is incomplete. It fails to address behavioral aspects like permissions, side effects, error responses, or what happens upon approval. For a tool that modifies data, more context is needed to ensure safe and correct usage.

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 fully documents both parameters (budgetId and transactionIds). The description adds minimal value beyond the schema by mentioning 'array of transaction IDs,' which is redundant with the schema. Baseline 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 ('approves multiple transactions at once') and resource ('transactions'), distinguishing it from the sibling 'ynab_approve_transaction' which handles single transactions. The phrase 'bulk' and 'multiple transactions at once' explicitly differentiates it from its single-transaction counterpart.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: 'Provide an array of transaction IDs to approve them all in a single API call.' This directly contrasts with the sibling 'ynab_approve_transaction' for single approvals, making the alternative clear and the usage context well-defined.

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