Skip to main content
Glama

report_balance

Aggregate balance sheet entries to generate a monthly net worth trend, sorted by period for tracking financial changes.

Instructions

Aggregate balance sheet entries by period. Returns monthly net worth trend sorted by period.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax number of periods to return (default: 36)

Implementation Reference

  • Handler: Defines the 'report_balance' MCP tool. Aggregates all balance entries by period, computing assets, liabilities, and net_worth, sorted by period and limited by the 'limit' parameter (default 36).
    server.tool(
      'report_balance',
      'Aggregate balance sheet entries by period. Returns monthly net worth trend sorted by period.',
      {
        limit: z
          .number()
          .int()
          .min(1)
          .max(120)
          .default(36)
          .describe('Max number of periods to return (default: 36)'),
      },
      async ({ limit }) => {
        const db = getDb();
        const rows = db.select().from(balanceEntries).all();
    
        const byPeriod = rows.reduce((map, { period, type, amount }) => {
          const prev = map.get(period) ?? { assets: 0, liabilities: 0 };
          map.set(period, {
            assets: prev.assets + (type === 'asset' ? amount : 0),
            liabilities: prev.liabilities + (type === 'liability' ? amount : 0),
          });
          return map;
        }, new Map<string, { assets: number; liabilities: number }>());
    
        const result = [...byPeriod.entries()]
          .sort(([a], [b]) => a.localeCompare(b))
          .slice(-limit)
          .map(([period, { assets, liabilities }]) => ({
            period,
            assets,
            liabilities,
            net_worth: assets - liabilities,
          }));
    
        return ok(result);
      },
    );
  • Schema: Zod input schema for report_balance — accepts optional 'limit' (integer 1-120, default 36).
    {
      limit: z
        .number()
        .int()
        .min(1)
        .max(120)
        .default(36)
        .describe('Max number of periods to return (default: 36)'),
    },
  • Registration: The 'report_balance' tool is registered via server.tool() within the registerReportTools() function, which is called from apps/mcp/src/index.ts:20.
    export function registerReportTools(server: McpServer): void {
      server.tool(
        'report_balance',
        'Aggregate balance sheet entries by period. Returns monthly net worth trend sorted by period.',
        {
          limit: z
            .number()
            .int()
            .min(1)
            .max(120)
            .default(36)
            .describe('Max number of periods to return (default: 36)'),
        },
  • Helper: The 'ok' function wraps data into the MCP response format (content array with JSON stringified text).
    export const ok = (data: unknown) => ({
      content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
    });
  • Support: getDb() returns the database client used by the tool handler to query balanceEntries.
    export const getDb = (): DbClient => {
      if (!_db) _db = createDbClient(dbPath());
      return _db;
    };
    
    export const getRepository = (): DataRepository => {
      if (!_repo) _repo = createDataRepository(getDb());
      return _repo;
    };
Behavior3/5

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

No annotations provided; description gives basic behavior (returns monthly trend sorted by period) but omits side effects, auth needs, or whether it's read-only.

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?

Two concise sentences with no wasted words; front-loaded and efficient.

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?

No output schema, but description gives essential output info. Lacks details on exact fields, but sufficient for a simple aggregation tool.

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 covers the only parameter (limit) with full description; description adds no additional parameter context.

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?

Description clearly states it aggregates balance sheet entries and returns monthly net worth trend, distinguishing it from sibling tools like report_flow and report_settle.

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?

No explicit guidance on when to use this tool versus alternatives; usage is implied but not elaborated.

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/evan-moon/firma'

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