get_account_balance
Retrieve the current balance in dollars for a specific YNAB account by providing the account ID, enabling users to quickly access financial data for budgeting and planning.
Instructions
Get the current balance of a YNAB account (in dollars).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes |
Implementation Reference
- src/mcp_ynab/server.py:351-362 (handler)The handler function decorated with @mcp.tool(), which registers the tool and defines its schema via the function signature (account_id: str -> float). It fetches the first budget, retrieves the account by ID, and returns the balance in dollars (converting from YNAB's milliunits).@mcp.tool() async def get_account_balance(account_id: str) -> float: """Get the current balance of a YNAB account (in dollars).""" async with await get_ynab_client() as client: accounts_api = AccountsApi(client) budgets_api = BudgetsApi(client) budgets_response = budgets_api.get_budgets() budget_id = budgets_response.data.budgets[0].id response = accounts_api.get_account_by_id(budget_id, account_id) return float(response.data.account.balance) / 1000