list_budgets
Retrieve all accessible budgets from YNAB with optional account details to view financial overviews and manage resources.
Instructions
[1 API call] List all budgets the user has access to, with optional account info
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_accounts | No | Include accounts for each budget |
Implementation Reference
- src/tools/budgets.ts:7-32 (handler)Implementation and registration of the 'list_budgets' tool. It fetches budgets using the YNAB client and formats them as a text result.
server.registerTool("list_budgets", { title: "List Budgets", description: "[1 API call] List all budgets the user has access to, with optional account info", inputSchema: { include_accounts: z.boolean().optional().describe("Include accounts for each budget"), }, annotations: { readOnlyHint: true }, }, async ({ include_accounts }) => { try { const response = await getClient().plans.getPlans(include_accounts); const budgets = response.data.plans; const lines = budgets.map((b) => { let line = `- ${b.name} (ID: ${b.id})`; if (b.last_modified_on) line += ` [Last modified: ${b.last_modified_on}]`; if (include_accounts && b.accounts) { for (const a of b.accounts) { line += `\n - ${a.name}: ${formatCurrency(a.balance)} (${a.type})`; } } return line; }); return textResult(`Budgets:\n${lines.join("\n")}`); } catch (e: any) { return errorResult(e.message); } });