Skip to main content
Glama

show_balance

Get balance sheet entries (assets and liabilities) for a specific month or view all periods to identify trends.

Instructions

Stored balance sheet entries (assets + liabilities) by period. Each entry has type (asset|liability), sub_type (cash|investment|other|short_term|long_term), category, amount in USD, and the entry date. Without period, returns ALL periods — use this for trends; with period (YYYY-MM), returns one month's snapshot.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodNoPeriod filter e.g. "2025-03"

Implementation Reference

  • MCP server.tool() registration for 'show_balance' — defines the tool's name, description, input schema (optional period parameter), and handler logic that queries balance_entries from the database.
    server.tool(
      'show_balance',
      "Stored balance sheet entries (assets + liabilities) by period. Each entry has type (asset|liability), sub_type (cash|investment|other|short_term|long_term), category, amount in USD, and the entry date. Without `period`, returns ALL periods — use this for trends; with `period` (YYYY-MM), returns one month's snapshot.",
      { period: z.string().optional().describe('Period filter e.g. "2025-03"') },
      async ({ period }) => {
        const db = getDb();
        const rows = period
          ? db.select().from(balanceEntries).where(eq(balanceEntries.period, period)).all()
          : db.select().from(balanceEntries).all();
        return ok(rows);
      },
    );
  • Handler function for 'show_balance' tool — accepts an optional period filter (YYYY-MM), queries the balanceEntries table, and returns all matching rows. If no period is given, returns ALL periods.
    async ({ period }) => {
      const db = getDb();
      const rows = period
        ? db.select().from(balanceEntries).where(eq(balanceEntries.period, period)).all()
        : db.select().from(balanceEntries).all();
      return ok(rows);
    },
  • Drizzle ORM schema for the balance_entries table — defines columns: id, period, date, type (asset|liability), sub_type, category, amount, currency, memo, with a unique index on (period, type, sub_type, category).
    export const balanceEntries = sqliteTable(
      'balance_entries',
      {
        id: integer('id').primaryKey({ autoIncrement: true }),
        period: text('period').notNull(),
        date: text('date').notNull(),
        type: text('type').notNull(),
        sub_type: text('sub_type').notNull(),
        category: text('category').notNull(),
        amount: integer('amount').notNull().default(0),
        currency: text('currency').notNull().default('KRW'),
        memo: text('memo'),
      },
      (t) => [uniqueIndex('balance_uq').on(t.period, t.type, t.sub_type, t.category)],
    );
  • Top-level MCP server setup — imports and calls registerPortfolioTools(server), which registers 'show_balance' among other portfolio tools.
    import { registerPortfolioTools } from './tools/portfolio.ts';
    import { registerReportTools } from './tools/report.ts';
    import { registerSnapshotTools } from './tools/snapshot.ts';
    import { registerStockTools } from './tools/stock.ts';
    import { registerPrompts } from './prompts.ts';
    
    const server = new McpServer(
      { name: 'firma', version: FIRMA_VERSION },
      { instructions: SERVER_INSTRUCTIONS },
    );
    
    registerPortfolioTools(server);
    registerReportTools(server);
    registerMutateTools(server);
    registerSnapshotTools(server);
  • Balance repository helper with CRUD operations for balanceEntries — provides getAll, getByPeriod, getPeriods, upsert, and deleteByPeriod methods used by other parts of the app.
    const createBalanceRepository = (db: DbClient): BalanceRepository => ({
      getAll: () => db.select().from(balanceEntries).all(),
      getByPeriod: (period) =>
        db.select().from(balanceEntries).where(eq(balanceEntries.period, period)).all(),
      getPeriods: () =>
        db
          .selectDistinct({ period: balanceEntries.period })
          .from(balanceEntries)
          .orderBy(desc(balanceEntries.period))
          .all()
          .map((r) => r.period),
      upsert: (entry) =>
        db
          .insert(balanceEntries)
          .values(entry)
          .onConflictDoUpdate({
            target: [
              balanceEntries.period,
              balanceEntries.type,
              balanceEntries.sub_type,
              balanceEntries.category,
            ],
            set: { amount: entry.amount, currency: entry.currency, date: entry.date, memo: entry.memo },
          })
          .run(),
      deleteByPeriod: (period) =>
        db.delete(balanceEntries).where(eq(balanceEntries.period, period)).run().changes,
    });
Behavior3/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 implies read-only behavior through the verb 'show' and describes the return structure, but it does not explicitly state it is read-only, disclose any side effects, or mention authentication or rate limits.

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 sentences cover purpose, return fields, and parameter behavior without any redundancy or waste. Every sentence is essential and front-loaded.

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?

Given the simple input (one optional parameter) and no output schema, the description adequately explains return fields and parameter effect. Missing details like ordering, limits, or error scenarios, but these are not critical for basic usage.

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

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides a description for 'period', but the tool description adds significant meaning by explaining the behavioral difference between providing and omitting the parameter (all periods vs. one snapshot). This goes beyond the schema's basic filter hint.

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 that the tool shows stored balance sheet entries (assets and liabilities) by period, listing specific fields (type, sub_type, category, amount in USD, entry date). It distinguishes from siblings like show_flow or show_snapshot by focusing on balance sheet content.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly explains when to use without 'period' for trends and with 'period' for a single month snapshot, providing clear context for parameter usage. However, it does not mention alternatives or when not to use this tool.

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