list_accounts
Retrieve all budget accounts with current balances and account types to monitor financial positions and track spending across categories.
Instructions
[1 API call] List all accounts for a budget including balances and types
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| budget_id | No | Budget ID or 'last-used' | last-used |
| last_knowledge_of_server | No | Delta request token |
Implementation Reference
- src/tools/accounts.ts:13-36 (handler)The 'list_accounts' tool registration and handler implementation. It uses the YNAB client to fetch accounts for a given budget and formats the result.
server.registerTool("list_accounts", { title: "List Accounts", description: "[1 API call] List all accounts for a budget including balances and types", inputSchema: { budget_id: z.string().default("last-used").describe("Budget ID or 'last-used'"), last_knowledge_of_server: z.number().optional().describe("Delta request token"), }, annotations: { readOnlyHint: true }, }, async ({ budget_id, last_knowledge_of_server }) => { try { const response = await getClient().accounts.getAccounts(budget_id, last_knowledge_of_server); const accounts = response.data.accounts; const lines = accounts.map((a) => { const status = a.closed ? " [CLOSED]" : ""; const onBudget = a.on_budget ? "On Budget" : "Off Budget"; return `- ${a.name}${status}: ${formatCurrency(a.balance)} (${a.type}, ${onBudget}) [ID: ${a.id}]`; }); return textResult( `Accounts (${accounts.length}):\n${lines.join("\n")}\n\nServer Knowledge: ${response.data.server_knowledge}` ); } catch (e: any) { return errorResult(e.message); } });