Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

Import Transactions

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";
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It helpfully explains that this triggers an external import action (similar to clicking 'Import' in the app), which implies network calls and potential delays. However, it lacks details on permissions needed, rate limits, error handling, or what 'available transactions' means operationally, leaving gaps for a mutation tool.

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 two concise sentences with zero waste: the first states the core action and scope, and the second provides essential behavioral context (triggering external import). Every sentence earns its place by adding critical information beyond the tool name.

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?

Given the tool's complexity (a mutation with external dependencies), no annotations, and no output schema, the description is adequate but incomplete. It covers the purpose and basic behavior but misses details like response format, error cases, or prerequisites (e.g., linked accounts must exist). For a tool that could have significant side effects, more context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the baseline is 3. The description adds value by implicitly clarifying that 'budgetId' targets the budget whose linked accounts are imported, but it doesn't explain the default behavior (environment variable) or provide examples. This extra context slightly elevates the score above the baseline.

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 ('Imports available transactions') and resource ('on all linked accounts for the budget'), distinguishing it from siblings like 'ynab_get_transactions' (read-only) and 'ynab_create_transaction' (manual creation). It precisely defines the tool's function beyond just restating the name/title.

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 ('triggers an import from connected financial institutions'), implying it's for syncing external data rather than manual entry. However, it doesn't explicitly state when not to use it or name alternatives (e.g., vs. 'ynab_create_transaction' for manual additions), which prevents a perfect score.

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