list_budgets
Retrieve all available budgets from the YNAB API to view and manage financial data through the YNAB MCP Server.
Instructions
Lists all available budgets from YNAB API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/ListBudgetsTool.ts:8-34 (handler)The main handler function `execute` that fetches and returns the list of budgets from the YNAB API.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.log("Listing budgets"); const budgetsResponse = await api.budgets.getBudgets(); console.log(`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: ${JSON.stringify(error)}`); return { content: [{ type: "text" as const, text: `Error listing budgets: ${JSON.stringify(error)}` }] }; } }
- src/tools/ListBudgetsTool.ts:4-6 (schema)Exports the tool name, description, and input schema (empty object).export const name = "list_budgets"; export const description = "Lists all available budgets from YNAB API"; export const inputSchema = {};
- src/index.ts:22-26 (registration)Registers the 'list_budgets' tool with the MCP server, providing title, description, input schema, and handler.server.registerTool(ListBudgetsTool.name, { title: "List Budgets", description: ListBudgetsTool.description, inputSchema: ListBudgetsTool.inputSchema, }, async (input) => ListBudgetsTool.execute(input, api));