funifier-mcp 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "funifier-mcp",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "Funifier AI toolkit — MCP server, API client, and Claude Code skills for the Funifier gamification platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,6 +63,8 @@ If search returns insufficient results, read these directly:
63
63
 
64
64
  ## Steps
65
65
 
66
+ > **Prepared aggregate** = pipeline MongoDB salvo na plataforma com `_id` e executado por ID via `POST /v3/find/<id>`, com parâmetros dinâmicos (`"$param:nome"`). Diferente do aggregate **ad-hoc** (`POST /v3/database/{collection}/aggregate`), usado para testar pipelines.
67
+
66
68
  ### Coleções principais
67
69
 
68
70
  | Coleção | Conteúdo chave |
@@ -148,3 +150,29 @@ funifier_save type=aggregate payload=<json>
148
150
  ```
149
151
  funifier_list type=aggregate search=<titulo>
150
152
  ```
153
+
154
+ ### 6. Executar o Prepared Aggregate
155
+
156
+ **Endpoint correto:** `POST /v3/find/<id>` com os parâmetros no corpo JSON.
157
+
158
+ > ⚠️ NÃO use `GET /v3/database/aggregate/{id}` — retorna null/405 silenciosamente, sem mensagem de erro. O endpoint de execução foge do padrão CRUD da plataforma.
159
+
160
+ Via MCP (`params` é uma string JSON):
161
+ ```
162
+ funifier_execute type=aggregate id=<id> params={"player":"abc"}
163
+ ```
164
+
165
+ Via frontend:
166
+ ```js
167
+ api.post('/v3/find/<id>', { player: 'abc' })
168
+ ```
169
+
170
+ | Regra | Detalhe |
171
+ |-------|---------|
172
+ | Método HTTP | POST obrigatório |
173
+ | Params | No corpo JSON — não na query string |
174
+ | Substituição | Cada chave do corpo substitui `"$param:<chave>"` no pipeline diretamente |
175
+ | `context` no Groovy | Só expõe o player autenticado — `context.get("outro")` retorna `null` |
176
+ | Script vazio | Se o pipeline só usa `"$param:nome"`, o `script` pode ser `""` — não precisa de `prepare()` |
177
+
178
+ Se o resultado vier vazio ou inesperado: `GET /v3/find/<id>/params` lista os params que o pipeline espera, e `POST /v3/prepared/aggregate/<id>/analyze` (mesmo corpo da execução) retorna outputs/exceções do script e o resultado de cada etapa do pipeline (`aggregate_step_N`) — veja `references/debug.md`.
@@ -34,7 +34,8 @@ If search returns insufficient results, read these directly:
34
34
  |---|---|
35
35
  | Trigger, Scheduler | `funifier_logs type=trigger id=<_id>` / `funifier_logs type=scheduler id=<_id>` |
36
36
  | Challenge, Level, Action | `funifier_get type=<type> id=<_id>` — verificar campos |
37
- | Aggregate | Testar via `POST /v3/database/<collection>/aggregate` |
37
+ | Aggregate ad-hoc | Testar via `POST /v3/database/<collection>/aggregate` |
38
+ | Prepared aggregate | `GET /v3/find/<id>/params` (params esperados) e `POST /v3/prepared/aggregate/<id>/analyze` (outputs/exceções do script + resultado de cada etapa do pipeline em `aggregate_step_N`) |
38
39
  | Frontend auth | Verificar role scope inclui `database` se usar `/v3/database` |
39
40
 
40
41
  ### Problemas comuns
@@ -49,6 +50,8 @@ If search returns insufficient results, read these directly:
49
50
  | `/v3/database` retorna vazio | Scope `database` ausente na role | Adicionar `database` ao scope via Security |
50
51
  | Filtro por data não encontra registros | Campo foi salvo como string ISO ou parâmetro ISO foi usado dentro de `$date` sem normalização | Salvar como `{ "$date": "<ISO UTC>" }`; em prepared aggregate converter ISO com `DateUtil.parse` no script |
51
52
  | Prepared aggregate com data absoluta falha/retorna vazio | `"$param:start"` dentro de `{ "$date": ... }` recebeu string ISO | Converter no `script` para `Date` e usar `"$gte":"$param:start"` diretamente |
53
+ | Prepared aggregate retorna null/405 sem erro | Execução via `GET /v3/database/aggregate/{id}` — endpoint errado | Executar com `POST /v3/find/<id>`, params no corpo JSON |
54
+ | Prepared aggregate retorna vazio | Nome de param divergente ou etapa do pipeline filtra tudo | `GET /v3/find/<id>/params` para conferir nomes; `POST /v3/prepared/aggregate/<id>/analyze` e achar a primeira `aggregate_step_N` vazia |
52
55
 
53
56
  ---
54
57
 
@@ -28,7 +28,7 @@ If search returns insufficient results, read these directly:
28
28
  |---|---|
29
29
  | Criar trigger com Groovy | `references/create-trigger.md` |
30
30
  | Criar scheduler/cron job | `references/create-scheduler.md` |
31
- | Criar aggregate/relatório | `references/create-aggregate.md` |
31
+ | Criar prepared aggregate (relatório/consulta salva) | `references/create-aggregate.md` |
32
32
  | Criar desafio/missão | `references/create-challenge.md` |
33
33
  | Criar ação rastreável | `references/create-action.md` |
34
34
  | Criar sistema de pontos | `references/create-point.md` |