Skip to main content
Glama
dgalarza

YNAB MCP Server

by dgalarza

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
NameRequiredDescriptionDefault
budget_idYes

Implementation Reference

  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dgalarza/ynab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server