Skip to main content
Glama
dgalarza

YNAB MCP Server

by dgalarza

update_category_budget

Modify the budgeted amount for a YNAB category in a specific month to adjust your financial planning and maintain accurate budget tracking.

Instructions

Update the budgeted amount for a category in a specific month.

Args:
    budget_id: The ID of the budget (use 'last-used' for default budget)
    month: Month in YYYY-MM-DD format (e.g., 2025-01-01 for January 2025)
    category_id: The category ID to update
    budgeted: The budgeted amount to set

Returns:
    JSON string with the updated category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes
budgetedYes
category_idYes
monthYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function decorated with @mcp.tool(), which registers the tool and executes by calling the YNABClient method.
    @mcp.tool()
    async def update_category_budget(
        budget_id: str,
        month: str,
        category_id: str,
        budgeted: float,
    ) -> str:
        """Update the budgeted amount for a category in a specific month.
    
        Args:
            budget_id: The ID of the budget (use 'last-used' for default budget)
            month: Month in YYYY-MM-DD format (e.g., 2025-01-01 for January 2025)
            category_id: The category ID to update
            budgeted: The budgeted amount to set
    
        Returns:
            JSON string with the updated category
        """
        client = get_ynab_client()
        result = await client.update_category_budget(budget_id, month, category_id, budgeted)
        return json.dumps(result, indent=2)
  • Core helper method in YNABClient class that performs the actual YNAB API PATCH request to update the category's budgeted amount for the specified month.
    async def update_category_budget(
        self,
        budget_id: str,
        month: str,
        category_id: str,
        budgeted: float,
    ) -> dict[str, Any]:
        """Update the budgeted amount for a category in a specific month.
    
        Uses direct API calls since ynab-sdk is read-only.
    
        Args:
            budget_id: The budget ID or 'last-used'
            month: Month in YYYY-MM-DD format (e.g., 2025-01-01)
            category_id: The category ID to update
            budgeted: The budgeted amount to set
    
        Returns:
            Updated category dictionary
        """
        try:
            url = f"{self.api_base_url}/budgets/{budget_id}/months/{month}/categories/{category_id}"
            data = {
                "category": {
                    "budgeted": int(budgeted * 1000)  # Convert to milliunits
                }
            }
    
            result = await self._make_request_with_retry("patch", url, json=data)
    
            cat = result["data"]["category"]
            return {
                "id": cat["id"],
                "name": cat["name"],
                "budgeted": cat["budgeted"] / 1000 if cat["budgeted"] else 0,
                "activity": cat["activity"] / 1000 if cat["activity"] else 0,
                "balance": cat["balance"] / 1000 if cat["balance"] else 0,
            }
        except Exception as e:
            raise Exception(f"Failed to update category budget: {e}") from e
  • The @mcp.tool() decorator registers this function as an MCP tool.
    @mcp.tool()
    async def update_category_budget(
        budget_id: str,
        month: str,
        category_id: str,
        budgeted: float,
    ) -> str:
        """Update the budgeted amount for a category in a specific month.
    
        Args:
            budget_id: The ID of the budget (use 'last-used' for default budget)
            month: Month in YYYY-MM-DD format (e.g., 2025-01-01 for January 2025)
            category_id: The category ID to update
            budgeted: The budgeted amount to set
    
        Returns:
            JSON string with the updated category
        """
        client = get_ynab_client()
        result = await client.update_category_budget(budget_id, month, category_id, budgeted)
        return json.dumps(result, indent=2)
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states this is an update operation but does not disclose behavioral traits such as permission requirements, whether the update is idempotent, error handling for invalid inputs, or side effects. The description adds minimal context beyond the basic action.

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 in the first sentence. The Args and Returns sections are organized efficiently with no redundant information. Every sentence earns its place by clarifying parameters or output.

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 4 parameters with 0% schema coverage and an output schema (implied by 'Returns: JSON string'), the description is mostly complete. It covers all parameters semantically and notes the return type. However, as a mutation tool with no annotations, it lacks behavioral context like error conditions or side effects, which slightly reduces completeness.

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?

Schema description coverage is 0%, so the description must compensate. It provides clear semantics for all 4 parameters: explains 'budget_id' accepts 'last-used' as a special value, specifies 'month' format (YYYY-MM-DD with example), identifies 'category_id' as the target, and defines 'budgeted' as the amount to set. This adds significant value beyond the bare schema.

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 specific action ('Update the budgeted amount'), target resource ('for a category in a specific month'), and scope. It distinguishes from sibling tools like 'update_category' (which likely updates category metadata) and 'move_category_funds' (which transfers funds between categories).

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

Usage Guidelines3/5

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

The description implies usage context through the parameter explanations (e.g., 'use 'last-used' for default budget'), but does not explicitly state when to use this tool versus alternatives like 'update_category' or 'move_category_funds'. No explicit exclusions or prerequisites are mentioned.

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