Skip to main content
Glama
grahammccain

Chart Library

cohort

Read-onlyIdempotent

Analyzes historical analogs for a given stock anchor, returning outcome distributions (p10-p90, win rate) and feature importance. Compares cohorts or stratifies by regime for deeper insight.

Instructions

Conditional-distribution analysis — the Chart Library core primitive.

Three depth modes:

  depth="basic" (default, fast ~50ms):
    Returns kNN cohort + outcome distribution (p10/p25/p50/p75/p90,
    win rate, MAE, MFE) + survivorship. Supply cohort_id (refine
    prior cohort) OR query OR symbol+date.

  depth="full" (Layer 3, ~280ms, paid tier):
    Returns the basic outputs PLUS feature importance (which Layer 2
    features separated winners from losers within this cohort),
    regime stratification (outcomes sliced by vol/macro), risk
    profile (drawdown / runup percentiles), and cohort tightness
    score. Requires symbol+date+timeframe (cohort_id alone isn't
    enough — the Layer 3 analyzer needs the full anchor).

  depth="compare" (~400ms):
    Compare TWO anchors' cohorts side-by-side. Pass symbol+date for
    the primary AND compare_with={"symbol":..., "date":...,         "timeframe":...} for the secondary. Returns both cohorts'
    distributions plus a delta summary.

Filters (Layer 2 metadata constraints):
    vol_regime: list of "low"/"mid"/"high"
    macro_state: list of "bullish"/"neutral"/"bearish"
    has_news: bool
    days_since_earnings / days_since_ath / sector_rs /
        realized_vol / relative_volume: dict with "min" / "max"

Empirical-distribution analysis only. Does NOT predict a single
point return; surfaces what historical analogs did and which features
separated them.

Args:
    symbol, date, timeframe: anchor (default timeframe "1h")
    query: alt to symbol+date, "SYMBOL YYYY-MM-DD"
    cohort_id: refine a stored cohort (basic mode only)
    depth: "basic" | "full" | "compare"
    filters: Layer 2 constraints
    horizons: forward horizons in trading days (default [5, 10] for
        basic, [1, 5, 10] for full)
    cohort_size: target K (10-2000)
    compare_with: secondary anchor for depth="compare"
    include_feature_importance, include_regime_stratification,
        include_risk_profile: full-mode toggles
    exclude_same_symbol_days: drop same-symbol analogs within N
        calendar days of the anchor (autocorrelation control;
        default 10)
    include_path_stats: include MAE/MFE/realized-vol (basic mode)
    fields: full-mode only — optional allowlist of top-level
        response keys to return. None (default) = full payload.
        Valid: outcome_distribution, feature_importance,
        regime_stratification, risk_profile, cohort_tightness_score,
        cohort_score, combined_conviction, pulse_boost,
        narrative_pulse, cohort_anchors, anchor_metadata. Use to
        slim the JSON when you only need a subset (e.g.
        fields=["outcome_distribution"] drops 97% of bytes).
        anchor, cohort_size_actual, elapsed_ms, warnings are
        always returned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNo
dateNo
timeframeNo1h
queryNo
cohort_idNo
depthNobasic
filtersNo
horizonsNo
cohort_sizeNo
compare_withNo
include_feature_importanceNo
include_regime_stratificationNo
include_risk_profileNo
exclude_same_symbol_daysNo
include_path_statsNo
fieldsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

Annotations already mark it as readOnlyHint=true, idempotentHint=true, and destructiveHint=false. The description adds extensive behavioral context, such as latency estimates, parameter dependencies, filtering constraints, the empirical nature of the analysis, and the fields parameter for response sliming. No contradictions with annotations.

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?

The description is well-structured with sections, bullet points, and bold text for emphasis. It is relatively long but appropriate for the tool's complexity. However, some redundancy exists (e.g., repeating the depth modes in different sections), and it could be slightly more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite 16 parameters and no schema descriptions, the description covers all aspects comprehensively: modes, filters, toggles, and response fields. Output schema exists (though not provided) but the description focuses on inputs and behavioral completeness, which is sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% description coverage, but the description thoroughly explains all 16 parameters, their roles, defaults, and valid values. For example, it clarifies that query is an alternative to symbol+date, that filters accept dictionaries with min/max, and provides a list of valid fields. This adds substantial meaning beyond the raw schema.

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 the tool's function as 'Conditional-distribution analysis' and details three depth modes (basic, full, compare) with explicit descriptions. It is a specific verb+resource and distinguishes between different modes of operation, though it does not directly compare to sibling tools like cohort_analyze or cohort_compare.

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 provides explicit guidance on when to use each depth mode, including constraints like 'cohort_id alone isn't enough for full mode'. It also clarifies what the tool does not do ('Does NOT predict a single point return'). However, it does not explicitly contrast with sibling tools, which slightly reduces the score.

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/grahammccain/chart-library-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server