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);

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