Skip to main content
Glama
elcukro

bank-mcp

by elcukro

spending_summary

Group expenses by merchant or category with totals to reveal where money is spent. Specify date range and grouping preference for a clear spending breakdown.

Instructions

Group expenses by merchant or category with totals. Shows where money is being spent. Use groupBy "merchant" for vendor breakdown, "category" for category breakdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdNo
dateFromNo
dateToNo
groupByNoGroup expenses by "merchant" (default) or "category".
limitNoMax groups to return (default 20, sorted by total spent).

Implementation Reference

  • The main handler function for the spending_summary tool. Calls listTransactions to fetch debit transactions, groups them by merchant or category, sorts by total spent descending, and returns an object with groups, totalSpent, currency, and period.
    export async function spendingSummary(
      args: z.infer<typeof spendingSummarySchema>,
    ): Promise<{ groups: SpendingGroup[]; totalSpent: number; currency: string; period: string }> {
      const transactions = await listTransactions({
        connectionId: args.connectionId,
        dateFrom: args.dateFrom,
        dateTo: args.dateTo,
        type: "debit",
      });
    
      const groupBy = args.groupBy || "merchant";
      const limit = args.limit || 20;
    
      // Group expenses
      const groups = new Map<string, { total: number; count: number; currency: string }>();
    
      for (const tx of transactions) {
        const key =
          groupBy === "merchant"
            ? tx.merchantName || tx.description || "Unknown"
            : tx.category || "uncategorized";
    
        const existing = groups.get(key) || { total: 0, count: 0, currency: tx.currency };
        existing.total += Math.abs(tx.amount);
        existing.count += 1;
        groups.set(key, existing);
      }
    
      // Sort by total spent descending
      const sorted = [...groups.entries()]
        .map(([name, data]) => ({
          name,
          totalSpent: Math.round(data.total * 100) / 100,
          transactionCount: data.count,
          currency: data.currency,
        }))
        .sort((a, b) => b.totalSpent - a.totalSpent)
        .slice(0, limit);
    
      const totalSpent =
        Math.round(transactions.reduce((sum, t) => sum + Math.abs(t.amount), 0) * 100) / 100;
    
      const currency = transactions[0]?.currency || "PLN";
      const dateFrom = args.dateFrom || defaultDateFrom(90);
      const dateTo = args.dateTo || today();
    
      return {
        groups: sorted,
        totalSpent,
        currency,
        period: `${dateFrom} to ${dateTo}`,
      };
    }
  • Zod schema defining the input parameters for spending_summary: optional connectionId, dateFrom, dateTo, groupBy (merchant/category), and limit.
    export const spendingSummarySchema = z.object({
      connectionId: z.string().optional(),
      dateFrom: z.string().optional(),
      dateTo: z.string().optional(),
      groupBy: z
        .enum(["merchant", "category"])
        .optional()
        .describe('Group expenses by "merchant" (default) or "category".'),
      limit: z
        .number()
        .optional()
        .describe("Max groups to return (default 20, sorted by total spent)."),
    });
  • src/server.ts:49-54 (registration)
    Tool registration in the TOOLS array: name 'spending_summary' with description and inputSchema mapped to spendingSummarySchema.
    {
      name: "spending_summary",
      description:
        'Group expenses by merchant or category with totals. Shows where money is being spent. Use groupBy "merchant" for vendor breakdown, "category" for category breakdown.',
      inputSchema: z.toJSONSchema(spendingSummarySchema),
    },
  • src/server.ts:66-68 (registration)
    Handler mapping: spending_summary routes args through spendingSummarySchema.parse and calls the spendingSummary function.
      spending_summary: (args) =>
        spendingSummary(spendingSummarySchema.parse(args)),
    };
  • Helper functions defaultDateFrom and today used to compute default date range (90 days back from today).
    function defaultDateFrom(days: number): string {
      const d = new Date();
      d.setDate(d.getDate() - days);
      return d.toISOString().slice(0, 10);
    }
    
    function today(): string {
      return new Date().toISOString().slice(0, 10);
    }
Behavior2/5

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

No annotations are provided, so the description carries full responsibility. It mentions grouping and totals but omits critical behavioral details such as the ability to filter by date range (dateFrom, dateTo) and the default limit and sorting behavior, which are only present in the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief, with three clear sentences that front-load the purpose. It avoids unnecessary detail and is easy to parse, though it could be slightly more structured.

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 five parameters and no output schema, the description omits important context such as the meaning of dateFrom/dateTo for filtering and the default limit of 20. It also lacks any hint of the return format beyond 'totals', making it incomplete for an agent to use effectively.

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

Parameters2/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: it reiterates the groupBy options but does not explain the purpose of connectionId, dateFrom, dateTo, or limit beyond what the schema already provides. With 40% schema coverage, the description should compensate more.

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 groups expenses by merchant or category with totals, showing where money is spent. It distinguishes from sibling tools like list_transactions and get_balance by focusing on aggregation rather than raw data or balances.

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 suggests when to use each groupBy option but does not provide explicit guidance on when to use this tool versus alternatives like search_transactions or list_transactions. The context is implied but not directly contrasted.

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/elcukro/bank-mcp'

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