Skip to main content
Glama
klauern

MCP YNAB Server

by klauern

get_transactions

Retrieve recent transactions for a specific account within a YNAB budget to monitor spending and track financial activity.

Instructions

Get recent transactions for a specific account in a specific budget.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes
account_idYes

Implementation Reference

  • The handler function for the 'get_transactions' MCP tool. It fetches transactions for a specific budget and account using the YNAB API since the 1st of the current month, 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

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/klauern/mcp-ynab'

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