Skip to main content
Glama

show_dividend

Calculate the annual dividend income for each holding in your portfolio, showing per-ticker yield, annual dividend per share, and estimated income from dividend-paying stocks.

Instructions

Estimated annual dividend income for all holdings. Returns per-ticker yield, annual DPS, and estimated income. Only includes tickers with dividend data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'show_dividend' tool on the MCP server. It calls server.tool() with the name 'show_dividend', a description, empty schema (no params), and an async handler.
    server.tool(
      'show_dividend',
      'Estimated annual dividend income for all holdings. Returns per-ticker yield, annual DPS, and estimated income. Only includes tickers with dividend data.',
      {},
      async () => {
        const db = getDb();
        const txns = db.select().from(transactions).all();
        const holdings = aggregateHoldings(txns);
        const priceMap = new Map(
          db
            .select()
            .from(prices)
            .all()
            .map((p) => [p.ticker, p]),
        );
    
        const rows = [...holdings.entries()]
          .map(([ticker, h]) => {
            const p = priceMap.get(ticker);
            const dps = p?.dividend_per_share ?? null;
            const yieldPct = p?.dividend_yield ?? null;
            return {
              ticker,
              shares: h.shares,
              dividend_yield: yieldPct,
              dividend_per_share: dps,
              estimated_annual_income: dps != null ? dps * h.shares : null,
            };
          })
          .filter((r) => r.dividend_per_share != null);
    
        const total_annual = rows.reduce((s, r) => s + (r.estimated_annual_income ?? 0), 0);
        return ok({
          holdings: rows,
          total_annual_income: total_annual,
          total_monthly_income: total_annual / 12,
        });
      },
    );
  • The handler function that executes 'show_dividend' logic: queries DB for transactions, aggregates holdings, fetches prices, computes dividend yield/DPS/annual income per ticker, and returns holdings with total annual/monthly income.
    async () => {
      const db = getDb();
      const txns = db.select().from(transactions).all();
      const holdings = aggregateHoldings(txns);
      const priceMap = new Map(
        db
          .select()
          .from(prices)
          .all()
          .map((p) => [p.ticker, p]),
      );
    
      const rows = [...holdings.entries()]
        .map(([ticker, h]) => {
          const p = priceMap.get(ticker);
          const dps = p?.dividend_per_share ?? null;
          const yieldPct = p?.dividend_yield ?? null;
          return {
            ticker,
            shares: h.shares,
            dividend_yield: yieldPct,
            dividend_per_share: dps,
            estimated_annual_income: dps != null ? dps * h.shares : null,
          };
        })
        .filter((r) => r.dividend_per_share != null);
    
      const total_annual = rows.reduce((s, r) => s + (r.estimated_annual_income ?? 0), 0);
      return ok({
        holdings: rows,
        total_annual_income: total_annual,
        total_monthly_income: total_annual / 12,
      });
    },
  • Empty schema object '{}' — the show_dividend tool takes no input parameters.
    {},
  • The aggregateHoldings helper function that processes transactions into a map of ticker -> Holding (shares, costShares, totalCost), used by the show_dividend handler to determine current positions.
    export const aggregateHoldings = (txns: Transaction[]): Map<string, Holding> => {
      const sorted = [...txns].sort((a, b) => a.date.localeCompare(b.date));
    
      const map = sorted.reduce((acc, t) => {
        const h = acc.get(t.ticker) ?? { ticker: t.ticker, shares: 0, costShares: 0, totalCost: 0 };
    
        if (t.type === 'buy') {
          h.shares += t.shares;
          h.costShares += t.shares;
          h.totalCost += t.shares * t.price;
        } else if (t.type === 'sell') {
          const ratio = h.shares > 0 ? (h.shares - t.shares) / h.shares : 0;
          h.shares -= t.shares;
          h.costShares = h.costShares * ratio;
          h.totalCost = h.totalCost * ratio;
        } else if (t.type === 'deposit') {
          h.shares += t.shares;
          if (t.price > 0) {
            h.costShares += t.shares;
            h.totalCost += t.shares * t.price;
          }
        }
    
        return acc.set(t.ticker, h);
      }, new Map<string, Holding>());
    
      return new Map([...map.entries()].filter(([, h]) => h.shares > 0));
    };
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses that results are estimated and only include tickers with dividend data, but does not mention read-only nature or data freshness.

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. Purpose is front-loaded, and every sentence adds value.

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 no parameters and no output schema, the description is largely complete. It specifies output fields and inclusion criteria, though it could clarify scope (e.g., all holdings in portfolio).

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?

With zero parameters, the description does not need to add parameter info. Schema coverage is 100%, so baseline is 4. The description appropriately omits parameter details.

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 estimated annual dividend income for all holdings, specifying per-ticker yield, annual DPS, and estimated income. It distinguishes itself from sibling show_* tools by focusing on dividend-specific metrics.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like show_earnings or show_financials. It only describes functionality without context for selection.

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