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. Dates show when Glama detected each change.

  1. 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"
      -}
  2. 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"
  3. Changed1 schema field changed
    • addedOutput schema / description
      Added value: +"Generic wrapper for non-object return types."
  4. Added

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive. Description adds the ordering dependency and position in the query workflow, which is behavioral context beyond annotations. It does not contradict and provides useful operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each serving a distinct purpose: definition, prerequisites, and usage triggers. Slightly verbose with the trigger phrase list but still efficient and well-structured.

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?

With output schema present and annotations covering safety, description addresses prerequisites, timing, and combination with other tools. It is sufficiently complete for a zero-parameter loader tool, though it doesn't describe the workflow contents in detail.

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?

Tool has zero parameters, so the schema fully covers semantics. Baseline 4 applies; description need not explain inputs. No additional parameter information required.

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?

Description clearly states it 'Load comparison workflow' for 'X vs Y, peer analysis, relative valuation', naming the specific resource and purpose. It distinguishes from sibling workflow tools by focusing on comparison, with explicit trigger phrases.

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?

Explicit prerequisites: 'REQUIRES get_database_schema then get_query_patterns to be called first (in that order)' and timing: 'Call BEFORE writing SQL'. Also states combinability with other workflow tools, covering both when and how to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A4.4/5.0
Disambiguation4/5

Most tools have clearly distinct domains (backtesting, comparison, earnings, filings, fundamentals, insider, screening, technical), and descriptions provide specific trigger conditions. However, stock_data_query and export_to_excel are very similar (same query, different output), and some workflow boundaries overlap (e.g., earnings vs. fundamental both mention revenue trends; filing vs. insider both involve SEC documents).

Naming Consistency3/5

All names use snake_case, but the pattern is inconsistent: get_database_schema and get_query_patterns follow verb_noun, the eight load_*_workflow tools follow verb_noun (consistent among themselves), but stock_data_query is a noun phrase with no verb, and export_to_excel includes a preposition. The mixed conventions are still readable but not uniform.

Tool Count4/5

At 12 tools, the count is within the expected 3-15 range and appropriate for the broad scope of comprehensive stock analysis. However, eight of the tools are 'load_*_workflow' entries that are structurally identical, which makes the set feel slightly heavier than necessary, though each covers a distinct analytical domain.

Completeness5/5

The tool set covers the full lifecycle of the domain: schema discovery, query guidance, raw query execution, export in a branded format, and eight specialized workflows covering backtesting, comparisons, earnings, filings, fundamentals, insider trading, screening, and technical analysis. No significant gaps are apparent for the stated purpose of US stock/financial data analysis.

Resources