Skip to main content
Glama
WGDevelopment

YNAB MCP Server

ynab_get_accounts

Read-onlyIdempotent

Retrieve all accounts in a YNAB budget along with their current balances. Specify a budget ID or use 'last-used' for the most recent budget. Useful for checking account statuses.

Instructions

List all accounts in a budget with their current balances.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler for ynab_get_accounts tool. Fetches accounts from YNAB API for a given budget_id, groups them by type (filtering out deleted/closed), formats balances in currency, and returns a markdown summary with total balance.
    @mcp.tool(
        name="ynab_get_accounts",
        annotations={
            "title": "List Accounts",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False,
        }
    )
    async def ynab_get_accounts(params: GetAccountsInput) -> str:
        """List all accounts in a budget with their current balances."""
        try:
            async with YNABClient() as client:
                accounts = await client.get_accounts(params.budget_id)
            
            by_type = {}
            for a in accounts:
                if a.get("deleted") or a.get("closed"):
                    continue
                atype = a.get("type", "other")
                if atype not in by_type:
                    by_type[atype] = []
                by_type[atype].append(a)
            
            result = "## Accounts\n\n"
            total_balance = 0
            
            for atype, accts in by_type.items():
                result += f"### {atype.replace('_', ' ').title()}\n\n"
                for a in accts:
                    balance = a.get("balance", 0)
                    total_balance += balance
                    result += f"- **{a['name']}**: {format_currency(balance)}\n"
                    result += f"  - ID: `{a['id']}`\n"
                result += "\n"
            
            result += f"**Total Balance: {format_currency(total_balance)}**\n"
            return result
        except Exception as e:
            return format_error(e)
  • Input schema for ynab_get_accounts. Extends BudgetIdInput which provides a budget_id field (default 'last-used') with whitespace stripping.
    class GetAccountsInput(BudgetIdInput):
        """Input for listing accounts in a budget."""
        pass
  • Registers ynab_get_accounts as an MCP tool via @mcp.tool() decorator with read-only, idempotent annotations.
    @mcp.tool(
        name="ynab_get_accounts",
        annotations={
            "title": "List Accounts",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False,
        }
    )
  • API client method that calls YNAB's GET /budgets/{budget_id}/accounts endpoint and returns the accounts list.
    async def get_accounts(self, budget_id: str) -> List[Dict[str, Any]]:
        """Get all accounts for a budget."""
        response = await self._request("GET", f"/budgets/{budget_id}/accounts")
        return response["data"]["accounts"]
  • Base input schema inherited by GetAccountsInput, providing the budget_id field with 'last-used' default.
    class BudgetIdInput(BaseModel):
        """Base model with budget_id field."""
        model_config = ConfigDict(str_strip_whitespace=True)
        
        budget_id: str = Field(
            default="last-used",
            description="Budget ID or 'last-used' for the most recently accessed budget",
        )
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, which cover behavioral aspects. The description confirms the read-only nature but does not add extra traits such as auth requirements or rate limits.

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?

Single, front-loaded sentence with no extraneous information. Every word adds value.

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

Completeness3/5

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

Given the tool's simplicity and presence of an output schema, the description is adequate but lacks contextual hints about when to use this tool in a workflow (e.g., after getting budget IDs).

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

Parameters2/5

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

Schema coverage is 0%, meaning the description does not mention parameters. Although the schema itself documents budget_id well, the description fails to add any guidance on usage, leaving the agent to rely solely on schema.

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

Purpose5/5

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

The description explicitly states the tool lists all accounts with their current balances, clearly identifying the verb 'list' and resource 'accounts', and distinguishes from sibling tools like ynab_get_transactions or ynab_get_budgets.

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 on when to use this tool vs siblings (e.g., ynab_get_budgets, ynab_create_transaction). It does not mention that the budget_id is typically obtained from ynab_get_budgets first, nor any 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/WGDevelopment/ynab-mcp-server'

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