You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add compact mode to strip null/empty values from responses
Adds stripEmpty() utility that recursively removes null and "" values
from all MCP tool responses by default, reducing token usage ~15-20%.
false is preserved (semantic meaning). Agents can pass compact=false
for raw data on 7 data-heavy GET tools.
- Extract stripEmpty() to src/utils/compact.js
- Apply via wrapHandler() on all 28 tools
- Add compact parameter to list/get tools for forms, entries, feeds
- Add 17 unit tests for compact utility
- Update AGENTS.md, CLAUDE.md with compact documentation
@@ -121,6 +123,7 @@ Responses are optimized for minimal token usage:
121
123
-**Compact JSON**: `JSON.stringify(result)` — no pretty-printing (no `null, 2`) — `src/index.js:114`
122
124
-**Minimal payloads**: No redundant `message`, `created`/`updated` booleans, or echo-back of input IDs. GET methods return `{ resource: data }`, mutations return only what can't be inferred (e.g., delete returns `{ deleted: true, id, permanently }`)
123
125
-**Summary/detail modes**: `gf_list_field_types` defaults to summary mode (`type`, `label`, `category` only). Pass `detail=true` for full metadata (supports, storage, validation, icon). Pass `include_variants=true` with `detail=true` for variant data.
126
+
-**Compact mode (default on)**: `stripEmpty()` (`utils/compact.js`) recursively removes `null` and `""` values from all responses via `wrapHandler()`. `false` is preserved (semantic meaning, e.g. `is_active: false`). `"0"`/`"1"` strings are preserved (GF boolean pattern). Data-heavy GET tools expose a `compact` parameter — pass `compact=false` for raw unstripped data.
124
127
-**Concise tool descriptions**: All 28 tool descriptions and property descriptions are terse to reduce tool-list overhead
@@ -35,3 +35,4 @@ Required env vars (see `.env.example` for full list):
35
35
5.**Update operations fetch-then-merge** — always GET existing data first to avoid data loss
36
36
6.**Minimize response tokens** — no pretty-print (`JSON.stringify(result)` not `null, 2`), no redundant `message` strings, no echo-back of input IDs, no `created`/`updated` booleans. Return only essential data.
37
37
7.**Keep tool descriptions terse** — every token in tool schemas is sent on every `tools/list` call
38
+
8.**Compact mode strips null and empty strings** — `stripEmpty()` in `utils/compact.js` runs on all responses by default. `false` is preserved (semantic meaning). Agents pass `compact=false` for raw data.
"test:all": "npm run test:unit && npm run test:auth && npm run test:forms && npm run test:entries && npm run test:feeds && npm run test:submissions && npm run test:validation && npm run test:field-validation && npm run test:tools && npm test",
27
28
"test:coverage": "echo 'Running all tests with coverage analysis' && npm run test:all"
0 commit comments