Skip to main content
Glama
dgalarza

YNAB MCP Server

by dgalarza

get_accounts

Retrieve all accounts associated with a specific YNAB budget to view account balances, types, and financial overview for budget management.

Instructions

Get all accounts for a budget.

Args:
    budget_id: The ID of the budget (use 'last-used' for default budget)

Returns:
    JSON string with list of accounts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'get_accounts'. Decorated with @mcp.tool() for automatic registration and execution. Fetches accounts using YNABClient and serializes to JSON.
    @mcp.tool()
    async def get_accounts(budget_id: str) -> str:
        """Get all accounts for a budget.
    
        Args:
            budget_id: The ID of the budget (use 'last-used' for default budget)
    
        Returns:
            JSON string with list of accounts
        """
        client = get_ynab_client()
        result = await client.get_accounts(budget_id)
        return json.dumps(result, indent=2)
  • Core implementation in YNABClient class. Calls YNAB SDK's get_accounts API, filters out deleted accounts, formats balances from milliunits, returns structured list of accounts.
    async def get_accounts(self, budget_id: str) -> list[dict[str, Any]]:
        """Get all accounts for a budget.
    
        Args:
            budget_id: The budget ID or 'last-used'
    
        Returns:
            List of account dictionaries
        """
        try:
            response = self.client.accounts.get_accounts(budget_id)
            accounts = []
    
            for account in response.data.accounts:
                # Skip deleted accounts
                if account.deleted:
                    continue
    
                accounts.append(
                    {
                        "id": account.id,
                        "name": account.name,
                        "type": account.type,
                        "on_budget": account.on_budget,
                        "closed": account.closed,
                        "balance": account.balance / 1000 if account.balance else 0,
                    }
                )
    
            return accounts
        except Exception as e:
            raise Exception(f"Failed to get accounts: {e}") from e
  • 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 for behavioral disclosure. It states it returns a JSON string with a list of accounts, which is helpful, but lacks critical details like whether this is a read-only operation, if it requires specific permissions, or if there are rate limits. This is inadequate for a tool with potential data access implications.

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

Conciseness4/5

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

The description is well-structured with a purpose statement followed by Args and Returns sections, making it easy to parse. It's concise with no wasted words, though the formatting could be slightly more polished (e.g., using bullet points).

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 has an output schema (which covers return values) and low complexity, the description is moderately complete. It explains the parameter well but lacks behavioral context and usage guidelines, making it sufficient for basic use but not fully informative for an agent navigating sibling tools.

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

Parameters5/5

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

The schema description coverage is 0%, so the description must compensate fully. It does so by clearly explaining the single parameter 'budget_id', including its purpose and a special value ('last-used' for default budget), adding significant meaning beyond the bare schema.

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 'Get' and resource 'accounts for a budget', making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_budget_summary' or 'get_categories', which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. There are multiple sibling tools for retrieving data (e.g., 'get_transactions', 'get_categories'), but no indication of when this specific tool is appropriate, leaving the agent to guess based on context.

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

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