Skip to main content
Glama

show_txns

Retrieve a chronological list of all investment transactions including buys, sells, deposits, dividends, and taxes. Filter by ticker to view per-position history.

Instructions

Full transaction log (buys, sells, deposits, dividends, taxes) ordered by date ascending. Pass ticker to filter to one symbol — useful for "show me all my AAPL trades" or computing a per-position story. Each row has the original currency it was entered in.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerNoFilter by ticker (e.g. AAPL)

Implementation Reference

  • The MCP tool handler for 'show_txns'. Queries the transactions table from SQLite via Drizzle ORM, optionally filtered by ticker, ordered by date ascending, and returns the rows via the 'ok' helper.
    server.tool(
      'show_txns',
      'Full transaction log (buys, sells, deposits, dividends, taxes) ordered by date ascending. Pass `ticker` to filter to one symbol — useful for "show me all my AAPL trades" or computing a per-position story. Each row has the original currency it was entered in.',
      { ticker: z.string().optional().describe('Filter by ticker (e.g. AAPL)') },
      async ({ ticker }) => {
        const db = getDb();
        const rows = ticker
          ? db
              .select()
              .from(transactions)
              .where(eq(transactions.ticker, ticker.toUpperCase()))
              .orderBy(asc(transactions.date))
              .all()
          : db.select().from(transactions).orderBy(asc(transactions.date)).all();
        return ok(rows);
      },
    );
  • Input schema for show_txns: an optional ticker string parameter using Zod validation.
    { ticker: z.string().optional().describe('Filter by ticker (e.g. AAPL)') },
  • Registration site: registerPortfolioTools is called in the MCP server entry point, which registers the 'show_txns' tool under the McpServer instance.
    registerPortfolioTools(server);
  • The function that registers all portfolio tools (including show_txns) on the McpServer. show_txns is one of several tools registered within this function.
    export function registerPortfolioTools(server: McpServer): void {
  • CLI version of the show_txns logic (showTxnsCommand). Same query logic as the MCP handler but with formatted terminal output including ID, date, ticker, type, shares, price, total, and average cost tracking.
    export const showTxnsCommand = async (ticker?: string, { json = false } = {}) => {
      const db = getDb();
      const all = ticker
        ? db
            .select()
            .from(transactions)
            .where(eq(transactions.ticker, ticker.toUpperCase()))
            .orderBy(asc(transactions.date))
            .all()
        : db.select().from(transactions).orderBy(asc(transactions.date)).all();
    
      const txns = [...all].reverse();
    
      if (txns.length === 0) {
        if (json) {
          process.stdout.write('[]\n');
          return;
        }
        log.warn(
          ticker ? `No transactions found for ${ticker.toUpperCase()}.` : 'No transactions found.',
        );
        return;
      }
    
      if (json) {
        process.stdout.write(`${JSON.stringify(txns, null, 2)}\n`);
        return;
      }
    
      const showTicker = !ticker;
      const showAvg = !!ticker;
    
      const header = [
        pc.dim('ID'.padEnd(COL.ID)),
        pc.dim('DATE'.padEnd(COL.DATE)),
        ...(showTicker ? [pc.dim('TICKER'.padEnd(COL.TICKER))] : []),
        pc.dim('TYPE'.padEnd(COL.TYPE)),
        pc.dim('SHARES'.padEnd(COL.SHARES)),
        pc.dim('PRICE'.padEnd(COL.PRICE)),
        pc.dim('TOTAL'.padEnd(COL.TOTAL)),
        ...(showAvg ? [pc.dim('AVG COST')] : []),
      ].join('  ');
    
      const totalWidth =
        COL.ID +
        COL.DATE +
        (showTicker ? COL.TICKER + 2 : 0) +
        COL.TYPE +
        COL.SHARES +
        COL.PRICE +
        COL.TOTAL +
        (showAvg ? COL.AVG + 2 : 0) +
        10;
      const divider = pc.dim('─'.repeat(totalWidth));
    
      const ordered = showAvg ? [...txns].reverse() : txns;
    
      const { rows: rowsAsc } = ordered.reduce(
        ({ shares, costShares, totalCost, rows }, t) => {
          const colorType = TYPE_COLOR[t.type] ?? ((s: string) => s);
          const total = t.shares * t.price;
    
          let ns = shares,
            nc = costShares,
            nt = totalCost;
          if (t.type === 'buy') {
            ns = shares + t.shares;
            nc = costShares + t.shares;
            nt = totalCost + total;
          } else if (t.type === 'sell') {
            ns = shares - t.shares;
            const ratio = shares > 0 ? ns / shares : 0;
            nc = costShares * ratio;
            nt = totalCost * ratio;
          } else if (t.type === 'deposit' && t.price > 0) {
            ns = shares + t.shares;
            nc = costShares + t.shares;
            nt = totalCost + t.shares * t.price;
          } else if (t.type === 'deposit') {
            ns = shares + t.shares;
          }
    
          const avg = nc > 0 ? nt / nc : 0;
          const row = [
            pc.dim(`#${t.id}`.padEnd(COL.ID)),
            pc.dim(t.date.padEnd(COL.DATE)),
            ...(showTicker ? [pc.bold(t.ticker.padEnd(COL.TICKER))] : []),
            colorType(t.type.padEnd(COL.TYPE)),
            fmt.num(t.shares).padEnd(COL.SHARES),
            (t.price > 0 ? fmt.price(t.price, t.currency) : pc.dim('─')).padEnd(COL.PRICE),
            (total > 0 ? fmt.price(total, t.currency) : pc.dim('─')).padEnd(COL.TOTAL),
            ...(showAvg ? [avg > 0 ? pc.bold(fmt.price(avg, t.currency)) : pc.dim('─')] : []),
          ].join('  ');
          return { shares: ns, costShares: nc, totalCost: nt, rows: [...rows, row] };
        },
        { shares: 0, costShares: 0, totalCost: 0, rows: [] as string[] },
      );
    
      const rows = showAvg ? rowsAsc.reverse() : rowsAsc;
      const title = ticker ? `Transactions · ${ticker.toUpperCase()}` : 'Transactions';
      const footer = `\n${pc.dim(`${txns.length} transaction${txns.length !== 1 ? 's' : ''}`)}`;
      section(title, `${header}\n${divider}\n${rows.join('\n')}${footer}`);
    };
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as read-only status, side effects, authorization requirements, or rate limits. The description focuses on the content of the output but not on the behavior of the tool itself, which is a significant gap given the absence of annotations.

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 two sentences long and front-loaded with the core purpose. Every sentence adds useful information: first sentence defines the tool, second explains the parameter and use case, third adds a note about currency. No wasted words.

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 simple list tool with one optional parameter, the description covers the main aspects: what is returned, ordering, filtering, and a use case. It does not mention pagination or limits, but given the simplicity, it is largely complete.

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 input schema already describes the `ticker` parameter with 100% coverage. The description adds value by explaining the filtering purpose and providing a concrete example ('show me all my AAPL trades'), going beyond the basic schema description.

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 it shows a full transaction log including all types (buys, sells, deposits, dividends, taxes) and ordering (date ascending). It distinguishes from sibling tools like show_balance, show_flow, and show_portfolio, which serve different purposes.

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?

The description explicitly mentions passing the `ticker` parameter to filter for one symbol and gives a concrete use case ('show me all my AAPL trades'), which guides appropriate usage. However, it does not explicitly state when not to use this tool or provide direct comparisons with alternatives.

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