analytics_query
Referência da tool analytics_query do MCP Server do bitERP (Indicadores).
Query Analytics · Indicadores
| Somente leitura | Destrutiva | Idempotente | Mundo aberto |
|---|---|---|---|
| Sim | Não | Sim | Não |
Descrição
A descrição abaixo é a que o servidor publica, em inglês, e é o texto que o agente lê para decidir quando usar a tool.
Aggregated analytics over the tenant data (revenue, count, avg ticket, MRR, ARR) by period, customer, product or time. Closed vocabulary; invalid combos are rejected.
Parâmetros
| Parâmetro | Tipo | Obrigatório | Descrição |
|---|---|---|---|
tenant | string | Sim | Defines which tenant will have data read or changed. Use list_tenants first and prefer the returned tenant slug. Writes are permanent, so when the user has more than one tenant you must confirm the tenant before any write and never assume or reuse a previous choice without confirmation. UUID is accepted only when already known safely. |
source | string | Sim | sales_orders=sold, invoices=billed, receivables=received by customer, cash_inflow=cash inflow, cash_outflow=cash outflow (cash lenses: asset accounts only; card statement payments count as outflow), subscriptions=MRR/ARR stock lens Valores: sales_orders, invoices, receivables, cash_inflow, cash_outflow, subscriptions. |
metric | string | Sim | flow: revenue|count|avg_ticket; receivables also offset_amount (credit-note compensation); subscriptions: mrr|arr|count Valores: revenue, count, avg_ticket, offset_amount, mrr, arr. |
period | string | Sim | today | yesterday | this_week | last_week | last_7_days | this_month | last_month | last_30_days | last_3_months | this_year | all_time | custom Valores: today, yesterday, this_week, last_week, last_7_days, this_month, last_month, last_30_days, last_3_months, this_year, all_time, custom. |
range | object | Não | Required when period=custom (ISO dates) |
range.start | string | Sim | — |
range.end | string | Sim | — |
group_by | string | Não | time | customer | product (absent = single total) Valores: time, customer, product. |
granularity | string | Não | day | week | month | quarter | year — only with group_by=time Valores: day, week, month, quarter, year. |
customer_id | string (UUID) | Não | Filter by one customer (not allowed for cash_inflow/cash_outflow |
limit | integer | Não | Cut rankings (default 10) |
currency | string | Não | ISO 4217 target currency; only with source=subscriptions and metric mrr|arr (not count; default: tenant currency) |
Resposta
O structuredContent da resposta traz os campos abaixo (até dois níveis; o schema completo está no outputSchema publicado no tools/list).
| Campo | Tipo | Descrição |
|---|---|---|
rows | array de objetos | — |
rows[].label | string | — |
rows[].value | string | — |
rows[].count | number | — |
rows[].customer_id | string (UUID) | — |
rows[].product_id | string (UUID) | — |
rows[].bucket_start | string | — |
rows[].bucket_end | string | — |
meta | object | — |
meta.source | string | Valores: sales_orders, invoices, receivables, cash_inflow, cash_outflow, subscriptions. |
meta.metric | string | Valores: revenue, count, avg_ticket, offset_amount, mrr, arr. |
meta.currency | string | — |
meta.period | object | — |
meta.group_by | string | Valores: time, customer, product. |
meta.granularity | string | Valores: day, week, month, quarter, year. |
meta.percentage | string | — |
meta.note | string | — |
Exemplo de chamada
Requisição tools/call com os parâmetros obrigatórios. Os valores são ilustrativos: troque minha-empresa pelo tenant devolvido por list_tenants e cada <...> por um valor real.
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "analytics_query",
"arguments": {
"tenant": "minha-empresa",
"source": "sales_orders",
"metric": "revenue",
"period": "today"
}
}
}
