Skip to main content
Glama

cache_categories

Store all YNAB categories for a specific budget ID using the Model Context Protocol, enabling efficient access and management of budget data.

Instructions

Cache all categories for a given YNAB budget ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes

Implementation Reference

  • The handler function for the 'cache_categories' MCP tool. It fetches all categories from the YNAB API for the given budget_id and caches them using the helper method. Registered via @mcp.tool() decorator.
    @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}"
  • Helper method in the YNABResources class that persists the categories to a JSON cache file for the specified budget_id.
    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)

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/Meh-S-Eze/ynab-mcp-client2'

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