Skip to main content
Glama
klauern

MCP YNAB Server

by klauern

get_accounts

Retrieve all accounts from a specific YNAB budget in Markdown format to view balances and financial overview.

Instructions

List all YNAB accounts in a specific budget in Markdown format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes

Implementation Reference

  • The handler function for the 'get_accounts' MCP tool. It retrieves accounts from the YNAB API for the given budget_id, filters out closed/deleted ones, formats them into asset/liability groups with totals and net worth summary, and returns a formatted Markdown report including tables per account type.
    @mcp.tool()
    async def get_accounts(budget_id: str) -> str:
        """List all YNAB accounts in a specific budget in Markdown format."""
        async with await get_ynab_client() as client:
            accounts_api = AccountsApi(client)
            all_accounts: List[Dict[str, Any]] = []
            response = accounts_api.get_accounts(budget_id)
            for account in response.data.accounts:
                if isinstance(account, Account):
                    all_accounts.append(account.to_dict())
    
            formatted = _format_accounts_output(all_accounts)
    
            markdown = "# YNAB Account Summary\n\n"
            markdown += "## Summary\n"
            markdown += f"- **Total Assets:** {formatted['summary']['total_assets']}\n"
            markdown += f"- **Total Liabilities:** {formatted['summary']['total_liabilities']}\n"
            markdown += f"- **Net Worth:** {formatted['summary']['net_worth']}\n\n"
    
            for group in formatted["accounts"]:
                markdown += f"## {group['type']}\n"
                markdown += f"**Group Total:** {group['total']}\n\n"
    
                rows = []
                for acct in group["accounts"]:
                    rows.append([acct["name"], acct["balance"], acct["id"]])
    
                markdown += _build_markdown_table(
                    rows, ["Account Name", "Balance", "ID"], ["left", "right", "left"]
                )
                markdown += "\n"
    
            return markdown
  • Supporting helper function that processes raw account data from YNAB API, groups by type, skips closed/deleted accounts, sorts by balance magnitude, categorizes into assets/liabilities, computes group and overall totals/net worth, and structures data for Markdown rendering.
    def _format_accounts_output(accounts: List[Dict[str, Any]]) -> Dict[str, Any]:
        """Format account data into a user-friendly structure."""
        account_groups: Dict[str, List[Dict[str, Any]]] = {}
        type_order = [
            "checking",
            "savings",
            "creditCard",
            "mortgage",
            "autoLoan",
            "studentLoan",
            "otherAsset",
            "otherLiability",
        ]
    
        type_display_names = {
            "checking": "Checking Accounts",
            "savings": "Savings Accounts",
            "creditCard": "Credit Cards",
            "mortgage": "Mortgages",
            "autoLoan": "Auto Loans",
            "studentLoan": "Student Loans",
            "otherAsset": "Other Assets",
            "otherLiability": "Other Liabilities",
        }
    
        for account in accounts:
            if account.get("closed", False) or account.get("deleted", False):
                continue
    
            acct_type = account["type"]
            if acct_type not in account_groups:
                account_groups[acct_type] = []
    
            balance = float(account["balance"]) / 1000
            account_groups[acct_type].append(
                {
                    "name": account["name"],
                    "balance": f"${balance:,.2f}",
                    "balance_raw": balance,
                    "id": account["id"],
                }
            )
    
        for group in account_groups.values():
            group.sort(key=lambda x: abs(x["balance_raw"]), reverse=True)
    
        output: Dict[str, Any] = {
            "accounts": [],
            "summary": {
                "total_assets": 0.0,
                "total_liabilities": 0.0,
                "net_worth": 0.0,
            },
        }
    
        for acct_type in type_order:
            if acct_type in account_groups and account_groups[acct_type]:
                group_data = {
                    "type": type_display_names.get(acct_type, acct_type),
                    "accounts": account_groups[acct_type],
                }
                group_total = sum(acct["balance_raw"] for acct in account_groups[acct_type])
                group_data["total"] = f"${group_total:,.2f}"
    
                if acct_type in ["checking", "savings", "otherAsset"]:
                    output["summary"]["total_assets"] += group_total
                elif acct_type in [
                    "creditCard",
                    "mortgage",
                    "autoLoan",
                    "studentLoan",
                    "otherLiability",
                ]:
                    output["summary"]["total_liabilities"] += abs(group_total)
    
                output["accounts"].append(group_data)
    
        output["summary"]["net_worth_raw"] = (
            output["summary"]["total_assets"] - output["summary"]["total_liabilities"]
        )
        output["summary"]["total_assets"] = f"${output['summary']['total_assets']:,.2f}"
        output["summary"]["total_liabilities"] = f"${output['summary']['total_liabilities']:,.2f}"
        output["summary"]["net_worth"] = f"${output['summary']['net_worth_raw']:,.2f}"
    
        return output
  • The @mcp.tool() decorator registers the get_accounts function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden but only mentions output format ('Markdown format'). It doesn't disclose critical behavioral traits such as whether this is a read-only operation, potential rate limits, authentication needs, or what happens if the budget_id is invalid. The mention of Markdown format adds some value but leaves significant gaps.

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 action and resource. There is no wasted verbiage, and it directly communicates the tool's function without unnecessary elaboration.

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?

Given no annotations, no output schema, and a single parameter with 0% schema coverage, the description is incomplete. It lacks details on behavioral traits, error handling, output structure beyond format, and usage context relative to siblings, making it inadequate for a tool with potential complexity in data retrieval.

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 0%, but the description adds context by specifying 'in a specific budget', which implies the 'budget_id' parameter is required for scoping. However, it doesn't provide details on parameter format, validation, or examples, leaving the schema to define the parameter fully.

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 action ('List all') and resource ('YNAB accounts in a specific budget'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_account_balance', which might retrieve similar data but with different scope or format.

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 guidance is provided on when to use this tool versus alternatives like 'get_account_balance' or 'get_transactions'. The description mentions a specific budget context but doesn't clarify prerequisites, exclusions, or comparative use cases with sibling tools.

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