Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

List Accounts

ynab_list_accounts

Retrieve all budget accounts to find account IDs needed for creating transactions in YNAB.

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 main handler function that fetches accounts from the YNAB API, filters and formats them, and returns a JSON response.
    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),
          }],
        };
      }
    }
  • Defines the tool's name, description, and input schema with Zod validators.
    export const name = "ynab_list_accounts";
    export const description = "Lists all accounts in a budget. Useful for finding account IDs when creating transactions.";
    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)"),
    };
  • src/index.ts:105-109 (registration)
    Registers the ynab_list_accounts tool with the MCP server using its name, description, input schema, and a wrapper around the execute function.
    server.registerTool(ListAccountsTool.name, {
      title: "List Accounts",
      description: ListAccountsTool.description,
      inputSchema: ListAccountsTool.inputSchema,
    }, async (input) => ListAccountsTool.execute(input, api));
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 implies a read-only operation ('Lists') but doesn't explicitly state safety, permissions, or rate limits. The description adds some context about finding IDs for transactions, which is helpful, but lacks details on response format, pagination, or error handling.

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 sentence states the core purpose, and the second provides practical usage guidance. It's appropriately sized and front-loaded with essential information.

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 no annotations and no output schema, the description is adequate but has gaps. It covers the basic purpose and usage context, but doesn't address behavioral aspects like safety, permissions, or response format. For a simple list tool with good schema coverage, it's minimally complete but could benefit from more transparency.

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. The description doesn't add any parameter-specific information beyond what's in the schema, such as explaining the budgetId default behavior or when to use includeClosedAccounts. Baseline 3 is appropriate when the schema handles all parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Lists' and resource 'all accounts in a budget', making the purpose specific and understandable. It distinguishes from siblings like 'ynab_list_budgets' and 'ynab_list_categories' by specifying accounts, but doesn't explicitly contrast with other list tools beyond the resource type.

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 usage: 'Useful for finding account IDs when creating transactions.' This gives a practical application scenario. However, it doesn't specify when NOT to use it or explicitly name alternatives like 'ynab_get_transactions' for other account-related needs.

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