get_unapproved_transactions
Retrieve transactions pending approval for review and decision-making in your YNAB budget management workflow.
Instructions
Get all unapproved transactions that need review.
Args:
budget_id: The ID of the budget (use 'last-used' for default budget)
Returns:
JSON string with list of unapproved transactions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| budget_id | Yes |
Implementation Reference
- src/ynab_mcp/server.py:417-429 (handler)MCP tool handler: decorated with @mcp.tool(), fetches unapproved transactions using YNABClient and serializes to JSON string.@mcp.tool() async def get_unapproved_transactions(budget_id: str) -> str: """Get all unapproved transactions that need review. Args: budget_id: The ID of the budget (use 'last-used' for default budget) Returns: JSON string with list of unapproved transactions """ client = get_ynab_client() result = await client.get_unapproved_transactions(budget_id) return json.dumps(result, indent=2)
- Core implementation in YNABClient: retrieves all transactions via SDK, filters for unapproved and non-deleted, formats and returns list.async def get_unapproved_transactions(self, budget_id: str) -> list[dict[str, Any]]: """Get all unapproved transactions. Args: budget_id: The budget ID or 'last-used' Returns: List of unapproved transaction dictionaries """ try: response = self.client.transactions.get_transactions(budget_id) transactions = [] for txn in response.data.transactions: if not txn.approved and not txn.deleted: transactions.append( { "id": txn.id, "date": str(txn.date), "amount": txn.amount / 1000 if txn.amount else 0, "memo": txn.memo, "cleared": txn.cleared, "account_id": txn.account_id, "account_name": txn.account_name, "payee_id": txn.payee_id, "payee_name": txn.payee_name, "category_id": txn.category_id, "category_name": txn.category_name, } ) return transactions except Exception as e: raise Exception(f"Failed to get unapproved transactions: {e}") from e