Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

List Accounts

ynab_list_accounts

Retrieve a list of all accounts in your YNAB budget, including optional closed accounts, to easily find account IDs for creating transactions.

Instructions

Lists all accounts in a budget. Useful for finding account IDs when creating transactions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budgetIdNoThe ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)
includeClosedAccountsNoInclude closed accounts in the list (default: false)

Implementation Reference

  • The execute function that handles the 'ynab_list_accounts' tool logic. Calls ynab API accounts.getAccounts, filters by closed/deleted, formats output with balance/1000.
    export async function execute(input: ListAccountsInput, api: ynab.API) {
      try {
        const budgetId = getBudgetId(input.budgetId);
        const includeClosedAccounts = input.includeClosedAccounts ?? false;
    
        console.error(`Listing accounts for budget ${budgetId}`);
        const response = await api.accounts.getAccounts(budgetId);
    
        // Filter and format accounts
        const accounts = response.data.accounts
          .filter((account) => !account.deleted && (includeClosedAccounts || !account.closed))
          .map((account) => ({
            id: account.id,
            name: account.name,
            type: account.type,
            on_budget: account.on_budget,
            closed: account.closed,
            balance: (account.balance / 1000).toFixed(2),
            cleared_balance: (account.cleared_balance / 1000).toFixed(2),
            uncleared_balance: (account.uncleared_balance / 1000).toFixed(2),
            transfer_payee_id: account.transfer_payee_id,
          }));
    
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              accounts,
              account_count: accounts.length,
            }, null, 2),
          }],
        };
      } catch (error) {
        console.error("Error listing accounts:", error);
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              success: false,
              error: getErrorMessage(error),
            }, null, 2),
          }],
        };
      }
    }
  • Input schema using zod: optional budgetId and optional includeClosedAccounts boolean.
    export const inputSchema = {
      budgetId: z.string().optional().describe("The ID of the budget (optional, defaults to YNAB_BUDGET_ID environment variable)"),
      includeClosedAccounts: z.boolean().optional().describe("Include closed accounts in the list (default: false)"),
    };
    
    interface ListAccountsInput {
      budgetId?: string;
      includeClosedAccounts?: boolean;
    }
  • Helper function getBudgetId that resolves budget ID from input or YNAB_BUDGET_ID env var.
    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:105-109 (registration)
    Registration of the tool using server.registerTool with name, description, inputSchema, and execute callback.
    server.registerTool(ListAccountsTool.name, {
      title: "List Accounts",
      description: ListAccountsTool.description,
      inputSchema: ListAccountsTool.inputSchema,
    }, async (input) => ListAccountsTool.execute(input, api));
  • src/index.ts:19-19 (registration)
    Import of the ListAccountsTool module in the main index.ts file.
    import * as ListAccountsTool from "./tools/ListAccountsTool.js";
Behavior2/5

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

No annotations are provided, so the description carries full burden. It does not disclose behavioral traits beyond listing accounts, such as read-only nature, rate limits, or sorting behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is concise and includes a practical hint, but lacks structured formatting for quick scanning.

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 simple list tool with no output schema, the description provides the basic purpose and a use case, but does not mention response details, pagination, or filtering, which may be expected.

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 coverage is 100% with descriptions for both parameters, so description adds minimal extra meaning beyond stating the default for budgetId, which is already documented.

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 'Lists all accounts in a budget' and provides a specific use case ('finding account IDs when creating transactions'), distinguishing it from sibling tools like ynab_list_budgets.

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 implies usage context by noting it's 'useful for finding account IDs when creating transactions', but does not explicitly state when not to use it or compare to alternatives.

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