get_budget
Retrieve detailed information for a specific YNAB budget, including all accounts, categories, and transactions. Use 'last-used' to access your most recent budget or specify a budget ID.
Instructions
[1 API call] Get a single budget's full detail including all entities. Use 'last-used' for the most recently accessed budget.
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 - only return entities changed since this server knowledge value |
Implementation Reference
- src/tools/budgets.ts:34-61 (handler)The handler function for "get_budget" tool, which uses the YNAB client to fetch budget details.
server.registerTool("get_budget", { title: "Get Budget", description: "[1 API call] Get a single budget's full detail including all entities. Use 'last-used' for the most recently accessed budget.", inputSchema: { budget_id: z.string().default("last-used").describe("Budget ID or 'last-used'"), last_knowledge_of_server: z.number().optional().describe("Delta request - only return entities changed since this server knowledge value"), }, annotations: { readOnlyHint: true }, }, async ({ budget_id, last_knowledge_of_server }) => { try { const response = await getClient().plans.getPlanById(budget_id, last_knowledge_of_server); const b = response.data.plan; const summary = [ `Budget: ${b.name}`, `ID: ${b.id}`, `Last Modified: ${b.last_modified_on}`, `Accounts: ${b.accounts?.length ?? 0}`, `Categories: ${b.categories?.length ?? 0}`, `Payees: ${b.payees?.length ?? 0}`, `Transactions: ${b.transactions?.length ?? 0}`, `Scheduled Transactions: ${b.scheduled_transactions?.length ?? 0}`, `Server Knowledge: ${response.data.server_knowledge}`, ]; return textResult(summary.join("\n")); } catch (e: any) { return errorResult(e.message); } });