Skip to main content
Glama
dgalarza

YNAB MCP Server

by dgalarza

get_transaction

Retrieve detailed information for a specific YNAB transaction, including subtransactions for split transactions, using budget and transaction IDs.

Instructions

Get a single transaction with all details including subtransactions.

Args:
    budget_id: The ID of the budget (use 'last-used' for default budget)
    transaction_id: The ID of the transaction to retrieve

Returns:
    JSON string with the transaction details including subtransactions if it's a split transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYes
transaction_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function registered with @mcp.tool(). Wraps YNABClient.get_transaction and serializes result to JSON string.
    @mcp.tool()
    async def get_transaction(budget_id: str, transaction_id: str) -> str:
        """Get a single transaction with all details including subtransactions.
    
        Args:
            budget_id: The ID of the budget (use 'last-used' for default budget)
            transaction_id: The ID of the transaction to retrieve
    
        Returns:
            JSON string with the transaction details including subtransactions if it's a split transaction
        """
        client = get_ynab_client()
        result = await client.get_transaction(budget_id, transaction_id)
        return json.dumps(result, indent=2)
  • Supporting method in YNABClient that performs the actual API call to retrieve a single transaction by ID, formats response including subtransactions, and handles errors.
    async def get_transaction(
        self,
        budget_id: str,
        transaction_id: str,
    ) -> dict[str, Any]:
        """Get a single transaction with all details including subtransactions.
    
        Args:
            budget_id: The budget ID or 'last-used'
            transaction_id: The transaction ID to retrieve
    
        Returns:
            Transaction dictionary with full details
        """
        try:
            url = f"{self.api_base_url}/budgets/{budget_id}/transactions/{transaction_id}"
            result = await self._make_request_with_retry("get", url)
    
            txn = result["data"]["transaction"]
    
            # Format subtransactions if present
            subtransactions = []
            if txn.get("subtransactions"):
                for sub in txn["subtransactions"]:
                    subtransactions.append(
                        {
                            "id": sub.get("id"),
                            "amount": sub["amount"] / MILLIUNITS_FACTOR if sub.get("amount") else 0,
                            "memo": sub.get("memo"),
                            "payee_id": sub.get("payee_id"),
                            "payee_name": sub.get("payee_name"),
                            "category_id": sub.get("category_id"),
                            "category_name": sub.get("category_name"),
                        }
                    )
    
            return {
                "id": txn["id"],
                "date": txn["date"],
                "amount": txn["amount"] / MILLIUNITS_FACTOR if txn.get("amount") else 0,
                "memo": txn.get("memo"),
                "cleared": txn.get("cleared"),
                "approved": txn.get("approved"),
                "account_id": txn.get("account_id"),
                "account_name": txn.get("account_name"),
                "payee_id": txn.get("payee_id"),
                "payee_name": txn.get("payee_name"),
                "category_id": txn.get("category_id"),
                "category_name": txn.get("category_name"),
                "transfer_account_id": txn.get("transfer_account_id"),
                "subtransactions": subtransactions if subtransactions else None,
            }
        except Exception as e:
            raise Exception(f"Failed to get transaction: {e}") from e
  • @mcp.tool() decorator registers the get_transaction function as an MCP tool.
    @mcp.tool()
Behavior3/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 discloses that it retrieves details including subtransactions and returns JSON, but doesn't cover behavioral aspects like error handling, permissions, rate limits, or whether it's a read-only operation (implied by 'Get' but not stated). It adds some value but has gaps for a tool with no annotations.

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, followed by clear sections for Args and Returns. Every sentence adds value, with no wasted words, making it efficient and easy to parse.

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 2 parameters with 0% schema coverage and an output schema exists, the description is reasonably complete. It explains the parameters and return format (JSON with transaction details), compensating for the lack of schema descriptions. However, as a read operation with no annotations, it could benefit from more behavioral context like error cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/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 adds meaning by explaining both parameters: 'budget_id' includes the special value 'last-used', and 'transaction_id' specifies it's for retrieval. This provides useful semantics beyond the bare schema, though it doesn't detail format constraints or examples.

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 tool's purpose: 'Get a single transaction with all details including subtransactions.' It specifies the verb ('Get') and resource ('transaction'), but doesn't explicitly differentiate from sibling tools like 'get_transactions' (plural) or 'search_transactions' beyond mentioning 'single transaction'.

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 for retrieving a specific transaction by ID, but doesn't explicitly state when to use this vs. alternatives like 'get_transactions' (for multiple) or 'search_transactions' (for filtering). The mention of 'single transaction' provides some context, but lacks explicit guidance on exclusions or prerequisites.

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