Skip to main content
Glama
klauern

MCP YNAB Server

by klauern

create_transaction

Add new financial transactions to YNAB by specifying account, amount, payee, and optional details to maintain accurate budget tracking.

Instructions

Create a new transaction in YNAB.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
amountYesAmount in dollars
payee_nameYes
category_nameNo
memoNo

Implementation Reference

  • The @mcp.tool()-decorated 'create_transaction' function serves as the handler, registration, and schema definition for the MCP tool. It executes the logic to create a new transaction in YNAB by interacting with the YNAB API, resolving budget and category IDs, and formatting the request.
    @mcp.tool()
    async def create_transaction(
        account_id: str,
        amount: Annotated[float, Field(description="Amount in dollars")],
        payee_name: str,
        category_name: Optional[str] = None,
        memo: Optional[str] = None,
    ) -> Dict[str, Any]:
        """Create a new transaction in YNAB."""
        async with await get_ynab_client() as client:
            transactions_api = TransactionsApi(client)
            budgets_api = BudgetsApi(client)
    
            amount_milliunits = int(amount * 1000)
    
            # Use preferred budget ID if available, otherwise fetch a list of budgets
            budget_id = ynab_resources.get_preferred_budget_id()
            if not budget_id:
                budgets_response = budgets_api.get_budgets()
                budget_id = budgets_response.data.budgets[0].id
    
            category_id = None
            if category_name:
                category_id = await _find_category_id(client, budget_id, category_name)
    
            # Create transaction data
            transaction = NewTransaction(
                account_id=account_id,
                date=date.today(),
                amount=amount_milliunits,
                payee_name=payee_name,
                memo=memo,
                category_id=category_id,
            )
    
            wrapper = PostTransactionsWrapper(transaction=transaction)
            response = transactions_api.create_transaction(budget_id, wrapper)
            if response.data and response.data.transaction:
                return response.data.transaction.to_dict()
            return {}
  • Supporting helper function used by the create_transaction handler to find and return the category ID matching the provided category_name.
    async def _find_category_id(client: ApiClient, budget_id: str, category_name: str) -> Optional[str]:
        """Find a category ID by name."""
        categories_api = CategoriesApi(client)
        categories_response = categories_api.get_categories(budget_id)
        categories = categories_response.data.category_groups
        for group in categories:
            for cat in group.categories:
                if cat.name.lower() == category_name.lower():
                    return cat.id
        return None
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 of behavioral disclosure. While 'Create' implies a write/mutation operation, the description doesn't address critical aspects like authentication requirements, error handling, whether the transaction is immediately saved or pending, or what happens on success/failure. This leaves significant gaps for an agent to understand the tool's behavior.

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, clear sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and efficiently communicates the core function, making it easy for an agent 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 complexity of a transaction creation tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It lacks details on behavioral traits, parameter meanings beyond basic schema info, and expected outcomes. For a mutation tool with significant contextual needs, this description leaves too many gaps for effective agent 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?

Schema description coverage is low at 20%, with only the 'amount' parameter having a description ('Amount in dollars'). The tool description itself adds no parameter information beyond what's in the schema. However, the schema provides titles and types for all parameters, offering basic semantics. The description doesn't compensate for the low coverage, resulting in a baseline 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 ('Create') and resource ('new transaction in YNAB'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential sibling tools like '_find_transaction_by_id' or 'get_transactions', which would require mentioning this is specifically for creating new transactions rather than retrieving or modifying existing ones.

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. There are multiple sibling tools related to transactions (e.g., '_find_transaction_by_id', 'get_transactions'), but the description doesn't indicate this is for creation only or specify any prerequisites or contexts for its use.

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