List Budgets
ynab_list_budgetsRetrieve a list of all budgets from your YNAB account to view and manage your financial plans.
Instructions
Lists all available budgets from YNAB API
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/ListBudgetsTool.ts:9-38 (handler)Handles the core logic of listing budgets from the YNAB API, returning the list or an error message.
export async function execute(_input: Record<string, unknown>, api: ynab.API) { try { if (!process.env.YNAB_API_TOKEN) { return { content: [{ type: "text" as const, text: "YNAB API Token is not set" }] }; } console.error("Listing budgets"); const budgetsResponse = await api.budgets.getBudgets(); console.error(`Found ${budgetsResponse.data.budgets.length} budgets`); const budgets = budgetsResponse.data.budgets.map((budget) => ({ id: budget.id, name: budget.name, })); return { content: [{ type: "text" as const, text: JSON.stringify(budgets, null, 2) }] }; } catch (error: unknown) { console.error("Error listing budgets:", error); return { content: [{ type: "text" as const, text: JSON.stringify({ success: false, error: getErrorMessage(error), }, null, 2) }] }; } } - src/tools/ListBudgetsTool.ts:5-7 (schema)Defines the tool name 'ynab_list_budgets', description, and empty input schema (no parameters needed).
export const name = "ynab_list_budgets"; export const description = "Lists all available budgets from YNAB API"; export const inputSchema = {}; - src/index.ts:33-37 (registration)Registers the ListBudgetsTool with the MCP server using its name, description, input schema, and execute handler.
server.registerTool(ListBudgetsTool.name, { title: "List Budgets", description: ListBudgetsTool.description, inputSchema: ListBudgetsTool.inputSchema, }, async (input) => ListBudgetsTool.execute(input, api));