Skip to main content
Glama

Customer Lifetime Value (LTV)

ps_customer_ltv

Calculate customer lifetime value and segment customers into champion, loyal, at-risk, or lost groups. Saves the KPI report to a dated JSON file for retention analysis.

Instructions

Calculate customer LTV and segment customers.

LTV = avg_order_value × purchase_frequency × lifespan_months

Segments:

  • "champion" : high LTV (top 20%)

  • "loyal" : medium LTV (20–60%)

  • "at_risk" : no purchase in 60+ days but ≥3 previous orders

  • "lost" : no purchase in 60+ days and <3 orders, or bottom 40% LTV

Saves to /data/kpi_ltv_YYYY-MM-DD.json.

Args:

  • limit: Max customers to analyse (default: 500)

  • at_risk_days: Days without purchase to flag as at_risk (default: 60)

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "ps_customer_ltv"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMax customers to analyse
at_risk_daysNoDays without purchase to flag as at_risk

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv3.1.0

TDQS

A3.7/5.0
Behavior4/5

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

Annotations declare readOnlyHint=false, and the description explains why: it 'Saves to /data/kpi_ltv_YYYY-MM-DD.json', disclosing the write side effect and the exact output path. The date-stamped filename also clarifies the non-idempotent behavior. It does not mention permissions, runtime cost of scanning customers, or overwrite semantics for a same-day rerun, which keeps it from a 5.

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 structure is excellent: purpose first, then formula, then segment definitions, then output location, then args. The only waste is the Args block, which duplicates a 100%-covered schema almost verbatim rather than adding interpretation.

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 no output schema, the description compensates well by naming the output file and defining every segment label an agent would need to interpret results. The one gap is ambiguity between segments: 'at_risk' (no purchase 60+ days, ≥3 orders) and 'lost' (bottom 40% LTV) can overlap, and precedence is not stated.

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

Parameters3/5

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

Schema description coverage is 100%, so both parameters are already fully documented with types, defaults, and ranges. The Args section restates those same defaults and adds little new meaning, though the segment rules do implicitly explain how at_risk_days is consumed. Baseline 3 is appropriate when the schema carries the weight.

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?

The description gives a specific verb+resource ('Calculate customer LTV and segment customers') and goes further by spelling out the exact LTV formula and the four segment labels with their thresholds. An agent knows precisely what computation happens. It does not reference any sibling tool, so it stops short of the sibling-differentiation bar for 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 Guidelines3/5

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

Usage is implied rather than stated: the segment definitions make clear this is the tool for LTV/segmentation work, and the defaults (500 customers, 60 days) suggest typical use. However, there is no explicit 'use this instead of X' routing, no stated prerequisites, and no guidance on when the analysis would be inappropriate.

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

Deploy Server

Other Tools