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

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -{
      -  "properties": {
      -    "result": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "result"
      -  ],
      -  "type": "object",
      -  "x-fastmcp-wrap-result": true
      -}New value: +null
  2. Changed2 schema fields changed
    • addedInput schema / additionalProperties
      Added value: +false
    • removedOutput schema / description
      Removed value: -"Generic wrapper for non-object return types."
  3. 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"
      -}
  4. 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"
  5. Changed1 schema field changed
    • addedOutput schema / description
      Added value: +"Generic wrapper for non-object return types."
  6. Added

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnly/idempotent/non-destructive, so safety is covered. The description adds genuinely non-annotated behavior: a hard dependency on two prior tool calls in a fixed order, plus the note that it composes with other workflow tools. It still doesn't say what the loaded workflow returns or whether it mutates conversation state.

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 dense sentences, front-loaded with the prerequisite requirement and trigger conditions, with no filler. It is somewhat list-heavy, but every clause carries routing or dependency information.

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 zero-parameter loader with no output schema, the critical information an agent needs is when to invoke it and what must precede it, and both are fully covered. The remaining gap is that the description never says what 'loading' produces (patterns, SQL templates, guidance), which would help an agent anticipate the next step.

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 schema takes zero parameters, so there is nothing for the description to disambiguate; baseline for a parameterless tool is 4. No parameter-level meaning is added or needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (load comparison workflow) plus its domain (peer analysis, relative valuation, X vs Y), which clearly separates it from load_earnings_workflow, load_technical_workflow and the other siblings. What a 'workflow' actually contains is left implicit, so it falls just short of a 5.

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 states the required prerequisite chain ('REQUIRES get_database_schema then get_query_patterns ... in that order') and the exact moment to call it ('BEFORE writing SQL'), then enumerates concrete user phrasings that trigger it. When-to-use is unambiguous and the ordering constraint is spelled out rather than implied.

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.

Resources