Skip to main content
Glama
dgalarza

YNAB MCP Server

by dgalarza

get_categories

Retrieve all budget categories and groups from your YNAB budget to manage spending targets and track financial allocations.

Instructions

Get all categories for a budget.

Args:
    budget_id: The ID of the budget (use 'last-used' for default budget)
    include_hidden: Include hidden categories and groups (default: False)

Returns:
    JSON string with category groups and categories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes
include_hiddenNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler and registration for get_categories. Decorated with @mcp.tool(), delegates to YNABClient.get_categories(budget_id, include_hidden), formats result as indented JSON string.
    @mcp.tool()
    async def get_categories(budget_id: str, include_hidden: bool = False) -> str:
        """Get all categories for a budget.
    
        Args:
            budget_id: The ID of the budget (use 'last-used' for default budget)
            include_hidden: Include hidden categories and groups (default: False)
    
        Returns:
            JSON string with category groups and categories
        """
        client = get_ynab_client()
        result = await client.get_categories(budget_id, include_hidden)
        return json.dumps(result, indent=2)
  • Core helper method in YNABClient that implements the get_categories logic: calls YNAB SDK, filters out hidden/deleted categories and groups unless include_hidden=True, structures response as list of category groups with categories.
    async def get_categories(
        self, budget_id: str, include_hidden: bool = False
    ) -> list[dict[str, Any]]:
        """Get all categories for a budget.
    
        Args:
            budget_id: The budget ID or 'last-used'
            include_hidden: Include hidden categories and groups (default: False)
    
        Returns:
            List of category dictionaries grouped by category groups
        """
        try:
            response = self.client.categories.get_categories(budget_id)
            category_groups = []
    
            for group in response.data.category_groups:
                categories = []
                for category in group.categories:
                    # Skip hidden and deleted categories unless requested
                    if not include_hidden and (category.hidden or category.deleted):
                        continue
    
                    categories.append(
                        {
                            "id": category.id,
                            "name": category.name,
                            "balance": category.balance / 1000 if category.balance else 0,
                            "hidden": category.hidden,
                        }
                    )
    
                # Skip hidden groups unless requested, and skip empty groups
                if (not include_hidden and group.hidden) or not categories:
                    continue
    
                category_groups.append(
                    {
                        "id": group.id,
                        "name": group.name,
                        "hidden": group.hidden,
                        "categories": categories,
                    }
                )
    
            return category_groups
        except Exception as e:
            raise Exception(f"Failed to get categories: {e}") from e
Behavior3/5

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

With no annotations provided, the description carries the full burden. It implies a read operation ('Get') and specifies return format ('JSON string with category groups and categories'), but lacks details on permissions, rate limits, or error handling. It adds some behavioral context but is incomplete 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.

Conciseness5/5

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

The description is well-structured with a brief purpose statement followed by clear sections for Args and Returns. Every sentence adds value, with no redundant or unnecessary information, making it efficient and easy to parse.

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

Completeness4/5

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

Given the tool's moderate complexity (2 parameters, no annotations, but has output schema), the description is fairly complete. It covers purpose, parameters, and return format, but lacks usage guidelines and some behavioral details like error cases or performance considerations, which would enhance completeness further.

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 description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'budget_id' can use 'last-used' for default budget and clarifies the default and purpose of 'include_hidden'. This compensates fully for the schema's lack of descriptions, providing clear parameter semantics.

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 ('Get all categories') and resource ('for a budget'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'get_category' (singular) or 'update_category', leaving some ambiguity about when to use this versus those alternatives.

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 such as 'get_category' (for a single category) or 'update_category'. It mentions the 'budget_id' parameter but doesn't explain context like whether this is for viewing, editing, or other purposes relative to siblings.

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