Skip to main content
Glama
klauern

MCP YNAB Server

by klauern

get_transactions_needing_attention

Identify transactions requiring review in your YNAB budget by filtering uncategorized or unapproved items from recent activity.

Instructions

List transactions that need attention based on specified filter type in a YNAB budget.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes
filter_typeNoType of transactions to show. One of: 'uncategorized', 'unapproved', 'both'both
days_backNoNumber of days to look back (default 30, None for all)

Implementation Reference

  • The primary handler function for the 'get_transactions_needing_attention' MCP tool. It uses YNAB API to retrieve transactions, applies filters for uncategorized/unapproved based on input, formats into a markdown table using helper functions.
    @mcp.tool()
    async def get_transactions_needing_attention(
        budget_id: str,
        filter_type: Annotated[
            str,
            Field(
                description="Type of transactions to show. One of: 'uncategorized', 'unapproved', 'both'"
            ),
        ] = "both",
        days_back: Annotated[
            Optional[int], Field(description="Number of days to look back (default 30, None for all)")
        ] = 30,
    ) -> str:
        """List transactions that need attention based on specified filter type in a YNAB budget."""
        filter_type = filter_type.lower()
        if filter_type not in ["uncategorized", "unapproved", "both"]:
            return "Error: Invalid filter_type. Must be 'uncategorized', 'unapproved', or 'both'"
    
        async with await get_ynab_client() as client:
            transactions_api = TransactionsApi(client)
            accounts_api = AccountsApi(client)
    
            accounts_response = accounts_api.get_accounts(budget_id)
            account_map = {
                account.id: account.name
                for account in accounts_response.data.accounts
                if not account.closed and not account.deleted
            }
    
            since_date = (datetime.now() - timedelta(days=days_back)).date() if days_back else None
            response = transactions_api.get_transactions(budget_id, since_date=since_date)
            needs_attention = _filter_transactions(response.data.transactions, filter_type)
    
            markdown = f"# Transactions Needing Attention ({filter_type.title()})\n\n"
            if not needs_attention:
                return markdown + "_No transactions need attention._"
    
            markdown += "**Filters Applied:**\n"
            markdown += f"- Filter type: {filter_type}\n"
            if days_back:
                markdown += f"- Looking back {days_back} days\n"
            markdown += "\n"
    
            headers = ["ID", "Date", "Account", "Amount", "Payee", "Status", "Memo"]
            align = ["left", "left", "left", "right", "left", "left", "left"]
            rows = [_get_transaction_row(txn, account_map, filter_type) for txn in needs_attention]
    
            markdown += _build_markdown_table(rows, headers, align)
            return markdown
  • Helper function used by the handler to filter transactions that are uncategorized and/or unapproved.
    def _filter_transactions(
        transactions: List[TransactionDetail], filter_type: str
    ) -> List[TransactionDetail]:
        """Filter transactions based on the filter type."""
        needs_attention = []
        for txn in transactions:
            if isinstance(txn, TransactionDetail):
                needs_category = filter_type in ["uncategorized", "both"] and not txn.category_id
                needs_approval = filter_type in ["unapproved", "both"] and not txn.approved
                if needs_category or needs_approval:
                    needs_attention.append(txn)
        return needs_attention
  • Helper function used by the handler to format individual transactions into markdown table rows, including status flags.
    def _get_transaction_row(
        txn: TransactionDetail, account_map: Dict[str, str], filter_type: str
    ) -> List[str]:
        """Format a transaction into a row for the markdown table."""
        amount_dollars = float(txn.amount) / 1000
        amount_str = f"${abs(amount_dollars):,.2f}"
        if amount_dollars < 0:
            amount_str = f"-{amount_str}"
    
        status = []
        if not txn.category_id:
            status.append("Uncategorized")
        if not txn.approved:
            status.append("Unapproved")
    
        return [
            txn.id,
            txn.var_date.strftime("%Y-%m-%d"),
            account_map.get(txn.account_id, "Unknown"),
            amount_str,
            txn.payee_name or "N/A",
            ", ".join(status),
            txn.memo or "",
        ]
  • Pydantic schema definitions for the tool's input parameters using Annotated and Field.
        budget_id: str,
        filter_type: Annotated[
            str,
            Field(
                description="Type of transactions to show. One of: 'uncategorized', 'unapproved', 'both'"
            ),
        ] = "both",
        days_back: Annotated[
            Optional[int], Field(description="Number of days to look back (default 30, None for all)")
        ] = 30,
    ) -> str:
  • MCP tool registration decorator applied to the handler function.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it's a list operation, implying read-only behavior, but lacks details on permissions, rate limits, pagination, or what 'attention' entails. This is insufficient for a tool with three parameters and no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. Every word contributes to understanding the tool's function, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with three parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'needing attention' means, how results are returned, or provide enough context for safe and effective use, leaving significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 67%, with two parameters well-documented in the schema. The description adds minimal value beyond the schema by implying filtering based on 'attention,' but doesn't elaborate on parameter interactions or meaning. Baseline 3 is appropriate given the moderate schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('transactions that need attention') with specific context ('in a YNAB budget'). It distinguishes from generic 'get_transactions' by focusing on those needing attention, though it doesn't explicitly contrast with all siblings like 'create_transaction' or 'get_accounts'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives is provided. The description mentions filtering but doesn't specify scenarios where this tool is preferred over 'get_transactions' or other siblings, nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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