Skip to main content
Glama
WGDevelopment

YNAB MCP Server

ynab_update_transaction

Idempotent

Update an existing transaction by providing a transaction ID and any fields to change: amount, date, payee, category, memo, cleared status, or approval.

Instructions

Update an existing transaction. Only specified fields will be updated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async function that handles the 'ynab_update_transaction' tool. It builds an updates dict from optional fields, converts dollars to milliunits if amount is provided, calls client.update_transaction(), and returns a formatted result string.
    async def ynab_update_transaction(params: UpdateTransactionInput) -> str:
        """Update an existing transaction. Only specified fields will be updated."""
        try:
            updates = {}
            
            if params.amount is not None:
                updates["amount"] = dollars_to_milliunits(params.amount)
            if params.date is not None:
                updates["date"] = params.date
            if params.payee_name is not None:
                updates["payee_name"] = params.payee_name
            if params.category_id is not None:
                updates["category_id"] = params.category_id
            if params.memo is not None:
                updates["memo"] = params.memo
            if params.cleared is not None:
                updates["cleared"] = params.cleared.value
            if params.approved is not None:
                updates["approved"] = params.approved
            
            if not updates:
                return "Error: No fields to update. Specify at least one field to change."
            
            async with YNABClient() as client:
                transaction = await client.update_transaction(
                    params.budget_id,
                    params.transaction_id,
                    **updates,
                )
            
            result = "## Transaction Updated\n\n"
            result += f"- **ID**: `{transaction['id']}`\n"
            result += f"- **Date**: {transaction['date']}\n"
            result += f"- **Amount**: {format_currency(transaction['amount'])}\n"
            result += f"- **Payee**: {transaction.get('payee_name', 'N/A')}\n"
            
            return result
        except Exception as e:
            return format_error(e)
  • The @mcp.tool() decorator that registers 'ynab_update_transaction' as an MCP tool with annotations for title, readOnlyHint, destructiveHint, idempotentHint, and openWorldHint.
    @mcp.tool(
        name="ynab_update_transaction",
        annotations={
            "title": "Update Transaction",
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False,
        }
  • Pydantic model UpdateTransactionInput defining the schema for the tool's input parameters: transaction_id (required), plus optional fields amount, date, payee_name, category_id, memo, cleared, approved. Extends BudgetIdInput which provides budget_id.
    class UpdateTransactionInput(BudgetIdInput):
        """Input for updating an existing transaction."""
        transaction_id: str = Field(..., description="The transaction ID to update")
        amount: Optional[float] = Field(default=None, description="New amount in dollars")
        date: Optional[str] = Field(default=None, description="New date (YYYY-MM-DD)", pattern=r"^\d{4}-\d{2}-\d{2}$")
        payee_name: Optional[str] = Field(default=None, description="New payee name", max_length=200)
        category_id: Optional[str] = Field(default=None, description="New category ID")
        memo: Optional[str] = Field(default=None, description="New memo", max_length=500)
        cleared: Optional[ClearedStatus] = Field(default=None, description="New cleared status")
        approved: Optional[bool] = Field(default=None, description="New approved status")
  • ClearedStatus enum used by the schema, with values CLEARED='cleared', UNCLEARED='uncleared', RECONCILED='reconciled'.
    class ClearedStatus(str, Enum):
        """Transaction cleared status."""
        CLEARED = "cleared"
        UNCLEARED = "uncleared"
        RECONCILED = "reconciled"
  • Helper function dollars_to_milliunits used in the handler to convert dollar amounts to YNAB milliunits (1000 milliunits = $1.00).
    def dollars_to_milliunits(dollars: float) -> int:
        """Convert dollars to YNAB milliunits (1000 milliunits = $1.00)."""
        return int(round(dollars * 1000))
Behavior4/5

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

The description adds the behavioral detail that only specified fields will be updated, which is beyond the annotations (readOnlyHint=false, idempotentHint=true). This helps the agent understand partial update semantics.

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 two short sentences, front-loaded with purpose and behavioral constraint. No extraneous words.

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 an output schema exists (not shown) and annotations are present, the description covers the essential behavior. It could mention prerequisites or error cases, but for a partial update tool, it is complete enough.

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 input schema has high coverage with descriptions for each parameter. The description does not add new parameter info beyond 'only specified fields will be updated', which reinforces the nullable defaults. Baseline 3 is appropriate.

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 action 'update' and the resource 'existing transaction'. It also specifies 'Only specified fields will be updated', which distinguishes it from create and full-replace operations. Among siblings like ynab_create_transaction and ynab_get_transactions, this is distinct.

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 when to use (when modifying an existing transaction) and, with sibling names, it is clear it updates rather than creates or reads. However, no explicit when-not-to-use or alternatives 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/WGDevelopment/ynab-mcp-server'

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