Skip to main content
Glama
calebl

YNAB MCP Server

by calebl

Budget Summary

ynab_budget_summary

Retrieve a monthly budget summary that identifies overspent categories requiring attention and highlights categories with positive balances.

Instructions

Get a summary of the budget for a specific month highlighting overspent categories that need attention and categories with a positive balance that are doing well.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budgetIdNoThe ID of the budget to get a summary for (optional, defaults to the budget set in the YNAB_BUDGET_ID environment variable)
monthNoThe budget month in ISO format (e.g. 2016-12-01). The string 'current' can also be used to specify the current calendar month (UTC)current

Implementation Reference

  • The main execute function that fetches accounts and budget month data from YNAB API and returns a summary with month budget details, active accounts, and a note about dividing by 1000 for dollar amounts.
    export async function execute(input: BudgetSummaryInput, api: ynab.API) {
      try {
        const budgetId = getBudgetId(input.budgetId);
        const month = input.month || "current";
    
        console.error(`Getting accounts and categories for budget ${budgetId} and month ${month}`);
        const accountsResponse = await api.accounts.getAccounts(budgetId);
        const accounts = accountsResponse.data.accounts.filter(
          (account) => account.deleted === false && account.closed === false
        );
    
        const monthBudget = await api.months.getBudgetMonth(budgetId, month);
    
        const categories = monthBudget.data.month.categories
          .filter(
            (category) => category.deleted === false && category.hidden === false
          );
    
        return {
          content: [{ type: "text" as const, text: JSON.stringify({
            monthBudget: monthBudget.data.month,
            accounts: accounts,
            note: "Divide all numbers by 1000 to get the balance in dollars.",
          }, null, 2) }]
        };
      } catch (error: unknown) {
        console.error("Error getting budget summary:", error);
        return {
          content: [{ type: "text" as const, text: JSON.stringify({
            success: false,
            error: getErrorMessage(error),
          }, null, 2) }]
        };
      }
    }
  • Exports: name='ynab_budget_summary', description, and inputSchema with optional budgetId and month (default 'current', accepts ISO date or 'current').
    export const name = "ynab_budget_summary";
    export const description = "Get a summary of the budget for a specific month highlighting overspent categories that need attention and categories with a positive balance that are doing well.";
    export const inputSchema = {
      budgetId: z.string().optional().describe("The ID of the budget to get a summary for (optional, defaults to the budget set in the YNAB_BUDGET_ID environment variable)"),
      month: z.string().regex(/^(current|\d{4}-\d{2}-\d{2})$/).default("current").describe("The budget month in ISO format (e.g. 2016-12-01). The string 'current' can also be used to specify the current calendar month (UTC)"),
    };
  • src/index.ts:45-49 (registration)
    Tool registration via server.registerTool using BudgetSummaryTool.name, description, inputSchema, and execute handler.
    server.registerTool(BudgetSummaryTool.name, {
      title: "Budget Summary",
      description: BudgetSummaryTool.description,
      inputSchema: BudgetSummaryTool.inputSchema,
    }, async (input) => BudgetSummaryTool.execute(input, api));
  • Helper function getBudgetId that resolves the budget ID from input or falls back to YNAB_BUDGET_ID env 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;
    }
  • getErrorMessage utility used to extract meaningful error messages from various error types including YNAB API errors.
    export function getErrorMessage(error: unknown): string {
      // Handle standard Error objects
      if (error instanceof Error) {
        return error.message;
      }
    
      // Handle YNAB API error responses which have the structure:
      // { error: { id: '...', name: '...', detail: '...' } }
      if (
        typeof error === 'object' &&
        error !== null &&
        'error' in error &&
        typeof (error as any).error === 'object'
      ) {
        const ynabError = (error as any).error;
        if (ynabError.detail) {
          return ynabError.detail;
        }
        if (ynabError.name) {
          return ynabError.name;
        }
      }
    
      // Fallback: try to stringify the error
      try {
        const stringified = JSON.stringify(error);
        if (stringified !== '{}') {
          return stringified;
        }
      } catch {
        // Ignore stringify errors
      }
    
      return 'Unknown error occurred';
    }
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 describes what the tool does (get summary) but does not explicitly state that it is read-only, nor does it disclose any behavioral traits like authentication needs, rate limits, or side effects. The term 'summary' suggests a read operation, but this is not confirmed.

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, well-structured sentence that clearly conveys the purpose without redundancy. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of output schema, the description should ideally hint at the return structure. It mentions 'highlighting overspent categories and positive balance categories', which provides some completeness, but lacks specifics on whether the summary is a text report, a list of categories, or a data object. For a tool with only 2 parameters and no annotations, this is adequate but not thorough.

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 coverage is 100%, so each parameter has a description. The tool description adds context that the summary is for a specific month, which aligns with the month parameter, but does not add semantic detail beyond the schema for budgetId (defaulting to env var) or month format. 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 'Get a summary of the budget for a specific month' with a specific verb and resource. It distinguishes from sibling tools by focusing on a consolidated summary highlighting overspent and positive categories, not listing transactions or accounts.

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 a monthly overview with overspent/positive categories but does not explicitly state when to use this tool versus alternatives like ynab_list_categories or ynab_get_transactions. No when-not or alternative guidance is provided.

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