Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

Get Unapproved Transactions

ynab_get_unapproved_transactions

Retrieve unapproved YNAB transactions for review, automatically fetching recent changes after initial setup to maintain budget oversight.

Instructions

Gets unapproved transactions from a budget. First time pulls last 3 days, subsequent pulls use server knowledge to get only changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budgetIdNoThe ID of the budget to fetch transactions for (optional, defaults to the budget set in the YNAB_BUDGET_ID environment variable)

Implementation Reference

  • The execute function that implements the tool's core logic: resolves budget ID, fetches unapproved transactions from YNAB API, filters and transforms data, returns formatted JSON response or error.
    export async function execute(input: GetUnapprovedTransactionsInput, api: ynab.API) {
      try {
        const budgetId = getBudgetId(input.budgetId);
    
        console.error(`Getting unapproved transactions for budget ${budgetId}`);
    
        const response = await api.transactions.getTransactions(
          budgetId,
          undefined,
          ynab.GetTransactionsTypeEnum.Unapproved
        );
    
        // Transform the transactions to a more readable format
        const transactions = response.data.transactions
          .filter((transaction) => !transaction.deleted)
          .map((transaction) => ({
            id: transaction.id,
            date: transaction.date,
            amount: (transaction.amount / 1000).toFixed(2), // Convert milliunits to actual currency
            memo: transaction.memo,
            approved: transaction.approved,
            account_name: transaction.account_name,
            payee_name: transaction.payee_name,
            category_name: transaction.category_name,
            transfer_account_id: transaction.transfer_account_id,
            transfer_transaction_id: transaction.transfer_transaction_id,
            matched_transaction_id: transaction.matched_transaction_id,
            import_id: transaction.import_id,
          }));
    
        return {
          content: [{ type: "text" as const, text: JSON.stringify({
            transactions,
            transaction_count: transactions.length,
          }, null, 2) }]
        };
      } catch (error) {
        console.error("Error getting unapproved transactions:", error);
        return {
          content: [{ type: "text" as const, text: JSON.stringify({
            success: false,
            error: getErrorMessage(error),
          }, null, 2) }]
        };
      }
    }
  • Tool metadata including name, description, and Zod input schema for optional budgetId parameter.
    export const name = "ynab_get_unapproved_transactions";
    export const description = "Gets unapproved transactions from a budget. First time pulls last 3 days, subsequent pulls use server knowledge to get only changes.";
    export const inputSchema = {
      budgetId: z.string().optional().describe("The ID of the budget to fetch transactions for (optional, defaults to the budget set in the YNAB_BUDGET_ID environment variable)"),
    };
  • src/index.ts:39-43 (registration)
    MCP server registration of the tool, specifying title, description, inputSchema, and handler wrapper calling the tool's execute function with YNAB API.
    server.registerTool(GetUnapprovedTransactionsTool.name, {
      title: "Get Unapproved Transactions",
      description: GetUnapprovedTransactionsTool.description,
      inputSchema: GetUnapprovedTransactionsTool.inputSchema,
    }, async (input) => GetUnapprovedTransactionsTool.execute(input, api));
  • Helper function to resolve and validate the budget ID from input parameter or YNAB_BUDGET_ID environment variable.
    function getBudgetId(inputBudgetId?: string): string {
      const budgetId = inputBudgetId || process.env.YNAB_BUDGET_ID || "";
      if (!budgetId) {
        throw new Error("No budget ID provided. Please provide a budget ID or set the YNAB_BUDGET_ID environment variable.");
      }
      return budgetId;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: it's a read operation ('Gets'), specifies the scope ('unapproved transactions'), and details the fetching behavior with time-based and incremental logic. This adds valuable context beyond basic functionality, though it could mention potential limitations like rate limits or error handling.

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 front-loaded with the core purpose in the first sentence, followed by a concise explanation of behavioral nuances in the second. Every sentence earns its place by providing essential information without redundancy, making it efficiently structured and appropriately sized.

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 the tool's moderate complexity (read operation with incremental fetching), no annotations, and no output schema, the description does a good job of covering key aspects: purpose, behavior, and usage context. It could be more complete by detailing the return format or error cases, but it's largely adequate for the agent to understand and invoke the tool correctly.

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 100% description coverage for its single parameter ('budgetId'), so the schema already documents it well. The description doesn't add any additional meaning or details about the parameter beyond what's in the schema, such as format examples or usage tips. Thus, it meets the baseline but doesn't enhance parameter understanding.

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 verb ('Gets') and resource ('unapproved transactions from a budget'), making the purpose specific and understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'ynab_get_transactions' or 'ynab_bulk_approve_transactions', which might also handle unapproved transactions, so it doesn't reach the highest score.

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 by mentioning 'first time pulls last 3 days, subsequent pulls use server knowledge to get only changes,' which suggests when to use it for initial vs. incremental fetching. However, it lacks explicit guidance on when to choose this tool over alternatives like 'ynab_get_transactions' or 'ynab_approve_transaction,' leaving some ambiguity.

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/calebl/ynab-mcp-server'

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