Skip to main content
Glama
dgalarza

YNAB MCP Server

by dgalarza

get_category

Retrieve detailed category information from YNAB including goals, budgeted amounts, activity, and balance for specific budget categories to analyze spending patterns and track financial progress.

Instructions

Get a single category with full details including goal information.

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

Returns:
    JSON string with category details including goals, budgeted amounts, activity, and balance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes
category_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for get_category. Decorated with @mcp.tool() for automatic registration and schema derivation from signature/docstring. Delegates to YNABClient.get_category and returns JSON.
    @mcp.tool()
    async def get_category(budget_id: str, category_id: str) -> str:
        """Get a single category with full details including goal information.
    
        Args:
            budget_id: The ID of the budget (use 'last-used' for default budget)
            category_id: The category ID
    
        Returns:
            JSON string with category details including goals, budgeted amounts, activity, and balance
        """
        client = get_ynab_client()
        result = await client.get_category(budget_id, category_id)
        return json.dumps(result, indent=2)
  • Core implementation in YNABClient that fetches single category via YNAB API GET /budgets/{budget_id}/categories/{category_id}, processes response with goal details, converts milliunits, and returns structured dict.
    async def get_category(self, budget_id: str, category_id: str) -> dict[str, Any]:
        """Get a single category with all details including goal information.
    
        Args:
            budget_id: The budget ID or 'last-used'
            category_id: The category ID
    
        Returns:
            Category dictionary with full details
    
        Raises:
            YNABValidationError: If parameters are invalid
            YNABAPIError: If API request fails
        """
        logger.debug(f"Getting category {category_id} for budget {budget_id}")
    
        # Validate inputs
        budget_id = validate_budget_id(budget_id)
    
        url = f"{self.api_base_url}/budgets/{budget_id}/categories/{category_id}"
        result = await self._make_request_with_retry("get", url)
    
        cat = result["data"]["category"]
    
        return {
            "id": cat["id"],
            "name": cat["name"],
            "category_group_id": cat.get("category_group_id"),
            "hidden": cat.get("hidden"),
            "note": cat.get("note"),
            "budgeted": cat.get("budgeted", 0) / MILLIUNITS_FACTOR if cat.get("budgeted") else 0,
            "activity": cat.get("activity", 0) / MILLIUNITS_FACTOR if cat.get("activity") else 0,
            "balance": cat.get("balance", 0) / MILLIUNITS_FACTOR if cat.get("balance") else 0,
            "goal_type": cat.get("goal_type"),
            "goal_target": cat.get("goal_target", 0) / MILLIUNITS_FACTOR
            if cat.get("goal_target")
            else 0,
            "goal_target_month": cat.get("goal_target_month"),
            "goal_percentage_complete": cat.get("goal_percentage_complete"),
            "goal_months_to_budget": cat.get("goal_months_to_budget"),
            "goal_under_funded": cat.get("goal_under_funded", 0) / MILLIUNITS_FACTOR
            if cat.get("goal_under_funded")
            else 0,
            "goal_overall_funded": cat.get("goal_overall_funded", 0) / MILLIUNITS_FACTOR
            if cat.get("goal_overall_funded")
            else 0,
            "goal_overall_left": cat.get("goal_overall_left", 0) / MILLIUNITS_FACTOR
            if cat.get("goal_overall_left")
            else 0,
        }
  • The @mcp.tool() decorator registers the get_category function as an MCP tool.
    @mcp.tool()
  • Tool schema derived from function signature (budget_id: str, category_id: str -> str) and docstring describing parameters and return value.
    """Get a single category with full details including goal information.
    
    Args:
        budget_id: The ID of the budget (use 'last-used' for default budget)
        category_id: The category ID
    
    Returns:
        JSON string with category details including goals, budgeted amounts, activity, and balance
    """
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 of behavioral disclosure. It indicates this is a read operation ('Get') and specifies the return format as a JSON string with details like goals and balance, which is helpful. However, it lacks information on error handling, authentication needs, rate limits, or whether the operation is idempotent, leaving gaps in behavioral context.

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 and front-loaded with the core purpose, followed by clear sections for Args and Returns. Each sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse for an AI agent.

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 with an output schema), the description is mostly complete. It covers the purpose, parameter semantics, and return format. However, it could improve by addressing behavioral aspects like error cases or prerequisites, though the output schema reduces the need to detail return values extensively.

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

Parameters4/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 the default budget, clarifying a key usage detail not in the schema. For 'category_id', it specifies retrieval of a single category, but does not elaborate on format or constraints, leaving some semantic gaps partially compensated.

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 clearly states the verb 'Get' and resource 'a single category with full details including goal information', making the purpose specific and actionable. It distinguishes from sibling tools like 'get_categories' (plural) by emphasizing retrieval of a single category with comprehensive details.

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

Usage Guidelines4/5

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

The description implies usage for retrieving detailed information about a specific category, which is clear from the context. However, it does not explicitly state when to use this tool versus alternatives like 'get_categories' for multiple categories or 'update_category' for modifications, leaving some guidance implicit rather than explicit.

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'

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