Skip to main content
Glama
whitebirchio

Monarch Money MCP Server

by whitebirchio

get_spending_by_category

Analyze spending patterns by category within a specified date range to track expenses and identify budget trends.

Instructions

Get spending breakdown by category for a specific time period

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startDateYesStart date in YYYY-MM-DD format
endDateYesEnd date in YYYY-MM-DD format

Implementation Reference

  • The actual implementation of get_spending_by_category that fetches transactions, filters for expenses (negative amounts), groups spending by category, sorts by amount descending, and returns the spending breakdown with totals.
    private async getSpendingByCategory(
      startDate: string,
      endDate: string
    ): Promise<any> {
      try {
        const transactions = await this.api.getTransactions({
          startDate,
          endDate,
          limit: 5000,
        });
    
        const categorySpending: Record<string, number> = {};
    
        transactions?.forEach((transaction: Transaction) => {
          if (transaction.amount < 0) {
            // Expenses are negative
            const category = transaction.category?.name || 'Uncategorized';
            categorySpending[category] =
              (categorySpending[category] || 0) + Math.abs(transaction.amount);
          }
        });
    
        const sortedCategories = Object.entries(categorySpending)
          .sort(([, a], [, b]) => b - a)
          .map(([category, amount]) => ({ category, amount }));
    
        return {
          success: true,
          data: sortedCategories,
          summary: `Spending breakdown for ${
            Object.keys(categorySpending).length
          } categories from ${startDate} to ${endDate}`,
          totalSpent: Object.values(categorySpending).reduce(
            (sum, amount) => sum + amount,
            0
          ),
        };
      } catch (error) {
        throw new Error(
          `Failed to get spending by category: ${
            error instanceof Error ? error.message : 'Unknown error'
          }`
        );
      }
    }
  • Tool schema definition for get_spending_by_category, including name, description, and inputSchema with required startDate and endDate parameters (YYYY-MM-DD format).
    {
      name: 'get_spending_by_category',
      description:
        'Get spending breakdown by category for a specific time period',
      inputSchema: {
        type: 'object',
        properties: {
          startDate: {
            type: 'string',
            description: 'Start date in YYYY-MM-DD format',
          },
          endDate: {
            type: 'string',
            description: 'End date in YYYY-MM-DD format',
          },
        },
        required: ['startDate', 'endDate'],
      },
    },
  • src/tools.ts:215-216 (registration)
    Switch case registration in executeTool method that routes 'get_spending_by_category' tool calls to the getSpendingByCategory implementation with startDate and endDate arguments.
    case 'get_spending_by_category':
      return await this.getSpendingByCategory(args.startDate, args.endDate);
Behavior2/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 states what the tool does but doesn't mention any behavioral traits such as whether it's read-only, requires authentication, has rate limits, or what the output format might be. This leaves significant gaps for an AI agent to understand how to interact with it effectively.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core functionality, making it easy to parse quickly, which is ideal for conciseness.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the spending breakdown includes (e.g., categories, amounts), how results are returned, or any prerequisites, making it inadequate for a tool that likely returns complex financial data without further context.

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 description adds minimal value beyond the input schema, which has 100% coverage with clear descriptions for both parameters. It implies date-range filtering ('for a specific time period') but doesn't provide additional context like date format requirements or handling of invalid ranges, so it meets the baseline for high schema coverage.

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 with a specific verb ('Get') and resource ('spending breakdown by category'), making it immediately understandable. However, it doesn't explicitly differentiate this tool from its siblings like 'get_budget_summary' or 'get_monthly_summary', which might also provide financial breakdowns, 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 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. It mentions a 'specific time period' but doesn't clarify if this is for historical analysis, budgeting, or other contexts, nor does it reference sibling tools like 'get_budget_summary' or 'get_transactions' that might serve similar purposes.

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/whitebirchio/monarch-mcp'

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