Skip to main content
Glama
calebl
by calebl

ynab_import_transactions

Import transactions from linked financial institutions into your YNAB budget to update account balances and categorize spending.

Instructions

Imports available transactions on all linked accounts for the budget. This triggers an import from connected financial institutions (equivalent to clicking 'Import' in the YNAB app).

Input Schema

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

Implementation Reference

  • The main handler function that executes the YNAB transaction import logic, calling the YNAB API and handling responses/errors.
    export async function execute(input: ImportTransactionsInput, api: ynab.API) { try { const budgetId = getBudgetId(input.budgetId); console.error(`Importing transactions for budget ${budgetId}`); const response = await api.transactions.importTransactions(budgetId); return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, transaction_ids: response.data.transaction_ids, imported_count: response.data.transaction_ids.length, message: response.data.transaction_ids.length > 0 ? `Successfully imported ${response.data.transaction_ids.length} transaction(s)` : "No new transactions to import", }, null, 2), }], }; } catch (error) { console.error("Error importing transactions:", error); return { content: [{ type: "text" as const, text: JSON.stringify({ success: false, error: getErrorMessage(error), }, null, 2), }], }; } }
  • Zod-based input schema defining optional budgetId parameter.
    export const inputSchema = { budgetId: z.string().optional().describe("The ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)"), };
  • src/index.ts:117-121 (registration)
    Registration of the tool with the MCP server, providing name, description, schema, and execute wrapper.
    server.registerTool(ImportTransactionsTool.name, { title: "Import Transactions", description: ImportTransactionsTool.description, inputSchema: ImportTransactionsTool.inputSchema, }, async (input) => ImportTransactionsTool.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; }
  • src/index.ts:21-21 (registration)
    Import statement for the ImportTransactionsTool module used in registration.
    import * as ImportTransactionsTool from "./tools/ImportTransactionsTool.js";

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