Skip to main content
Glama

Run purchase count analysis

run_num_of_purchases_analysis
Read-only

Num of Purchases Analysis (첫구매/재구매 · 구매회차)

When to use: 사용자가 '첫구매 vs 재구매' 비중, '구매 N회차별' 매출/객단가/구매자수 같은 구매 순번(num_of_purchases) 기반 분석을 원할 때. 신규/재구매 코호트, 회차별 리텐션/객단가 변화를 측정하고 싶을 때 호출.

When NOT to use: A/B 상품 함께 구매(basket) 패턴은 cross-selling. 일반 시계열 매출 추이는 query_dashboard. 코호트 LTV/리텐션은 cohort. 브랜드·상품·채널별 재구매 주기(다음 구매까지 일수)는 run_order_cycle_analysis — 이 tool 의 재구매 비중(첫구매 vs 재구매, N회차별)과는 다른 지표다.

Limitations: 회차 정의는 index_dimensions/pivot_dimensions 에 'num_of_purchase_type'(첫구매/재구매) 또는 'num_of_purchases'(N회차) 파생 차원 문자열을 직접 포함해야 결정된다. view_option 은 advisory 힌트일 뿐 서버 side-effect 가 없다(분석 기준을 바꾸지 않음). rank_method (history/freq), num_of_count_type (any/a_a), n (1..50) 로 회차 집계 방식이 달라진다. '그룹 내 구성비'(첫구매/재구매 비중 등)는 더 이상 서버 *_per SQL 컬럼으로 계산되지 않는다 — measures 는 base measure(sales, pay_cnt, aov 등)만 요청하고, 비중은 요청의 percentage_by(partitions 지정) 경로로 서버가 제공한다. 단, percentage_by(및 distance_by) 후처리는 orient="split" 요청에서만 실행되며, 기본값인 orient="pv" 요청에서는 no-op 이다 — 비중이 필요하면 반드시 orient="split" 을 함께 지정해야 한다. 레거시 호환을 위해 *_per measure 요청 자체는 orient 와 무관하게 여전히 200 을 반환하지만 동작이 orient 별로 다르다: orient="pv" 는 base/total 값에서 재구성한 실값으로 응답하고, orient="split" 은 measures/meta_data/columns/data 에서 조용히 drop 한다. 신규 호출에는 percentage_by 사용을 권장한다 — *_per 는 deprecated. 단, percentage_by 의 분모는 파티션 내 각 행의 절대값을 더한 값(x.abs().sum())이고 레거시 *_per 는 부호 있는 SUM(x) 기준이라, 파티션 내에 부호가 섞인(음수 per-group 행이 하나라도 있는) 경우 두 값이 갈릴 수 있다 — 파티션 합 자체가 양수여도 발생할 수 있다(예: [+100,-40,+60], 합계 120>0 이어도 abs 분모와 signed 분모가 달라짐). 응답은 split-pivot shape (index / columns / data 행렬).

Examples:

  • Q: 2024년 4분기 첫 구매와 재구매 비중, 구매 횟수별 매출과 객단가를 알려줘 params: {'body': {'freq': '-', 'data_source': 'commerce_order', 'date_filters': {'start_date_id': '2024-10-01', 'end_date_id': '2024-12-31'}, 'view_option': 'num_of_purchase_type', 'index_dimensions': ['num_of_purchase_type'], 'pivot_dimensions': [], 'measures': ['sales', 'pay_cnt', 'aov'], 'rank_method': 'history', 'num_of_count_type': 'any', 'n': 20}}

Related resources: analytics://overview, analytics://schema/data_source

Output shape: split-shape JSON: { index: [...], columns: [...], data: ..., dimensions, index_dimensions, pivot_dimensions, measures, meta_data, masked_columns, source_match_columns }

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "project-id": "<project-id>",
      "date_filters": "<date_filters>"
    },
    "name": "run_num_of_purchases_analysis"
  }
}

Input Schema

NameRequiredDescriptionDefault
nNo최대 구매 회차 (1..50)
stdNosince_time 상한 (기준값)
freqNo시간 빈도 (-, days, weeks, months, quarters, years)days
orientNo응답 포맷: pv(레거시 피벗 호환, 기본) / split(커스텀 대시보드). percentage_by/distance_by 파생 컬럼 후처리는 orient=split 에서만 동작하며, 기본값 pv 에서는 no-op 이다. legacy `<base>_per` 요청도 orient 에 따라 동작이 다르다: pv 는 base/total 에서 값을 재구성해 응답하고, split 은 조용히 drop 한다. 출력 `time_id` 라벨 포맷도 orient 에 따라 다르다: split 은 acc(freq='-') 를 제외한 모든 freq 에서 default analytics 와 같은 밀리초 타임스탬프 라벨 'YYYY-MM-DD HH:MM:SS.mmm' 을 내리고(acc 는 리터럴 '-' 유지), pv 는 레거시 freq별 모양을 그대로 유지한다(years=bigint 2026, quarters='2026-Q1', months/weeks/days='YYYY-MM-DD').pv
filtersNodefault analytics 와 동일한 ExpressionTree(JSON) 필터. 모든 연산자 (IN/EQ/포함/비교 등)를 raw 스캔 WHERE 로 적용한다(집계 전).
measuresNo측정 지표 목록. dashboard/meta/v1 등록 measure(또는 그 _per 비율 파생)만 허용되며, 미등록 식별자는 HTTP 400 으로 거부된다(validation.py allowlist — SQL injection 방어). sales 강제 포함
project-idYes
data_sourceNo데이터 소스 (commerce_order / commerce_item_order)commerce_order
distance_byNo사분면/버블 x/y 축 measure. 그 외 차트타입은 빈 목록.
is_refundedNo환불/취소 주문 제외 여부 (exemption=제외(기본) / inclusion=포함)exemption
rank_methodNoN회차 회차집계 (history / freq)history
view_optionNo분석 기준 힌트 (advisory-only, 서버 side-effect 없음). 실제 분석 기준은 index_dimensions 또는 pivot_dimensions 에 'num_of_purchase_type'(첫구매/재구매) 또는 'num_of_purchases'(N회차) 파생 차원 문자열을 직접 포함시켜야 결정된다.num_of_purchase_type
date_filtersYes조회 기간
distance_fromNo사분면/버블 거리 기준 집계 (average/median). 그 외 차트타입은 빈 목록.
percentage_byNo파레토 누적%/ABC 그룹 기준 measure. 그 외 차트타입은 빈 목록. orient=split 요청에서만 적용되며, 기본값 orient=pv 에서는 no-op 이다.
max_date_rangeNo날짜 필터 무시 (전체 범위) 여부
num_of_count_byNoA→A 의 기준 차원(A). 미전송이면 요청 차원에서 파생 차원을 제외해 추론(deprecated). a_a 와 함께 빈 배열을 보내면 400.
since_time_typeNosince_time 축 유형rolling
index_dimensionsNopivot 행 축 (index_dimensions)
pivot_dimensionsNopivot 열 축 / 분석 단위 / BreakDown (pivot_dimensions)
pop_date_filtersNo직전 대비(PoP) 비교 기간. default DashboardRequest 와 동형. orient=split 요청에서만 prev_/prev_diff_/pct_change_ 파생 컬럼을 만든다. 최대 5개까지 허용한다 — 항목마다 이전 기간 STAT 쿼리가 한 번씩 추가로 실행되므로 무제한 허용 시 쿼리가 증폭된다.
time_series_typeNo시계열 기준date_range
num_of_count_typeNo재구매 판단조건 (any / a_a)any
num_of_purchase_type_filterNo첫구매/재구매 세그먼트 필터 (관점 셀렉터). None=전체

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the readOnlyHint annotations, it discloses that view_option is advisory-only with no server side-effect, that percentage_by/distance_by are no-ops unless orient="split", that legacy *_per measures are deprecated and dropped under split, and that percentage_by uses an absolute-value denominator while legacy *_per uses signed SUM — a real behavioral trap an agent could not infer otherwise.

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

Conciseness3/5

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

Purpose and when-to-use are well front-loaded, but the Limitations block is a dense run-on that mixes deprecation policy, denominator math, and response shape in one paragraph, and it repeats the orient=split no-op rule already stated in the schema. Several sentences could be trimmed or split.

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 24 parameters and deeply nested objects, the description covers the analysis-grain mechanics, deprecation path, response shape, and a full worked example with concrete params, so an agent has enough to construct a correct call even before consulting the output schema.

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?

Schema coverage is 96%, so the baseline is 3, but the description adds genuine meaning: that num_of_purchase_type/num_of_purchases must be placed in index_dimensions or pivot_dimensions for the analysis grain to be determined, and the abs-vs-signed denominator divergence for percentage_by that the schema does not mention. It stops short of covering several of the 24 params (freq, since_time_type, pop_date_filters) in prose.

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 names a specific analysis verb and resource (num_of_purchases / first-purchase vs repurchase, N-th purchase) and explicitly distinguishes it from cross-selling basket analysis, query_dashboard time series, cohort LTV, and run_order_cycle_analysis repurchase-cycle metrics.

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?

Has explicit 'When to use' and 'When NOT to use' sections that name the alternative tool for each excluded case (cross-selling, query_dashboard, cohort, run_order_cycle_analysis) and the condition that selects them.

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