Skip to main content
Glama

add_txns

Bulk-insert multiple transactions in one call for imports of over 5 rows. Automatically sorts by date and returns a per-ticker summary for confirmation.

Instructions

Bulk-insert transactions in one call. Use this for any import larger than ~5 rows (CSV / brokerage export / paste). Sorts by date ascending automatically — average cost depends on insertion order. Returns a per-ticker / per-type summary so you can confirm the import to the user. For one-off entries during conversation, prefer add_txn.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
transactionsYes

Implementation Reference

  • Handler function for the add_txns tool. Sorts transactions by date ascending, iterates over each transaction, inserts it into the database using db.insert(transactions).values(...).run(), tracks per-ticker and per-type counts, and returns a summary with inserted count, first/last dates, by_ticker, and by_type.
    server.tool(
      'add_txns',
      'Bulk-insert transactions in one call. Use this for any import larger than ~5 rows (CSV / brokerage export / paste). Sorts by date ascending automatically — average cost depends on insertion order. Returns a per-ticker / per-type summary so you can confirm the import to the user. For one-off entries during conversation, prefer add_txn.',
      {
        transactions: z
          .array(
            z.object({
              ticker: z.string(),
              date: z.string().describe('YYYY-MM-DD'),
              type: z.enum(['buy', 'sell', 'deposit', 'dividend', 'tax']),
              shares: z.number().positive(),
              price: z.number().min(0),
              currency: z.string().default('USD'),
              reason: z.string().optional(),
            }),
          )
          .min(1),
      },
      async ({ transactions: txns }) => {
        const db = getDb();
        const sorted = [...txns].sort((a, b) => a.date.localeCompare(b.date));
        const byTicker = new Map<string, number>();
        const byType = new Map<string, number>();
    
        for (const t of sorted) {
          const ticker = t.ticker.toUpperCase();
          db.insert(transactions)
            .values({
              ticker,
              date: t.date,
              type: t.type,
              shares: t.shares,
              price: t.price,
              currency: t.currency ?? 'USD',
              reason: t.reason ?? null,
            })
            .run();
          byTicker.set(ticker, (byTicker.get(ticker) ?? 0) + 1);
          byType.set(t.type, (byType.get(t.type) ?? 0) + 1);
        }
    
        return ok({
          inserted: sorted.length,
          first_date: sorted[0].date,
          last_date: sorted[sorted.length - 1].date,
          by_ticker: Object.fromEntries(byTicker),
          by_type: Object.fromEntries(byType),
        });
      },
    );
  • Input schema for add_txns: takes an array (min 1) of transaction objects with fields ticker, date (YYYY-MM-DD), type (buy/sell/deposit/dividend/tax), shares (positive number), price (>=0), currency (default USD), and optional reason.
    {
      transactions: z
        .array(
          z.object({
            ticker: z.string(),
            date: z.string().describe('YYYY-MM-DD'),
            type: z.enum(['buy', 'sell', 'deposit', 'dividend', 'tax']),
            shares: z.number().positive(),
            price: z.number().min(0),
            currency: z.string().default('USD'),
            reason: z.string().optional(),
          }),
        )
        .min(1),
    },
  • Tool registration via server.tool('add_txns', ...) inside registerMutateTools function.
    server.tool(
      'add_txns',
      'Bulk-insert transactions in one call. Use this for any import larger than ~5 rows (CSV / brokerage export / paste). Sorts by date ascending automatically — average cost depends on insertion order. Returns a per-ticker / per-type summary so you can confirm the import to the user. For one-off entries during conversation, prefer add_txn.',
      {
        transactions: z
          .array(
            z.object({
              ticker: z.string(),
              date: z.string().describe('YYYY-MM-DD'),
              type: z.enum(['buy', 'sell', 'deposit', 'dividend', 'tax']),
              shares: z.number().positive(),
              price: z.number().min(0),
              currency: z.string().default('USD'),
              reason: z.string().optional(),
            }),
          )
          .min(1),
      },
      async ({ transactions: txns }) => {
        const db = getDb();
        const sorted = [...txns].sort((a, b) => a.date.localeCompare(b.date));
        const byTicker = new Map<string, number>();
        const byType = new Map<string, number>();
    
        for (const t of sorted) {
          const ticker = t.ticker.toUpperCase();
          db.insert(transactions)
            .values({
              ticker,
              date: t.date,
              type: t.type,
              shares: t.shares,
              price: t.price,
              currency: t.currency ?? 'USD',
              reason: t.reason ?? null,
            })
            .run();
          byTicker.set(ticker, (byTicker.get(ticker) ?? 0) + 1);
          byType.set(t.type, (byType.get(t.type) ?? 0) + 1);
        }
    
        return ok({
          inserted: sorted.length,
          first_date: sorted[0].date,
          last_date: sorted[sorted.length - 1].date,
          by_ticker: Object.fromEntries(byTicker),
          by_type: Object.fromEntries(byType),
        });
      },
    );
  • The export function registerMutateTools is the registration entry point that registers add_txns along with other tools (add_txn, edit_txn, add_balances) on the McpServer.
    export function registerMutateTools(server: McpServer): void {
Behavior4/5

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

Describes two behavioral traits: 'Sorts by date ascending automatically — average cost depends on insertion order' and 'Returns a per-ticker / per-type summary.' Without annotations, this adds valuable context, though it could mention idempotency or error behavior for a 5.

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 concise with four sentences, front-loaded with the core purpose. Every sentence adds distinct value without redundancy.

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?

For a bulk-insert tool with one complex parameter array and no output schema, the description covers purpose, usage context, sorting behavior, and return summary. It is reasonably complete, though missing potential error handling or limits.

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 input schema has one parameter (an array of transaction objects) with reasonable self-documentation (e.g., date format, enum for type). The description adds no extra semantic detail beyond 'bulk-insert,' so baseline 3 is appropriate given schema coverage.

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 'Bulk-insert transactions in one call,' specifying the verb (insert) and resource (transactions). It differentiates from sibling 'add_txn' by noting that 'add_txn' is for one-off entries, making the tool's role distinct.

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

Usage Guidelines5/5

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

Explicitly advises 'Use this for any import larger than ~5 rows (CSV / brokerage export / paste)' and contrasts with 'For one-off entries during conversation, prefer add_txn.' This gives clear when-to-use and when-not-to-use guidance.

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