get_transactions
Retrieve recent transactions for a specific account and budget using the MCP YNAB Server. Input budget_id and account_id to access transaction data.
Instructions
Get recent transactions for a specific account in a specific budget.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes | ||
| budget_id | Yes |
Implementation Reference
- src/mcp_ynab/server.py:417-452 (handler)The handler function for the 'get_transactions' MCP tool. It fetches transactions for a given budget and account since the 1st of the current month using the YNAB API, formats them into a markdown table, and returns the result.@mcp.tool() async def get_transactions(budget_id: str, account_id: str) -> str: """Get recent transactions for a specific account in a specific budget.""" async with await get_ynab_client() as client: transactions_api = TransactionsApi(client) all_transactions: List[TransactionDetail] = [] since_date = datetime.now().replace(day=1).date() response = transactions_api.get_transactions_by_account( budget_id, account_id, since_date=since_date ) all_transactions.extend(response.data.transactions) markdown = "# Recent Transactions\n\n" if not all_transactions: return markdown + "_No recent transactions found._\n" headers = ["ID", "Date", "Amount", "Payee Name", "Category Name", "Memo"] align = ["left", "left", "right", "left", "left", "left"] rows = [] for txn in all_transactions: amount_str = f"${txn.amount / 1000:,.2f}" rows.append( [ txn.id, txn.var_date.strftime("%Y-%m-%d"), amount_str, txn.payee_name or "N/A", txn.category_name or "N/A", txn.memo or "", ] ) markdown += _build_markdown_table(rows, headers, align) return markdown