Skip to main content
Glama
klauern

MCP YNAB Server

by klauern

cache_categories

Store YNAB budget categories locally to reduce API calls and improve data access speed for financial tracking.

Instructions

Cache all categories for a given YNAB budget ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes

Implementation Reference

  • The handler function for the MCP tool 'cache_categories'. It fetches all categories from the YNAB API for the specified budget_id and caches them using the YNABResources.cache_categories helper method. The @mcp.tool() decorator registers this function as an MCP tool.
    @mcp.tool()
    async def cache_categories(budget_id: str) -> str:
        """Cache all categories for a given YNAB budget ID."""
        async with await get_ynab_client() as client:
            categories_api = CategoriesApi(client)
            response = categories_api.get_categories(budget_id)
            groups = response.data.category_groups
            categories = []
            for group in groups:
                if isinstance(group, CategoryGroupWithCategories):
                    categories.extend(group.categories)
    
            ynab_resources.cache_categories(budget_id, [cat.to_dict() for cat in categories])
            return f"Categories cached for budget ID {budget_id}"
  • Supporting helper method in the YNABResources class that stores the provided categories in a JSON cache file (BUDGET_CATEGORY_CACHE_FILE) for later retrieval via the 'ynab://categories/{budget_id}' MCP resource.
    def cache_categories(self, budget_id: str, categories: List[Dict[str, Any]]) -> None:
        """Cache categories for a budget ID."""
        self._category_cache[budget_id] = [
            {
                "id": cat.get("id"),
                "name": cat.get("name"),
                "group": cat.get("category_group_name"),
            }
            for cat in categories
        ]
        _save_json_file(BUDGET_CATEGORY_CACHE_FILE, self._category_cache)
  • The @mcp.tool() decorator registers the cache_categories 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 the full burden of behavioral disclosure. It mentions 'Cache all categories', implying a write or update operation to store data, but doesn't specify what caching entails—e.g., whether it overwrites existing cache, requires permissions, or has side effects like rate limits. This leaves key behavioral traits unclear for a tool that likely modifies state.

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 directly states the tool's purpose without unnecessary words. It's front-loaded and appropriately sized for a simple tool, making it easy to parse quickly.

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 the tool's complexity (likely a write operation for caching), lack of annotations, no output schema, and minimal parameter details, the description is incomplete. It doesn't cover what caching means, the expected outcome, error conditions, or how it differs from sibling tools, leaving significant gaps for effective use.

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?

The description adds minimal semantics beyond the input schema: it clarifies that 'budget_id' is for a YNAB budget, but with 0% schema description coverage, it doesn't explain the parameter's format, constraints, or examples. Since there's only one parameter, the baseline is 4, but the lack of detailed compensation for the coverage gap reduces the score.

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 ('Cache all categories') and the target resource ('for a given YNAB budget ID'), making the purpose understandable. However, it doesn't distinguish this tool from its sibling 'get_categories', which appears to retrieve categories without caching, leaving some ambiguity about when to use one versus the other.

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 like 'get_categories'. It doesn't mention prerequisites, such as whether the budget ID must be valid or accessible, or any context for caching behavior, leaving the agent with minimal usage direction.

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