Skip to main content
Glama

Peer Comparison Workflow

load_comparison_workflow
Read-onlyIdempotent

Load comparison workflow for X vs Y, peer analysis, relative valuation. REQUIRES get_database_schema then get_query_patterns to be called first (in that order). Call BEFORE writing SQL when the user asks to compare companies, "X vs Y", "how does X compare to Y", peer benchmarking, sector peers, side-by-side metrics, or relative valuation. Can be combined with other workflow tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / additionalProperties
      Added value: +false
    • removedOutput schema / description
      Removed value: -"Generic wrapper for non-object return types."
  2. Changed1 schema field changed
    • removedInput schema / properties / _content
      Removed value: -{
      -  "default": "## Comparative Analysis Workflow\n\n### Persona\nYou are an analyst producing peer comparison reports. You focus\non apples-to-apples comparisons - same sector, similar size,\ncomparable business models. You highlight where a company stands\nout (positively or negatively) relative to peers.\n\n### Workflow\n1. **Validate comparability**: Check that companies are in the\n   same or adjacent GICS sector/industry. If not, note\n   that the comparison is cross-sector and metrics may not be\n   directly comparable.\n2. **Size context**: Note market cap differences. A $10B company\n   vs a $500B company will naturally differ in growth rates,\n   margins, and multiples.\n3. **Snapshot comparison**: Pull latest valuation + fundamentals\n   overview fields for all symbols. Compare P/E, EV/EBITDA,\n   margins, return_on_equity.\n4. **Trend comparison**: Compare quarterly revenue and earnings\n   trajectories from fundamentals. Are they converging or diverging?\n5. **Price performance**: Use P2 pattern for returns over same period.\n6. **Relative strengths**: Identify what each company does better.\n   Avoid declaring a \"winner\" - different investors value\n   different attributes.\n\n### Output Format\n- **Comparison Overview**: Brief context on why these companies\n  are being compared (same industry, competitors, etc.)\n- **Snapshot Table**: Side-by-side metrics (inline markdown)\n- **Key Differentiators**: 2-3 sentences on what distinguishes each\n- **Trend Context**: Are the gaps widening or narrowing?\n- **Caveats**: Size differences, data staleness, sector mismatches\n\n### Advanced Query Patterns\n\n#### C1: Side-by-side snapshot (N companies)\n```sql\nWITH latest_val AS (\n  SELECT symbol, market_cap, pe_ratio, price_to_book, peg_ratio,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.valuation WHERE date >= CURRENT_DATE - INTERVAL '7 days'\n),\nlatest_q AS (\n  SELECT symbol, profit_margin, return_on_equity, revenue_growth_yoy,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.fundamentals_quarterly\n  WHERE date >= CURRENT_DATE - INTERVAL '6 months'\n),\nlatest_dd AS (\n  SELECT symbol, ev_ebitda, dividend_yield,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.fundamentals_derived_daily WHERE date >= CURRENT_DATE - INTERVAL '7 days'\n)\nSELECT g.symbol, g.name, g.gics_industry,\n  ROUND(v.market_cap / 1e9, 1) AS market_cap_bln,\n  ROUND(v.pe_ratio, 2) AS pe,\n  ROUND(dd.ev_ebitda, 2) AS ev_ebitda,\n  ROUND(f.profit_margin * 100, 1) AS margin_pct,\n  ROUND(f.return_on_equity * 100, 1) AS roe_pct,\n  ROUND(f.revenue_growth_yoy * 100, 1) AS rev_growth_pct,\n  ROUND(dd.dividend_yield * 100, 2) AS div_yield_pct,\n  os.percent_insiders, os.short_percent_float\nFROM shibui.general_info g\nINNER JOIN latest_val v ON g.symbol = v.symbol AND v.rn = 1\nLEFT JOIN latest_q f ON g.symbol = f.symbol AND f.rn = 1\nLEFT JOIN latest_dd dd ON g.symbol = dd.symbol AND dd.rn = 1\nLEFT JOIN shibui.ownership_stats os ON g.symbol = os.symbol\nWHERE g.symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\nORDER BY v.market_cap DESC\nLIMIT 10\n```\n\n#### C2: Revenue and margin trend comparison (last 8 quarters)\n```sql\nSELECT f.symbol, f.date,\n  f.revenue,\n  ROUND(f.gross_profit / NULLIF(f.revenue, 0) * 100, 1) AS gross_margin_pct,\n  ROUND(f.net_income / NULLIF(f.revenue, 0) * 100, 1) AS net_margin_pct,\n  ROUND(f.operating_income / NULLIF(f.revenue, 0) * 100, 1) AS op_margin_pct\nFROM shibui.fundamentals_quarterly f\nWHERE f.symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ')\n  AND f.date >= CURRENT_DATE - INTERVAL '2 years'\n  AND f.revenue IS NOT NULL\nORDER BY f.symbol, f.date DESC\nLIMIT 20\n```\n\n#### C3: Price performance comparison (multiple timeframes)\n```sql\nWITH prices AS (\n  SELECT symbol, date, close,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn,\n    FIRST_VALUE(close) OVER (PARTITION BY symbol ORDER BY date ASC) AS start_90d\n  FROM shibui.stock_quotes\n  WHERE symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\n    AND date >= CURRENT_DATE - INTERVAL '90 days'\n),\nprices_1y AS (\n  SELECT symbol,\n    FIRST_VALUE(close) OVER (PARTITION BY symbol ORDER BY date ASC) AS start_1y,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.stock_quotes\n  WHERE symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\n    AND date >= CURRENT_DATE - INTERVAL '1 year'\n)\nSELECT p.symbol,\n  ROUND(p.close, 2) AS current_price,\n  ROUND((p.close - p.start_90d) / NULLIF(p.start_90d, 0) * 100, 1) AS return_90d_pct,\n  ROUND((p.close - y.start_1y) / NULLIF(y.start_1y, 0) * 100, 1) AS return_1y_pct\nFROM prices p\nLEFT JOIN prices_1y y ON p.symbol = y.symbol AND y.rn = 1\nWHERE p.rn = 1\nORDER BY return_90d_pct DESC\nLIMIT 10\n```\n",
      -  "type": "string"
      -}
  3. Changed1 schema field changed
    • changedInput schema / properties / _content / default
      Previous value: -"## Comparative Analysis Workflow\n\n### Persona\nYou are an analyst producing peer comparison reports. You focus\non apples-to-apples comparisons — same sector, similar size,\ncomparable business models. You highlight where a company stands\nout (positively or negatively) relative to peers.\n\n### Workflow\n1. **Validate comparability**: Check that companies are in the\n   same or adjacent gic_sector/gic_sub_industry. If not, note\n   that the comparison is cross-sector and metrics may not be\n   directly comparable.\n2. **Size context**: Note market cap differences. A $10B company\n   vs a $500B company will naturally differ in growth rates,\n   margins, and multiples.\n3. **Snapshot comparison**: Pull highlights + valuation for all\n   symbols in one query. Compare P/E, EV/EBITDA, margins, ROE.\n4. **Trend comparison**: Compare quarterly revenue and earnings\n   trajectories. Are they converging or diverging?\n5. **Price performance**: Use P2 pattern for returns over same period.\n6. **Relative strengths**: Identify what each company does better.\n   Avoid declaring a \"winner\" — different investors value\n   different attributes.\n\n### Output Format\n- **Comparison Overview**: Brief context on why these companies\n  are being compared (same industry, competitors, etc.)\n- **Snapshot Table**: Side-by-side metrics (inline markdown)\n- **Key Differentiators**: 2-3 sentences on what distinguishes each\n- **Trend Context**: Are the gaps widening or narrowing?\n- **Caveats**: Size differences, data staleness, sector mismatches\n\n### Advanced Query Patterns\n\n#### C1: Side-by-side snapshot (N companies)\n```sql\nSELECT g.symbol, g.name, g.gic_sub_industry,\n  h.market_capitalization_mln,\n  ROUND(h.pe_ratio, 2) AS pe,\n  ROUND(v.forward_pe, 2) AS fwd_pe,\n  ROUND(v.enterprise_value_ebitda, 2) AS ev_ebitda,\n  ROUND(h.profit_margin * 100, 1) AS margin_pct,\n  ROUND(h.return_on_equity_ttm * 100, 1) AS roe_pct,\n  ROUND(h.quarterly_revenue_growth_yoy * 100, 1) AS rev_growth_pct,\n  ROUND(h.dividend_yield * 100, 2) AS div_yield_pct,\n  ss.percent_insiders, ss.short_percent_float\nFROM shibui.general_info g\nINNER JOIN shibui.highlights h ON g.symbol = h.symbol\nLEFT JOIN shibui.valuation v ON g.symbol = v.symbol\nLEFT JOIN shibui.share_stats ss ON g.symbol = ss.symbol\nWHERE g.symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\nORDER BY h.market_capitalization_mln DESC\nLIMIT 10\n```\n\n#### C2: Revenue and margin trend comparison (last 8 quarters)\n```sql\nSELECT i.symbol, i.date,\n  i.total_revenue,\n  ROUND(i.gross_profit / NULLIF(i.total_revenue, 0) * 100, 1) AS gross_margin_pct,\n  ROUND(i.net_income / NULLIF(i.total_revenue, 0) * 100, 1) AS net_margin_pct,\n  ROUND(i.operating_income / NULLIF(i.total_revenue, 0) * 100, 1) AS op_margin_pct\nFROM shibui.income_statement_quarterly i\nWHERE i.symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ')\n  AND i.date >= CURRENT_DATE - INTERVAL '2 years'\n  AND i.total_revenue IS NOT NULL\nORDER BY i.symbol, i.date DESC\nLIMIT 20\n```\n\n#### C3: Price performance comparison (multiple timeframes)\n```sql\nWITH prices AS (\n  SELECT symbol, date, close,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn,\n    FIRST_VALUE(close) OVER (PARTITION BY symbol ORDER BY date ASC) AS start_90d\n  FROM shibui.stock_quotes\n  WHERE symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\n    AND date >= CURRENT_DATE - INTERVAL '90 days'\n),\nprices_1y AS (\n  SELECT symbol,\n    FIRST_VALUE(close) OVER (PARTITION BY symbol ORDER BY date ASC) AS start_1y,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.stock_quotes\n  WHERE symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\n    AND date >= CURRENT_DATE - INTERVAL '1 year'\n)\nSELECT p.symbol,\n  ROUND(p.close, 2) AS current_price,\n  ROUND((p.close - p.start_90d) / NULLIF(p.start_90d, 0) * 100, 1) AS return_90d_pct,\n  ROUND((p.close - y.start_1y) / NULLIF(y.start_1y, 0) * 100, 1) AS return_1y_pct\nFROM prices p\nLEFT JOIN prices_1y y ON p.symbol = y.symbol AND y.rn = 1\nWHERE p.rn = 1\nORDER BY return_90d_pct DESC\nLIMIT 10\n```\n"New value: +"## Comparative Analysis Workflow\n\n### Persona\nYou are an analyst producing peer comparison reports. You focus\non apples-to-apples comparisons - same sector, similar size,\ncomparable business models. You highlight where a company stands\nout (positively or negatively) relative to peers.\n\n### Workflow\n1. **Validate comparability**: Check that companies are in the\n   same or adjacent GICS sector/industry. If not, note\n   that the comparison is cross-sector and metrics may not be\n   directly comparable.\n2. **Size context**: Note market cap differences. A $10B company\n   vs a $500B company will naturally differ in growth rates,\n   margins, and multiples.\n3. **Snapshot comparison**: Pull latest valuation + fundamentals\n   overview fields for all symbols. Compare P/E, EV/EBITDA,\n   margins, return_on_equity.\n4. **Trend comparison**: Compare quarterly revenue and earnings\n   trajectories from fundamentals. Are they converging or diverging?\n5. **Price performance**: Use P2 pattern for returns over same period.\n6. **Relative strengths**: Identify what each company does better.\n   Avoid declaring a \"winner\" - different investors value\n   different attributes.\n\n### Output Format\n- **Comparison Overview**: Brief context on why these companies\n  are being compared (same industry, competitors, etc.)\n- **Snapshot Table**: Side-by-side metrics (inline markdown)\n- **Key Differentiators**: 2-3 sentences on what distinguishes each\n- **Trend Context**: Are the gaps widening or narrowing?\n- **Caveats**: Size differences, data staleness, sector mismatches\n\n### Advanced Query Patterns\n\n#### C1: Side-by-side snapshot (N companies)\n```sql\nWITH latest_val AS (\n  SELECT symbol, market_cap, pe_ratio, price_to_book, peg_ratio,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.valuation WHERE date >= CURRENT_DATE - INTERVAL '7 days'\n),\nlatest_q AS (\n  SELECT symbol, profit_margin, return_on_equity, revenue_growth_yoy,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.fundamentals_quarterly\n  WHERE date >= CURRENT_DATE - INTERVAL '6 months'\n),\nlatest_dd AS (\n  SELECT symbol, ev_ebitda, dividend_yield,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.fundamentals_derived_daily WHERE date >= CURRENT_DATE - INTERVAL '7 days'\n)\nSELECT g.symbol, g.name, g.gics_industry,\n  ROUND(v.market_cap / 1e9, 1) AS market_cap_bln,\n  ROUND(v.pe_ratio, 2) AS pe,\n  ROUND(dd.ev_ebitda, 2) AS ev_ebitda,\n  ROUND(f.profit_margin * 100, 1) AS margin_pct,\n  ROUND(f.return_on_equity * 100, 1) AS roe_pct,\n  ROUND(f.revenue_growth_yoy * 100, 1) AS rev_growth_pct,\n  ROUND(dd.dividend_yield * 100, 2) AS div_yield_pct,\n  os.percent_insiders, os.short_percent_float\nFROM shibui.general_info g\nINNER JOIN latest_val v ON g.symbol = v.symbol AND v.rn = 1\nLEFT JOIN latest_q f ON g.symbol = f.symbol AND f.rn = 1\nLEFT JOIN latest_dd dd ON g.symbol = dd.symbol AND dd.rn = 1\nLEFT JOIN shibui.ownership_stats os ON g.symbol = os.symbol\nWHERE g.symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\nORDER BY v.market_cap DESC\nLIMIT 10\n```\n\n#### C2: Revenue and margin trend comparison (last 8 quarters)\n```sql\nSELECT f.symbol, f.date,\n  f.revenue,\n  ROUND(f.gross_profit / NULLIF(f.revenue, 0) * 100, 1) AS gross_margin_pct,\n  ROUND(f.net_income / NULLIF(f.revenue, 0) * 100, 1) AS net_margin_pct,\n  ROUND(f.operating_income / NULLIF(f.revenue, 0) * 100, 1) AS op_margin_pct\nFROM shibui.fundamentals_quarterly f\nWHERE f.symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ')\n  AND f.date >= CURRENT_DATE - INTERVAL '2 years'\n  AND f.revenue IS NOT NULL\nORDER BY f.symbol, f.date DESC\nLIMIT 20\n```\n\n#### C3: Price performance comparison (multiple timeframes)\n```sql\nWITH prices AS (\n  SELECT symbol, date, close,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn,\n    FIRST_VALUE(close) OVER (PARTITION BY symbol ORDER BY date ASC) AS start_90d\n  FROM shibui.stock_quotes\n  WHERE symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\n    AND date >= CURRENT_DATE - INTERVAL '90 days'\n),\nprices_1y AS (\n  SELECT symbol,\n    FIRST_VALUE(close) OVER (PARTITION BY symbol ORDER BY date ASC) AS start_1y,\n    ROW_NUMBER() OVER (PARTITION BY symbol ORDER BY date DESC) AS rn\n  FROM shibui.stock_quotes\n  WHERE symbol IN ('AAPL.NASDAQ', 'MSFT.NASDAQ', 'GOOGL.NASDAQ')\n    AND date >= CURRENT_DATE - INTERVAL '1 year'\n)\nSELECT p.symbol,\n  ROUND(p.close, 2) AS current_price,\n  ROUND((p.close - p.start_90d) / NULLIF(p.start_90d, 0) * 100, 1) AS return_90d_pct,\n  ROUND((p.close - y.start_1y) / NULLIF(y.start_1y, 0) * 100, 1) AS return_1y_pct\nFROM prices p\nLEFT JOIN prices_1y y ON p.symbol = y.symbol AND y.rn = 1\nWHERE p.rn = 1\nORDER BY return_90d_pct DESC\nLIMIT 10\n```\n"
  4. Changed1 schema field changed
    • addedOutput schema / description
      Added value: +"Generic wrapper for non-object return types."
  5. Added

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources