suppa-mcp-2 1.28.0 → 1.29.0

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/README.md CHANGED
@@ -1,659 +1,716 @@
1
- # suppa-mcp-2
2
-
3
- MCP (Model Context Protocol) server for the **Suppa 2.0** platform ([modern.suppa.me](https://modern.suppa.me)).
4
- Allows LLMs (Claude, GPT, Copilot, Cursor, etc.) to manage Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments through standardised MCP tools — with multi-tenant Google authentication.
5
-
6
- This is the Node.js/TypeScript port of the Python [`suppa-mcp`](https://pypi.org/project/suppa-mcp/) package, published to npm as **`suppa-mcp-2`**.
7
-
8
- [![npm version](https://img.shields.io/npm/v/suppa-mcp-2)](https://www.npmjs.com/package/suppa-mcp-2)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
10
-
11
- ---
12
-
13
- ## Quick start
14
-
15
- ### Run directly with npx
16
-
17
- ```bash
18
- npx suppa-mcp-2
19
- ```
20
-
21
- ### Or install from npm
22
-
23
- ```bash
24
- npm install -g suppa-mcp-2
25
- ```
26
-
27
- No API key needed to start — the server authenticates interactively via the `suppa_login` tool (see [Authentication](#authentication)).
28
-
29
- ---
30
-
31
- ## Authentication
32
-
33
- There is **no API key to paste**. Run the **`suppa_login`** tool from your MCP client — it opens a browser for Google sign-in, then stores the resulting tokens in the OS keychain (Windows Credential Manager / macOS Keychain / libsecret). The server is **multi-tenant**: log in to more than one Suppa tenant and switch with `suppa_use_tenant`.
34
-
35
- Credentials stay on your machine, are sent only in the `Authorization` header to your configured `SUPPA_BASE_URL`, and are **never** exposed to the AI agent. A `SUPPA_API_KEY` env var is an optional CI-only alternative.
36
-
37
- ---
38
-
39
- ## Configuration
40
-
41
- All variables are optional — the server works out of the box and authenticates via `suppa_login`.
42
-
43
- | Variable | Default | Description |
44
- |---|---|---|
45
- | `SUPPA_BASE_URL` | `https://modern.suppa.me` | Platform base URL (the active tenant) |
46
- | `SUPPA_API_KEY` | (none) | JWT / API key; skips interactive login when set (CI) |
47
- | `SUPPA_REFRESH_TOKEN` | (none) | Refresh token; paired with `SUPPA_API_KEY` for long-lived CI sessions |
48
- | `SUPPA_LANG` | `en` | Language (`en` / `uk`) |
49
- | `SUPPA_LANGS` | (auto) | Languages a multi-language title/Name is written into. When unset, resolved from the platform (the languages already used by existing entity titles), falling back to `en,uk`. Set e.g. `en,uk` to force it. |
50
- | `SUPPA_TZ` | `Europe/Kyiv` | Timezone |
51
- | `SUPPA_MCP_LOGIN_PORT` | `8080` | Local loopback port for the browser login callback |
52
- | `SUPPA_MCP_HOME` | `~/.suppa-mcp` | Directory for the tenant registry |
53
- | `SUPPA_HTTP_TIMEOUT` | `60` | Per-request timeout, seconds |
54
- | `SUPPA_MCP_DEBUG` | (off) | `1` logs each request line to stderr |
55
-
56
- ---
57
-
58
- ## Use with Claude Desktop
59
-
60
- Add to your `claude_desktop_config.json`:
61
-
62
- ```json
63
- {
64
- "mcpServers": {
65
- "suppa-2.0": {
66
- "command": "npx",
67
- "args": ["-y", "suppa-mcp-2"]
68
- }
69
- }
70
- }
71
- ```
72
-
73
- ## Use with Cursor
74
-
75
- Add to `.cursor/mcp.json` in your project:
76
-
77
- ```json
78
- {
79
- "mcpServers": {
80
- "suppa-2.0": {
81
- "command": "npx",
82
- "args": ["-y", "suppa-mcp-2"]
83
- }
84
- }
85
- }
86
- ```
87
-
88
- ## Use with VS Code (Copilot)
89
-
90
- Add to `.vscode/mcp.json`:
91
-
92
- ```json
93
- {
94
- "servers": {
95
- "suppa-2.0": {
96
- "command": "npx",
97
- "args": ["-y", "suppa-mcp-2"]
98
- }
99
- }
100
- }
101
- ```
102
-
103
- Then run **`suppa_login`** once per tenant to authenticate.
104
-
105
- ---
106
-
107
- ## Which version is running (and is it current)
108
-
109
- An MCP client keeps whatever build it started with — an `npx` cache or a
110
- `node_modules` copy — for the whole session. Publishing a fix changes nothing
111
- for that session, so "the fix isn't working" and "I'm running last week's
112
- server" look identical from the inside. Two mechanisms keep them apart:
113
-
114
- - **`suppa_version`** — read-only, asks the npm registry live, and reports the
115
- running version, the published one, and the upgrade command. Ask it first
116
- whenever a tool or behaviour you expect is missing. `suppa_health_check` also
117
- carries `version` in every report, so a bug report names its build without
118
- anyone remembering to ask.
119
- - **An automatic notice.** The server checks the registry in the background
120
- (detached, cached for 6h, 4s timeout, silent when offline — startup never
121
- waits). If the running build is behind, the next session's instructions open
122
- with an `OUTDATED` banner telling the agent to say so in its first reply, and
123
- to restart the client after updating.
124
-
125
- Upgrading: `npm i -g suppa-mcp-2@latest`, or pin `suppa-mcp-2@latest` in the
126
- client's MCP config — then **restart the client**. Without the restart the old
127
- process, and its old code, keep serving the session.
128
-
129
- On the source side, the version is stated in `package.json` **only**.
130
- `scripts/check-version-literals.mjs` runs inside `npm test` (and so inside
131
- `prepublishOnly`) and fails the build if a version string is typed into `src/`:
132
- the handshake once announced a hardcoded `1.6.1` for every release after it,
133
- which made the one diagnostic question unanswerable.
134
-
135
- ## Agent workflow
136
-
137
- When an AI agent connects, the server provides built-in instructions describing the correct workflow. Auth first, then discover schema before reading or writing data:
138
-
139
- ```
140
- ┌─────────────────────────────────────────────────────────┐
141
- │ 0. AUTHENTICATE (once per tenant) │
142
- │ suppa_login — Google browser sign-in │
143
- │ suppa_use_tenant — switch active tenant │
144
- ├─────────────────────────────────────────────────────────┤
145
- │ 1. DISCOVER ENTITIES │
146
- │ suppa_list_entities(search?: "task") │
147
- │ suppa_search_entities — fuzzy-find + record count │
148
- ├─────────────────────────────────────────────────────────┤
149
- │ 2. DISCOVER FIELDS │
150
- │ suppa_describe_entity(entity_name) │
151
- │ suppa_list_field_types / suppa_list_tabular_parts │
152
- ├─────────────────────────────────────────────────────────┤
153
- │ 3. READ DATA │
154
- │ suppa_search_records / suppa_get_record │
155
- │ suppa_search_tasks / suppa_get_task / … │
156
- │ suppa_list_docs / suppa_read_page / suppa_get_blocks │
157
- │ suppa_list_automations / suppa_get_automation │
158
- ├─────────────────────────────────────────────────────────┤
159
- │ 4. WRITE DATA (destructive/edit tools are confirm-gated)│
160
- │ suppa_create_record / suppa_update_record │
161
- │ suppa_copy_record / suppa_restore_record │
162
- │ suppa_create_entity / suppa_add_field │
163
- │ suppa_create_automation / suppa_publish_automation │
164
- └─────────────────────────────────────────────────────────┘
165
- ```
166
-
167
- > **Important:** discover with `suppa_list_entities` → `suppa_describe_entity` before reading or writing — field names, types, and filters vary between entities. Edit/delete tools return a **confirmation preview** first and only apply when re-called with `confirm=true`.
168
-
169
- ### What the server does not send back
170
-
171
- A tool result is not paid once: the whole conversation is re-sent on every turn, so a long string returned early is charged again on every later turn and is still occupying the window when compaction fires. These bytes are therefore removed on the way out — each chosen because it carries nothing the reader does not already hold or is not told:
172
-
173
- | Removed | Why it is safe |
174
- |---|---|
175
- | `$readAccess`, `$updateAccess`, `$instanceAccess` | Lists of field names, identical on every row of an entity, read by nothing in this server. Suppressed at the source with `getAccessByFields: false` where the endpoint documents the flag, and stripped by name in `makeRequest` everywhere else. Two bounds, both deliberate: only these three key names (never a blanket `$`-prefix rule, which would silently eat a future key that matters), and only at **record level** — the response object, and each row of a returned array. The strip never descends into a value, so a `json`-typed field holding data that happens to use these names is left exactly as stored. |
176
- | Long values in a **confirmation preview** | `proposed_changes` was built by copying the tool's own arguments back out. The value is verbatim in the same tool call, so it is named and sized instead: `<4231 chars — unchanged from this call's arguments>`. Short values stay verbatim, and `target` — the half that says *what* is about to change — is never touched. |
177
- | Long values a **write echoed back** | An insert with no `returning` projection answers with the whole stored record, so the HTML just uploaded returns with it. Replaced only when byte-identical to what was sent, and the marker says what was checked — `<4231 chars — identical to the value this call wrote>`, not a claim about what you typed (a task description passes through `wrapHtml()` on the way out). If the platform normalised the markup or filled a default, the stored value differs — that difference is real information and comes back in full. |
178
-
179
- | **Schema reads** (`suppa_describe_entity`) | A field lists only what departs from the platform defaults: constraints that are `null`, flags that are `false`/`0` and options at their default (`canGroup`/`canSort`/`showInTable`/`editFromTable`/`canFilter` true, `readOnly`/`searchable` false) are omitted, and a title keeps its language keys only. The result leads with a `_legend` stating exactly that rule, and `full=true` returns the platform's raw schema. Measured on a live tenant: Tasks 43,316 → 16,687 characters, Users 14,829 → 4,858. `suppa_list_entities` reduces each title the same way (24,840 → 13,132 for 202 entities; `full=true` keeps it whole). |
180
- | `deletedAt: null` **on expanded relations** | The platform adds `deletedAt` to every relation it expands — `null` on every live row, nine times per task. Dropped only inside relations named by a projection **this server wrote** (tasks, docs, forms, automations), never inside a `json` value and never where the projection asked for it; a non-null value — the related row *is* deleted — always comes back. A projection the caller supplied (`suppa_search_records`) is returned as sent. |
181
- | **A stage's status object** | `suppa_list_workflows` / `suppa_list_stages` return `status` as its value (`"completed"`) instead of the expanded enum row; the value is the one word every stage decision reads. 68,565 → 41,119 characters for 162 workflows. |
182
- | **A task's second description** | `suppa_get_task` drops `plainDescription` when it is exactly `htmlDescription` with the tags removed — the HTML is what an edit has to send back, and the text is one strip away. When the two differ, both come back. |
183
-
184
- The key is always kept, so "the field was written" is never in doubt. A marker is not the stored text: quote the value to the user from your own arguments.
185
-
186
- The same discipline applies to what every session pays before the first call. The `instructions` block is budgeted (`test/instructionsBudget.test.ts`), and `tools/list` goes out without the JSON-Schema boilerplate no model reads — the `$schema` URI on each tool, `"default": null` on optional parameters, the two-branch `anyOf` where a type array says the same — while every property, `required` list, enum, non-null default and description is kept and compared against the SDK's own output in `test/toolsListEconomy.test.ts`. Measured on the shipped listing: 103,058 characters for 89 tools uncompacted, 95,074 compacted; 100,867 for the 93 tools of 1.27.0, of which the four custom-field tools are 5,007. The ceiling in that test was raised from 96,000 to 101,500 deliberately, in the same commit and with the arithmetic in its comment.
187
-
188
-
189
- ### Deletes are reversible — permanent delete is blocked
190
-
191
- This server performs **reversible deletes only**. Every delete tool calls the platform's
192
- soft delete, `POST /core/data/:entity/remove`, which sets `deletedAt` and leaves the row in
193
- the table; `suppa_restore_record` clears it again.
194
-
195
- The platform's permanent delete — `POST /core/data/:entity/delete`, where *"the rows leave
196
- the table and cannot be restored"* — is **deliberately unavailable here**, and the block is
197
- not a tool-level check that a future tool could miss: `src/httpClient.ts` refuses that route
198
- shape at the single choke point every request to a 2.0 tenant passes through — `makeRequest`
199
- and `makeRequestRawBytes` — before any `fetch`. No tool, parameter, `confirm=true` or direct
200
- `makeRequest` call can reach it, and an attempt raises
201
-
202
- ```
203
- REFUSED BY POLICY — permanent delete is not available through this server. …
204
- Use the reversible pair instead: /remove … undone with suppa_restore_record.
205
- ```
206
-
207
- Neighbouring routes are untouched: `/remove`, `/restore`, `/copy/:id`,
208
- `/core/builder/:entity/remove-fields` and an entity legitimately named `DeleteRequests` all
209
- work normally. Erasing data for good is an admin action in the platform's own UI.
210
-
211
- ---
212
-
213
- ### Custom fields
214
-
215
- A tenant can add columns to an entity from the running product, and they are **scoped to a
216
- context** — in practice, one project. The pieces:
217
-
218
- | Piece | What it is |
219
- |---|---|
220
- | `options.customFields` on the entity | Turns the feature on and creates the `{Entity}CustomFields` extension table. `suppa_update_entity_options`. |
221
- | A **set** (`CustomFieldSets`) | Entity + context field + context value, e.g. `Tasks.project = "2556"`. An ordinary record — the generic tools reach it. |
222
- | A **link row** (`CustomFieldSetFields`) | Puts one field in one set, with `required` / `readOnly` / `defaultValue`. Also an ordinary record. |
223
- | The values | Live on the OWNER record under the reserved `customFields` key. |
224
-
225
- ```text
226
- suppa_update_entity_options("Tasks", '{"customFields": true}', confirm=true)
227
- suppa_add_custom_field("Tasks", "budget", "numeric", context_field="project", context_value=2556)
228
- suppa_update_record("Tasks", 900, '{"customFields": {"budget": 600}}', confirm=true)
229
- suppa_get_record("Tasks", 900, '{"id": true, "customFields": {"budget": true}}')
230
- ```
231
-
232
- The `confirm=true` on the write is not optional: every tool that changes existing data
233
- returns a confirmation preview first and applies nothing until it is re-called with it.
234
-
235
- Five things worth knowing before the platform tells you the hard way, all verified against a
236
- live 2.0 tenant. The first two are refusals that name the next step; the rest are behaviour:
237
-
238
- - **A custom field must belong to a set.** Pass `context_field` + `context_value` (the set
239
- for that context is created if it has none) or `set_ids`. Neither is HTTP 400.
240
- - **A custom field cannot be created NOT NULL** on this platform build, in either form — so
241
- `suppa_add_custom_field` has no `required` parameter at all. Per-context obligation lives on
242
- the link row instead: set `required` on the `CustomFieldSetFields` record.
243
- - **One field can live in SEVERAL contexts.** The link row is the membership, so the same
244
- column and the same values are offered in each — `suppa_link_custom_field` adds or removes
245
- that membership. Verified live: a field resolved in two contexts at once and a record in the
246
- newly linked one accepted a value for it.
247
- - **`readOnly` and `defaultValue` on the link row are NOT enforced** by the data API — an
248
- update through a readOnly link stored the value, and a record created without one did not
249
- receive the default (both verified live). `required` IS enforced, but only when the record's
250
- custom-values row is written: a create that omits the `customFields` envelope entirely still
251
- succeeds.
252
- - **`/schema` lags** up to a minute behind an add or a remove; `suppa_resolve_custom_fields`
253
- is current immediately. `suppa_add_custom_field` confirms itself through resolve when it was
254
- given a context, and says so when the field it just created is not in the answer. The other
255
- three writers return the platform's own rows — read them back with resolve, not with a schema
256
- call, or you will be told the old field list for the next minute.
257
- - **Removal is reversible.** `suppa_remove_custom_field` soft-deletes the metadata and the
258
- platform *renames* the column to `<name>_<timestamp>` rather than dropping it, so
259
- `suppa_restore_custom_field` brings the field and every value back. The NAME stays reserved
260
- while it is parked — a new field cannot take it until the old one is purged, which is not
261
- something this server can do.
262
- - **Restoring a record restores its values with it.** Deleting a record soft-deletes the row
263
- holding its custom values; the platform's own restore does not clear that row, which reads
264
- back as stale values (or as none, with `include_deleted_relations=false`) and makes the next
265
- write create a *second* values row. `suppa_restore_record` restores both — its confirmation
266
- preview names the second table, and it leaves a `{Entity}CustomFields` alone when the tenant
267
- has an entity of that name (the platform keeps its own extension tables out of the schema
268
- listing, so a listed one is the tenant's).
269
-
270
- ### Two rules that are easy to get wrong
271
-
272
- **An enum's values belong to the group named by the field's `subType`.** That is the only
273
- binding the platform enforces — the value picker filters on it and the enum validation checks
274
- it. The familiar `Entity.field` shape is a *client convention*, not something the backend
275
- generates or parses; live tenants also carry groups called `Salutation` or `department`. So
276
- for a field that already exists, **read** the name, never rebuild it:
277
-
278
- ```text
279
- suppa_add_enum_values(values="high:High,low:Low", entity_name="TasksCustomFields", field_name="stage")
280
- ```
281
-
282
- `enum_name` on its own stays for a group whose field does not exist yet. Passing both, with
283
- a name that disagrees with the field, is refused rather than silently preferred — values
284
- written under the wrong name are invisible to the field.
285
-
286
- **An entity name is at most 30 characters, letters, numbers and underscores.** The platform
287
- types it as `@Length(1, 30)` and the rename path applies the same bound, so
288
- `suppa_create_entity` refuses a longer one before sending anything. The `{Name}CustomFields`
289
- extension table is created outside that check and is not subject to it.
290
-
291
- ## Available tools
292
-
293
- 95 tools across the areas below.
294
-
295
- ### Session & identity
296
-
297
- | Tool | Description |
298
- |---|---|
299
- | `suppa_get_me` | Current authenticated user's profile |
300
- | `suppa_login` | Google browser sign-in for a tenant (stores tokens in OS keychain) |
301
- | `suppa_use_tenant` | Switch the active tenant (alias / host / URL) |
302
- | `suppa_list_tenants` | List known tenants + which is active / authenticated |
303
- | `suppa_logout` | Remove stored credentials for a tenant |
304
- | `suppa_diagnostics` | Validate the whole multi-tenant setup |
305
- | `suppa_health_check` | Config + upstream connectivity check (reports `version`) |
306
- | `suppa_version` | Running build vs newest published, and how to upgrade |
307
- | `suppa_validate_entity_code` | Run the schema gate over an app repo before calling entity code done |
308
-
309
- ### Tasks
310
-
311
- | Tool | Description |
312
- |---|---|
313
- | `suppa_search_tasks` | Search tasks (my / active / overdue / due-today filters, paginated); `task_ids` reads several known tasks in one call; `fields_json` narrows each row |
314
- | `suppa_count_tasks` | Count tasks matching filters |
315
- | `suppa_get_task` | Get a single task (full details, or only `fields_json`) |
316
- | `suppa_create_task` | Create a task |
317
- | `suppa_update_task` | Update a task (confirm-gated) |
318
- | `suppa_delete_task` | Delete a task (confirm-gated) |
319
- | `suppa_move_task` | Move a task to another stage (confirm-gated) |
320
- | `suppa_close_task` | Close a task (confirm-gated) |
321
- | `suppa_add_comment` | Add a comment (supports @mentions) |
322
- | `suppa_get_comments` | Get comments on a task |
323
- | `suppa_attach_file` | Attach a local file to a task |
324
- | `suppa_list_workflows` | List Task workflows |
325
- | `suppa_list_stages` | List stages of a workflow |
326
- | `suppa_list_task_types` | List task types |
327
- | `suppa_search_users` | Search users (feeds assignee / mentions) |
328
-
329
- ### Docs & pages
330
-
331
- | Tool | Description |
332
- |---|---|
333
- | `suppa_list_docs` | List docs (`fields_json` narrows each row) |
334
- | `suppa_get_doc` | Get a doc (page tree included, or only `fields_json`) |
335
- | `suppa_create_doc` | Create a doc |
336
- | `suppa_update_doc` | Update a doc (confirm-gated) |
337
- | `suppa_delete_doc` | Delete a doc (confirm-gated) |
338
- | `suppa_list_pages` | List pages of a doc (`fields_json` narrows each row) |
339
- | `suppa_get_page` | Get a page (metadata, or only `fields_json`) |
340
- | `suppa_create_page` | Create a page |
341
- | `suppa_update_page` | Update a page (confirm-gated) |
342
- | `suppa_delete_page` | Delete a page (confirm-gated) |
343
- | `suppa_get_blocks` | Get raw blocks of a page |
344
- | `suppa_read_page` | Read a page rendered to text |
345
- | `suppa_create_blocks` | Create blocks from a JSON array (11 block types) |
346
- | `suppa_insert_block` | Insert a block at a position |
347
- | `suppa_update_block` | Update a block (confirm-gated) |
348
- | `suppa_delete_block` | Delete a block (confirm-gated) |
349
- | `suppa_reorder_blocks` | Reorder blocks on a page |
350
-
351
- ### Entities & records
352
-
353
- | Tool | Description |
354
- |---|---|
355
- | `suppa_list_entities` | List entities (tables) |
356
- | `suppa_describe_entity` | Field definitions + types for an entity (compact by default; `full=true` for the raw schema) |
357
- | `suppa_list_tabular_parts` | List tabular parts (ТЧ) of an entity |
358
- | `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows) |
359
- | `suppa_validate_select` | Check a select/filter payload against the entity without running it — names the field that does not resolve |
360
- | `suppa_get_record` | Get a single record (`deleted_scope` reads a soft-deleted one) |
361
- | `suppa_create_entity` | Create a new entity (`options_json`: comments / globalSearch / hierarchy …) |
362
- | `suppa_create_tabular_part` | Create a tabular part (owned rows) of a parent |
363
- | `suppa_add_field` | Add a field to an entity (`options_json`: searchable / showInTable / canFilter …) |
364
- | `suppa_update_field` | Edit an existing field — name, title, flags, options, encryption (confirm-gated) |
365
- | `suppa_update_entity_options` | Toggle the 16 per-entity features — comments, hierarchy, approvals, customFields … (confirm-gated) |
366
- | `suppa_add_enum_values` | Add values to an enum field — the group is read from the field's subType |
367
- | `suppa_resolve_custom_fields` | Which custom fields are live for a record or context, and their values |
368
- | `suppa_add_custom_field` | Create a custom field in one context (its set is created if missing) |
369
- | `suppa_add_custom_fields_batch` | Create MANY custom fields in ONE atomic call — one bad entry creates nothing |
370
- | `suppa_link_custom_field` | Put an existing custom field into another context, take it out, or set `required` there (confirm-gated) |
371
- | `suppa_remove_custom_field` | Soft-remove custom fields; the column is parked, not dropped (confirm-gated) |
372
- | `suppa_restore_custom_field` | Put a removed custom field and its values back (confirm-gated) |
373
- | `suppa_set_title_field` | Set the representative/title field |
374
- | `suppa_list_field_types` | List supported field types |
375
- | `suppa_create_record` | Create a record — or a batch, by passing an array of records (one request) |
376
- | `suppa_update_record` | Update a record (confirm-gated) |
377
- | `suppa_delete_record` | Soft-delete a record — reversible (confirm-gated); permanent delete is blocked server-wide |
378
- | `suppa_restore_record` | Undo a soft delete: clear `deletedAt` on a record (confirm-gated) |
379
- | `suppa_copy_record` | Duplicate a record, optionally with its files / related records |
380
- | `suppa_attach_file_to_record` | Attach a local file to any record |
381
- | `suppa_list_record_files` | List the files attached to a record |
382
- | `suppa_download_file` | Download one attachment (original, preview, or generated PDF) |
383
- | `suppa_download_files_zip` | Download several attachments as a ZIP |
384
-
385
- ### Automations
386
-
387
- | Tool | Description |
388
- |---|---|
389
- | `suppa_list_automations` | List automation workflows |
390
- | `suppa_get_automation` | Get one automation as a normalized graph (nodes + edges) |
391
- | `suppa_list_automation_runs` | List runs (executions) of an automation |
392
- | `suppa_get_automation_run` | Get one run with per-node steps + trigger payload |
393
- | `suppa_list_automation_node_types` | Node-type catalog (authoritative + fallback) |
394
- | `suppa_get_automation_node_schema` | Parameter schema for one node type |
395
- | `suppa_search_entities` | Fuzzy-find an entity by name/title (+ record count) |
396
- | `suppa_create_automation` | Create an automation (pre-flight validated; draft) |
397
- | `suppa_update_automation` | Update an automation (read-modify-write; confirm-gated) |
398
- | `suppa_delete_automation` | Delete an automation (confirm-gated) |
399
- | `suppa_publish_automation` | Publish the draft snapshot (confirm-gated) |
400
- | `suppa_unpublish_automation` | Deactivate an automation (confirm-gated) |
401
-
402
- ### Forms
403
-
404
- | Tool | Description |
405
- |---|---|
406
- | `suppa_list_forms` | List forms |
407
- | `suppa_get_form` | Get a form |
408
- | `suppa_create_form` | Create a form (optionally generated from an entity) |
409
- | `suppa_update_form` | Update a form (confirm-gated) |
410
- | `suppa_generate_form_schema` | Generate a grid form schema from an entity |
411
- | `suppa_add_field_to_form` | Add a field element to a form (confirm-gated) |
412
- | `suppa_list_form_field_types` | List form element types |
413
-
414
- ### Migration (Suppa 1.0 → 2.0) & workspace
415
-
416
- | Tool | Description |
417
- |---|---|
418
- | `suppa_migrate_entities_from_v1` | Migrate 1.0 entities → 2.0 (dry-run / create / gap-fill / reconcile) |
419
- | `suppa_read_v1_entities` | Read entity list from a Suppa 1.0 tenant |
420
- | `suppa_read_v1_entity_props` | Read 1.0 entity field definitions |
421
- | `suppa_read_v1_enum` | Read 1.0 enum values |
422
- | `suppa_create_workspace` | Create a workspace + nav item |
423
- | `suppa_add_menu_item` | Add a navigation-menu item |
424
-
425
- ---
426
-
427
- ## Prompts
428
-
429
- Guided workflows clients can expose as slash commands:
430
-
431
- | Prompt | Arguments | Description |
432
- |---|---|---|
433
- | `plan_my_day` | — | Triage my Suppa tasks into a prioritized day plan |
434
- | `build_entity` | `entity_purpose` | Guided design + creation of a new entity, fields, enums, and a form |
435
- | `migrate_from_v1` | `entity_names?` | Guided Suppa 1.0 → 2.0 schema migration (dry-run, review, execute) |
436
- | `write_entity_code` | `entity_purpose` | Guided: write v2 application schema code (entities, seeds, registration) instead of API calls |
437
-
438
- ---
439
-
440
- ## Bundled agent skill: suppa-entity-code
441
-
442
- The package ships an agent skill at `skills/suppa-entity-code/` (also installed
443
- via npm) that writes **Suppa v2 application schema code** — `*.entity.ts`
444
- classes, `*.seed.ts` seeds, and the `EntityModule.forFeature()` registration —
445
- following the platform's declarative-migration rules, where the entity class
446
- *is* the migration.
447
-
448
- Two flows:
449
-
450
- - **Flow A** — design a new entity/seed in an application repo.
451
- - **Flow B** — port a Suppa 1.0 entity to v2 code, using the same
452
- type-mapping authority as `suppa_migrate_entities_from_v1`.
453
-
454
- It includes a static validator that catches everything `tsc` cannot:
455
-
456
- ```bash
457
- node <this-skill-dir>/scripts/validate-suppa-schema.mjs <app-root>
458
- # (installed via npm: node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs)
459
- ```
460
-
461
- Checks: SQL-string defaults, decorator misuse, thunk-less relations, an
462
- `inverse` selector wrongly passed to `@ManyToOne`/`@ManyToMany` (W609) or
463
- pointing at a non-relation property such as `id` on any of the four relation
464
- decorators (E111), seed idempotency (importKeyFields / `$key`), forbidden
465
- seed keys, numeric relation ids, reverse `@OneToMany` references, `forFeature`
466
- membership, seed dependency order, `dist/` autoload paths, tsconfig decorator
467
- flags, unknown `@Entity()`/`@Column()` options or field types, and tabular-part rules —
468
- the `type: 'tabular-part'` + `relationEntityName` + `owner` triad, `owner`
469
- resolving to the right parent, and `owner` first in `importKeyFields`
470
- (E108/E109/E110/W607) — validated against the installed `@suppa/sdk` typings
471
- when resolvable, falling back to the doc tables otherwise
472
- (E101/E102/E107/E501/E502). Options/records/registration arrays delivered via
473
- spread or by reference can't be statically checked and fire a W606 warning
474
- instead. An entity or seed left out of `EntityModule.forFeature()` fires
475
- E301/E302, naming the module file to edit so the fix is a find-and-add, not a
476
- search. Use the `write_entity_code` MCP prompt to drive it from any client.
477
-
478
- **Make the rules unskippable.** Stating a rule in a skill, in the server
479
- instructions and in a tool description is optional at the moment code gets
480
- written — an agent may open none of them, and that is exactly how an entity
481
- shipped with restated defaults and four bare relation stand-ins. Install the
482
- guards into an application repo:
483
-
484
- ```bash
485
- npx suppa-entity-guards .
486
- # or, without npx:
487
- node node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/install-entity-code-guards.mjs .
488
- ```
489
-
490
- It is idempotent, and it refuses to write a hook whose path does not resolve —
491
- hooks pointing at nothing behave exactly like no hooks at all.
492
-
493
- **Adding the package runs this for you.** A `postinstall` installs the guards into
494
- the repo the install was run from, so a developer who never reads this file still
495
- gets them. It refuses far more often than it acts: never when
496
- `SUPPA_NO_GUARD_INSTALL` is set, never in CI (where hooks do nothing and the CI job
497
- is its own layer), never for a global install, and never for a repo with no sign of
498
- Suppa schema code — no `@suppa/*` dependency and no `*.entity.ts`. A package install
499
- is not permission to configure an unrelated project. It also never fails an install:
500
- whatever happens, it exits 0 and prints one line saying what to run by hand.
501
-
502
- One caveat worth knowing: `npm ci --ignore-scripts` skips it, which is common in CI
503
- and in locked-down organisations. There the CI job is the layer that holds.
504
-
505
- Five layers, each covering a way the previous one is missed: Claude Code hooks
506
- put the rules in an agent's context **before** it writes `*.entity.ts` and the
507
- gate's findings in front of it **after**, a `Stop` hook refuses to end a turn
508
- while a changed schema file still fails, `.githooks/pre-commit` refuses the
509
- commit, a `.gitlab/suppa-schema-gate.yml` job refuses the merge request, and a
510
- managed section in `AGENTS.md` / `CLAUDE.md` carries the same rules to editors
511
- with no hook support. Re-running the installer is safe, `--dry-run` prints the
512
- plan, and details are in `skills/suppa-entity-code/references/enforcement.md`.
513
-
514
- It also enforces the **authoring rules** the platform doc does not: a
515
- relation property must carry a TypeScript type that agrees with its decorator
516
- (E114/E115/W610, and W615 when the type names no class at all — `any`), enum
517
- member keys are PascalCase (W611), no field option may be written at its
518
- platform default (W612), `@Enum`/`@MultiEnum` take a global name only when
519
- the enum is actually shared (W613), and a relation target that already exists on
520
- the tenant is declared as a **stub**: `@Entity({ name, key })` + `extends
521
- SystemBaseEntity`, an **empty body**, alone in a `<name>.stub.entity.ts` file,
522
- registered in `forFeature()`. A bare `export class Accounts {}` satisfies the
523
- thunk but registers nothing, so the platform cannot resolve the relation — the
524
- target is chased through its import (relative, `.js`-suffixed or tsconfig-aliased)
525
- into the file that declares it and reported as E116. A stub that kept its fields
526
- is E117, because each field is a column the migration would create on a table
527
- another application owns; the `.stub.entity.ts` name is what makes that rule
528
- checkable (W617 when it is missing, W616 when stubs share a file).
529
-
530
- A stub stands in for a table so a relation can reach it. To **add columns** to an
531
- entity you do not own — a platform system entity, or another application's — the
532
- platform supports an **extension**: the entity's existing name, only your own
533
- columns, in `<owner>.extension.entity.ts` (SKILL.md rule 20,
534
- `references/extensions.md`). The mode is chosen by ownership at start, so the
535
- filename is what lets the gate apply extension mode's restrictions before the
536
- build does: entity options are ignored there (W618), `@OneToMany` /
537
- `@ManyToManyBackRef` (E118) and `primary: true` (E119) are refused, `nullable:
538
- false` needs a `default` (E120), and `@Index`/`@Check` may cover only the columns
539
- you declare (E121). A relation to an entity you do not own names its target by
540
- string and is typed by shape — right there, W620 anywhere else.
541
-
542
- Those, plus
543
- `owner` first in a tabular part's `importKeyFields` (W607) and no `inverse` on
544
- `@ManyToOne`/`@ManyToMany` (W609), are the **rule violations** — W607, W609,
545
- W610, W611, W612, W613, W615, W616, W617, W618, W620 — and like errors they exit 1, because a
546
- rule that only warns is a rule that gets ignored. `--no-strict` demotes them for a legacy repo, and says so:
547
- they print as `[rule violation, demoted]` and the summary ends `NOT a clean
548
- run`. Advisory warnings — W601-W606, W608, W614 — never block; they report what
549
- the checker could not see.
550
-
551
- Tabular parts (owned child sub-tables like checklist items or order lines)
552
- and the remove-and-re-add-a-field semantics — a re-added field restores its
553
- old data because the key defaults to `<EntityName>.<fieldName>` — are both
554
- covered; see `references/tabular-parts.md` and `references/registration.md`.
555
-
556
- ---
557
-
558
- ## Development
559
-
560
- ```bash
561
- # Install dependencies
562
- npm install
563
-
564
- # Build
565
- npm run build
566
-
567
- # Run locally (stdio)
568
- node dist/bin.js
569
-
570
- # Test with MCP Inspector
571
- npm run inspect
572
-
573
- # Tests
574
- npm test
575
-
576
- # Watch mode
577
- npm run dev
578
- ```
579
-
580
- ### Run the tests through this package, not through npx
581
-
582
- `npm test` and `npm --prefix <path>/suppa-mcp-node test` both use the vitest in
583
- this package's `node_modules`. `npx vitest` does not: with nothing resolvable
584
- locally it downloads the newest major from the registry, and from the repo root
585
- it also never reads this package's `vitest.config.ts`. It still collects these
586
- test files, and the failures it invents look real — a phantom timeout from
587
- exactly that mistake was believed long enough for a `testTimeout` bump to be
588
- committed on the strength of it.
589
-
590
- Both halves now refuse rather than mislead: `vitest.config.ts` asserts the
591
- running vitest is the one installed here, and the repo root carries a
592
- `vitest.config.mjs` whose only job is to stop a run started from there.
593
-
594
- ### Driving a real build against a tenant
595
-
596
- ```bash
597
- npm run live:install -- <harness-dir> # rebuild, pack, install, verify
598
- npm run live:verify -- <harness-dir> # re-check before a long sweep
599
- ```
600
-
601
- npm resolves a `file:` dependency by name and version, so repacking after a
602
- rebuild — same filename, same version — lets `npm install` decide there is
603
- nothing to do and leave the previous build in `node_modules`, exit 0, no
604
- warning. A sweep against a stale build reports confidence it did not earn.
605
-
606
- `live:install` names the tarball after a hash of its own contents, clears the
607
- target's `node_modules` and lockfile, and then compares every packed file
608
- byte for byte against what npm extracted. Only that last step is trusted; the
609
- manifest it leaves behind is what `live:verify` re-checks later.
610
-
611
- ---
612
-
613
- ## Publish to npm
614
-
615
- ```bash
616
- # 1. Make sure you're logged in
617
- npm login
618
-
619
- # 2. Build & publish
620
- npm publish
621
- ```
622
-
623
- The `prepublishOnly` script automatically runs `tsc` + the full test suite before publishing.
624
-
625
- ---
626
-
627
- ## Project structure
628
-
629
- ```
630
- suppa-mcp-node/
631
- ├── src/
632
- │ ├── bin.ts # Entry point — stdio transport
633
- │ ├── server.ts # McpServer + all 95 tool + 4 prompt registrations
634
- │ ├── config.ts # Env / .env config surface
635
- │ ├── store.ts # Credentials in the OS keychain (@napi-rs/keyring)
636
- │ ├── registry.ts # Non-secret tenant registry (~/.suppa-mcp/tenants.json)
637
- │ ├── tenants.ts # Tenant context, active tenant, resolve, diagnostics
638
- │ ├── auth.ts # JWT refresh (single-flight) + browser Google login
639
- │ ├── httpClient.ts # fetch client: retry, envelope unwrap, 401→refresh→retry
640
- │ ├── utils.ts # filters, dates, JSON params, multipart, confirm gate
641
- │ └── tools/
642
- │ ├── tasks.ts docs.ts entity.ts forms.ts
643
- │ ├── automation.ts # read + write automation tools
644
- │ ├── migrate.ts nameMap.ts v1Fields.ts
645
- │ └── workspace.ts
646
- ├── skills/suppa-entity-code/ # bundled agent skill: write v2 schema code + validator
647
- ├── test/ # vitest suite (ports the Python test suite)
648
- ├── scripts/ # live read-only / write verify scripts
649
- ├── package.json
650
- ├── tsconfig.json
651
- ├── vitest.config.ts
652
- └── README.md
653
- ```
654
-
655
- ---
656
-
657
- ## License
658
-
659
- MIT — see [LICENSE](LICENSE).
1
+ # suppa-mcp-2
2
+
3
+ MCP (Model Context Protocol) server for the **Suppa 2.0** platform ([modern.suppa.me](https://modern.suppa.me)).
4
+ Allows LLMs (Claude, GPT, Copilot, Cursor, etc.) to manage Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments through standardised MCP tools — with multi-tenant Google authentication.
5
+
6
+ This is the Node.js/TypeScript port of the Python [`suppa-mcp`](https://pypi.org/project/suppa-mcp/) package, published to npm as **`suppa-mcp-2`**.
7
+
8
+ [![npm version](https://img.shields.io/npm/v/suppa-mcp-2)](https://www.npmjs.com/package/suppa-mcp-2)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
10
+
11
+ ---
12
+
13
+ ## Quick start
14
+
15
+ ### Run directly with npx
16
+
17
+ ```bash
18
+ npx suppa-mcp-2
19
+ ```
20
+
21
+ ### Or install from npm
22
+
23
+ ```bash
24
+ npm install -g suppa-mcp-2
25
+ ```
26
+
27
+ No API key needed to start — the server authenticates interactively via the `suppa_login` tool (see [Authentication](#authentication)).
28
+
29
+ ---
30
+
31
+ ## Authentication
32
+
33
+ There is **no API key to paste**. Run the **`suppa_login`** tool from your MCP client — it opens a browser for Google sign-in, then stores the resulting tokens in the OS keychain (Windows Credential Manager / macOS Keychain / libsecret). The server is **multi-tenant**: log in to more than one Suppa tenant and switch with `suppa_use_tenant`.
34
+
35
+ Credentials stay on your machine, are sent only in the `Authorization` header to your configured `SUPPA_BASE_URL`, and are **never** exposed to the AI agent. A `SUPPA_API_KEY` env var is an optional CI-only alternative.
36
+
37
+ ---
38
+
39
+ ## Configuration
40
+
41
+ All variables are optional — the server works out of the box and authenticates via `suppa_login`.
42
+
43
+ | Variable | Default | Description |
44
+ |---|---|---|
45
+ | `SUPPA_BASE_URL` | `https://modern.suppa.me` | Platform base URL (the active tenant) |
46
+ | `SUPPA_API_KEY` | (none) | JWT / API key; skips interactive login when set (CI) |
47
+ | `SUPPA_REFRESH_TOKEN` | (none) | Refresh token; paired with `SUPPA_API_KEY` for long-lived CI sessions |
48
+ | `SUPPA_LANG` | `en` | Language (`en` / `uk`) |
49
+ | `SUPPA_LANGS` | (auto) | Languages a multi-language title/Name is written into. When unset, resolved from the platform (the languages already used by existing entity titles), falling back to `en,uk`. Set e.g. `en,uk` to force it. |
50
+ | `SUPPA_TZ` | `Europe/Kyiv` | Timezone |
51
+ | `SUPPA_MCP_LOGIN_PORT` | `8080` | Local loopback port for the browser login callback |
52
+ | `SUPPA_MCP_HOME` | `~/.suppa-mcp` | Directory for the tenant registry |
53
+ | `SUPPA_HTTP_TIMEOUT` | `60` | Per-request timeout, seconds |
54
+ | `SUPPA_MCP_DEBUG` | (off) | `1` logs each request line to stderr |
55
+ | `SUPPA_MCP_NO_SELFTEST` | (off) | Set to skip the install-time self-check |
56
+ | `SUPPA_MCP_NO_CACHE_REPAIR` | (off) | Set to keep the server from removing its own broken `_npx/<hash>` directory after an incomplete download (see below) |
57
+
58
+ ### The install checks itself
59
+
60
+ Every `npm install` / `npx` of this package runs a self-check before anything
61
+ else: it confirms each declared bin is on disk, then **starts the server in a
62
+ child process and makes it speak MCP** — `initialize`, then `tools/list`. A
63
+ healthy install prints one line:
64
+
65
+ ```
66
+ suppa-mcp-2: self-check ok — v1.29.0, 95 tools.
67
+ ```
68
+
69
+ A broken one says what is wrong, what the host will show you instead, and the
70
+ command that fixes it. This exists because the two faults that reached users —
71
+ a bin `npx` could not choose, and a truncated download missing `ajv` — were both
72
+ invisible to a test suite that only ever drove `dist/bin.js` directly, which is
73
+ the one path an MCP host never takes.
74
+
75
+ It never fails an install (a package that refuses to install is worse than one
76
+ that installs and complains), it touches no network, and it runs its child with
77
+ repair disabled so it can never delete the package while npm is still writing
78
+ it. It reports on **stderr**, never stdout — under `npx` the install and the
79
+ server share one pipe, and stdout on that pipe is the JSON-RPC stream.
80
+ `SUPPA_MCP_NO_SELFTEST=1` turns it off; `node dist/selfcheckCli.js` runs it by
81
+ hand.
82
+
83
+ **One caveat worth knowing.** npm 11 does not run lifecycle scripts by default —
84
+ it prints `1 package has install scripts not yet covered by allowScripts` and
85
+ skips them, so on those versions the self-check (and the entity-code guards) do
86
+ not run until you allow them:
87
+
88
+ ```
89
+ npm approve-scripts suppa-mcp-2
90
+ ```
91
+
92
+ That is npm's policy, not something this package can opt out of. It is why the
93
+ server also checks itself at **startup**: an incomplete install is caught there
94
+ in every case, whatever npm decided about scripts.
95
+
96
+ ### When npx leaves a half-downloaded package
97
+
98
+ An interrupted `npx` download leaves the package in the cache with files
99
+ missing, and the symptom points at the wrong thing: Node cannot resolve a
100
+ dependency, the process dies *before* the MCP handshake, and the host reports
101
+ `CONNECT_TIMEOUT` / `CONNECTION_CLOSED` / `Server disconnected` — as though the
102
+ server had crashed, when it never ran.
103
+
104
+ The server now recognises this and repairs it. On a module-resolution failure it
105
+ removes **only** its own `_npx/<hash>` directory and exits, so the next launch
106
+ downloads a clean copy; the message on stderr names the missing module and the
107
+ directory. It never clears the npm cache as a whole, never touches a global
108
+ install or a project's `node_modules`, and never runs on a healthy start — a
109
+ repair is only ever a response to a failure that already happened. A second
110
+ failure within a minute leaves the directory alone, so a host that restarts the
111
+ server cannot loop.
112
+
113
+ ---
114
+
115
+ ## Use with Claude Desktop
116
+
117
+ Add to your `claude_desktop_config.json`:
118
+
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "suppa-2.0": {
123
+ "command": "npx",
124
+ "args": ["-y", "suppa-mcp-2"]
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ ## Use with Cursor
131
+
132
+ Add to `.cursor/mcp.json` in your project:
133
+
134
+ ```json
135
+ {
136
+ "mcpServers": {
137
+ "suppa-2.0": {
138
+ "command": "npx",
139
+ "args": ["-y", "suppa-mcp-2"]
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ ## Use with VS Code (Copilot)
146
+
147
+ Add to `.vscode/mcp.json`:
148
+
149
+ ```json
150
+ {
151
+ "servers": {
152
+ "suppa-2.0": {
153
+ "command": "npx",
154
+ "args": ["-y", "suppa-mcp-2"]
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ Then run **`suppa_login`** once per tenant to authenticate.
161
+
162
+ ---
163
+
164
+ ## Which version is running (and is it current)
165
+
166
+ An MCP client keeps whatever build it started with — an `npx` cache or a
167
+ `node_modules` copy — for the whole session. Publishing a fix changes nothing
168
+ for that session, so "the fix isn't working" and "I'm running last week's
169
+ server" look identical from the inside. Two mechanisms keep them apart:
170
+
171
+ - **`suppa_version`** — read-only, asks the npm registry live, and reports the
172
+ running version, the published one, and the upgrade command. Ask it first
173
+ whenever a tool or behaviour you expect is missing. `suppa_health_check` also
174
+ carries `version` in every report, so a bug report names its build without
175
+ anyone remembering to ask.
176
+ - **An automatic notice.** The server checks the registry in the background
177
+ (detached, cached for 6h, 4s timeout, silent when offline — startup never
178
+ waits). If the running build is behind, the next session's instructions open
179
+ with an `OUTDATED` banner telling the agent to say so in its first reply, and
180
+ to restart the client after updating.
181
+
182
+ Upgrading: `npm i -g suppa-mcp-2@latest`, or pin `suppa-mcp-2@latest` in the
183
+ client's MCP config — then **restart the client**. Without the restart the old
184
+ process, and its old code, keep serving the session.
185
+
186
+ On the source side, the version is stated in `package.json` **only**.
187
+ `scripts/check-version-literals.mjs` runs inside `npm test` (and so inside
188
+ `prepublishOnly`) and fails the build if a version string is typed into `src/`:
189
+ the handshake once announced a hardcoded `1.6.1` for every release after it,
190
+ which made the one diagnostic question unanswerable.
191
+
192
+ ## Agent workflow
193
+
194
+ When an AI agent connects, the server provides built-in instructions describing the correct workflow. Auth first, then discover schema before reading or writing data:
195
+
196
+ ```
197
+ ┌─────────────────────────────────────────────────────────┐
198
+ │ 0. AUTHENTICATE (once per tenant) │
199
+ │ suppa_login — Google browser sign-in │
200
+ │ suppa_use_tenant — switch active tenant │
201
+ ├─────────────────────────────────────────────────────────┤
202
+ │ 1. DISCOVER ENTITIES │
203
+ │ suppa_list_entities(search?: "task") │
204
+ │ suppa_search_entities — fuzzy-find + record count │
205
+ ├─────────────────────────────────────────────────────────┤
206
+ │ 2. DISCOVER FIELDS │
207
+ │ suppa_describe_entity(entity_name) │
208
+ │ suppa_list_field_types / suppa_list_tabular_parts │
209
+ ├─────────────────────────────────────────────────────────┤
210
+ │ 3. READ DATA │
211
+ │ suppa_search_records / suppa_get_record │
212
+ │ suppa_search_tasks / suppa_get_task / … │
213
+ │ suppa_list_docs / suppa_read_page / suppa_get_blocks │
214
+ │ suppa_list_automations / suppa_get_automation │
215
+ ├─────────────────────────────────────────────────────────┤
216
+ │ 4. WRITE DATA (destructive/edit tools are confirm-gated)│
217
+ │ suppa_create_record / suppa_update_record │
218
+ │ suppa_copy_record / suppa_restore_record │
219
+ │ suppa_create_entity / suppa_add_field │
220
+ │ suppa_create_automation / suppa_publish_automation │
221
+ └─────────────────────────────────────────────────────────┘
222
+ ```
223
+
224
+ > **Important:** discover with `suppa_list_entities` → `suppa_describe_entity` before reading or writing — field names, types, and filters vary between entities. Edit/delete tools return a **confirmation preview** first and only apply when re-called with `confirm=true`.
225
+
226
+ ### What the server does not send back
227
+
228
+ A tool result is not paid once: the whole conversation is re-sent on every turn, so a long string returned early is charged again on every later turn and is still occupying the window when compaction fires. These bytes are therefore removed on the way out — each chosen because it carries nothing the reader does not already hold or is not told:
229
+
230
+ | Removed | Why it is safe |
231
+ |---|---|
232
+ | `$readAccess`, `$updateAccess`, `$instanceAccess` | Lists of field names, identical on every row of an entity, read by nothing in this server. Suppressed at the source with `getAccessByFields: false` where the endpoint documents the flag, and stripped by name in `makeRequest` everywhere else. Two bounds, both deliberate: only these three key names (never a blanket `$`-prefix rule, which would silently eat a future key that matters), and only at **record level** — the response object, and each row of a returned array. The strip never descends into a value, so a `json`-typed field holding data that happens to use these names is left exactly as stored. |
233
+ | Long values in a **confirmation preview** | `proposed_changes` was built by copying the tool's own arguments back out. The value is verbatim in the same tool call, so it is named and sized instead: `<4231 chars — unchanged from this call's arguments>`. Short values stay verbatim, and `target` — the half that says *what* is about to change — is never touched. |
234
+ | Long values a **write echoed back** | An insert with no `returning` projection answers with the whole stored record, so the HTML just uploaded returns with it. Replaced only when byte-identical to what was sent, and the marker says what was checked — `<4231 chars — identical to the value this call wrote>`, not a claim about what you typed (a task description passes through `wrapHtml()` on the way out). If the platform normalised the markup or filled a default, the stored value differs — that difference is real information and comes back in full. |
235
+
236
+ | **Schema reads** (`suppa_describe_entity`) | A field lists only what departs from the platform defaults: constraints that are `null`, flags that are `false`/`0` and options at their default (`canGroup`/`canSort`/`showInTable`/`editFromTable`/`canFilter` true, `readOnly`/`searchable` false) are omitted, and a title keeps its language keys only. The result leads with a `_legend` stating exactly that rule, and `full=true` returns the platform's raw schema. Measured on a live tenant: Tasks 43,316 → 16,687 characters, Users 14,829 → 4,858. `suppa_list_entities` reduces each title the same way (24,840 → 13,132 for 202 entities; `full=true` keeps it whole). |
237
+ | `deletedAt: null` **on expanded relations** | The platform adds `deletedAt` to every relation it expands — `null` on every live row, nine times per task. Dropped only inside relations named by a projection **this server wrote** (tasks, docs, forms, automations), never inside a `json` value and never where the projection asked for it; a non-null value — the related row *is* deleted — always comes back. A projection the caller supplied (`suppa_search_records`) is returned as sent. |
238
+ | **A stage's status object** | `suppa_list_workflows` / `suppa_list_stages` return `status` as its value (`"completed"`) instead of the expanded enum row; the value is the one word every stage decision reads. 68,565 → 41,119 characters for 162 workflows. |
239
+ | **A task's second description** | `suppa_get_task` drops `plainDescription` when it is exactly `htmlDescription` with the tags removed — the HTML is what an edit has to send back, and the text is one strip away. When the two differ, both come back. |
240
+
241
+ The key is always kept, so "the field was written" is never in doubt. A marker is not the stored text: quote the value to the user from your own arguments.
242
+
243
+ The same discipline applies to what every session pays before the first call. The `instructions` block is budgeted (`test/instructionsBudget.test.ts`), and `tools/list` goes out without the JSON-Schema boilerplate no model reads — the `$schema` URI on each tool, `"default": null` on optional parameters, the two-branch `anyOf` where a type array says the same — while every property, `required` list, enum, non-null default and description is kept and compared against the SDK's own output in `test/toolsListEconomy.test.ts`. Measured on the shipped listing: 103,058 characters for 89 tools uncompacted, 95,074 compacted; 100,867 for the 93 tools of 1.27.0, of which the four custom-field tools are 5,007. The ceiling in that test was raised from 96,000 to 101,500 deliberately, in the same commit and with the arithmetic in its comment.
244
+
245
+
246
+ ### Deletes are reversible — permanent delete is blocked
247
+
248
+ This server performs **reversible deletes only**. Every delete tool calls the platform's
249
+ soft delete, `POST /core/data/:entity/remove`, which sets `deletedAt` and leaves the row in
250
+ the table; `suppa_restore_record` clears it again.
251
+
252
+ The platform's permanent delete — `POST /core/data/:entity/delete`, where *"the rows leave
253
+ the table and cannot be restored"* — is **deliberately unavailable here**, and the block is
254
+ not a tool-level check that a future tool could miss: `src/httpClient.ts` refuses that route
255
+ shape at the single choke point every request to a 2.0 tenant passes through — `makeRequest`
256
+ and `makeRequestRawBytes` — before any `fetch`. No tool, parameter, `confirm=true` or direct
257
+ `makeRequest` call can reach it, and an attempt raises
258
+
259
+ ```
260
+ REFUSED BY POLICY — permanent delete is not available through this server. …
261
+ Use the reversible pair instead: /remove … undone with suppa_restore_record.
262
+ ```
263
+
264
+ Neighbouring routes are untouched: `/remove`, `/restore`, `/copy/:id`,
265
+ `/core/builder/:entity/remove-fields` and an entity legitimately named `DeleteRequests` all
266
+ work normally. Erasing data for good is an admin action in the platform's own UI.
267
+
268
+ ---
269
+
270
+ ### Custom fields
271
+
272
+ A tenant can add columns to an entity from the running product, and they are **scoped to a
273
+ context** — in practice, one project. The pieces:
274
+
275
+ | Piece | What it is |
276
+ |---|---|
277
+ | `options.customFields` on the entity | Turns the feature on and creates the `{Entity}CustomFields` extension table. `suppa_update_entity_options`. |
278
+ | A **set** (`CustomFieldSets`) | Entity + context field + context value, e.g. `Tasks.project = "2556"`. An ordinary record — the generic tools reach it. |
279
+ | A **link row** (`CustomFieldSetFields`) | Puts one field in one set, with `required` / `readOnly` / `defaultValue`. Also an ordinary record. |
280
+ | The values | Live on the OWNER record under the reserved `customFields` key. |
281
+
282
+ ```text
283
+ suppa_update_entity_options("Tasks", '{"customFields": true}', confirm=true)
284
+ suppa_add_custom_field("Tasks", "budget", "numeric", context_field="project", context_value=2556)
285
+ suppa_update_record("Tasks", 900, '{"customFields": {"budget": 600}}', confirm=true)
286
+ suppa_get_record("Tasks", 900, '{"id": true, "customFields": {"budget": true}}')
287
+ ```
288
+
289
+ The `confirm=true` on the write is not optional: every tool that changes existing data
290
+ returns a confirmation preview first and applies nothing until it is re-called with it.
291
+
292
+ Five things worth knowing before the platform tells you the hard way, all verified against a
293
+ live 2.0 tenant. The first two are refusals that name the next step; the rest are behaviour:
294
+
295
+ - **A custom field must belong to a set.** Pass `context_field` + `context_value` (the set
296
+ for that context is created if it has none) or `set_ids`. Neither is HTTP 400.
297
+ - **A custom field cannot be created NOT NULL** on this platform build, in either form — so
298
+ `suppa_add_custom_field` has no `required` parameter at all. Per-context obligation lives on
299
+ the link row instead: set `required` on the `CustomFieldSetFields` record.
300
+ - **One field can live in SEVERAL contexts.** The link row is the membership, so the same
301
+ column and the same values are offered in each — `suppa_link_custom_field` adds or removes
302
+ that membership. Verified live: a field resolved in two contexts at once and a record in the
303
+ newly linked one accepted a value for it.
304
+ - **`readOnly` and `defaultValue` on the link row are NOT enforced** by the data API — an
305
+ update through a readOnly link stored the value, and a record created without one did not
306
+ receive the default (both verified live). `required` IS enforced, but only when the record's
307
+ custom-values row is written: a create that omits the `customFields` envelope entirely still
308
+ succeeds.
309
+ - **`/schema` lags** up to a minute behind an add or a remove; `suppa_resolve_custom_fields`
310
+ is current immediately. `suppa_add_custom_field` confirms itself through resolve when it was
311
+ given a context, and says so when the field it just created is not in the answer. The other
312
+ three writers return the platform's own rows — read them back with resolve, not with a schema
313
+ call, or you will be told the old field list for the next minute.
314
+ - **Removal is reversible.** `suppa_remove_custom_field` soft-deletes the metadata and the
315
+ platform *renames* the column to `<name>_<timestamp>` rather than dropping it, so
316
+ `suppa_restore_custom_field` brings the field and every value back. The NAME stays reserved
317
+ while it is parked — a new field cannot take it until the old one is purged, which is not
318
+ something this server can do.
319
+ - **Restoring a record restores its values with it.** Deleting a record soft-deletes the row
320
+ holding its custom values; the platform's own restore does not clear that row, which reads
321
+ back as stale values (or as none, with `include_deleted_relations=false`) and makes the next
322
+ write create a *second* values row. `suppa_restore_record` restores both — its confirmation
323
+ preview names the second table, and it leaves a `{Entity}CustomFields` alone when the tenant
324
+ has an entity of that name (the platform keeps its own extension tables out of the schema
325
+ listing, so a listed one is the tenant's).
326
+
327
+ ### Two rules that are easy to get wrong
328
+
329
+ **An enum's values belong to the group named by the field's `subType`.** That is the only
330
+ binding the platform enforces — the value picker filters on it and the enum validation checks
331
+ it. The familiar `Entity.field` shape is a *client convention*, not something the backend
332
+ generates or parses; live tenants also carry groups called `Salutation` or `department`. So
333
+ for a field that already exists, **read** the name, never rebuild it:
334
+
335
+ ```text
336
+ suppa_add_enum_values(values="high:High,low:Low", entity_name="TasksCustomFields", field_name="stage")
337
+ ```
338
+
339
+ `enum_name` on its own stays for a group whose field does not exist yet. Passing both, with
340
+ a name that disagrees with the field, is refused rather than silently preferred — values
341
+ written under the wrong name are invisible to the field.
342
+
343
+ **An entity name is at most 30 characters, letters, numbers and underscores.** The platform
344
+ types it as `@Length(1, 30)` and the rename path applies the same bound, so
345
+ `suppa_create_entity` refuses a longer one before sending anything. The `{Name}CustomFields`
346
+ extension table is created outside that check and is not subject to it.
347
+
348
+ ## Available tools
349
+
350
+ 95 tools across the areas below.
351
+
352
+ ### Session & identity
353
+
354
+ | Tool | Description |
355
+ |---|---|
356
+ | `suppa_get_me` | Current authenticated user's profile |
357
+ | `suppa_login` | Google browser sign-in for a tenant (stores tokens in OS keychain) |
358
+ | `suppa_use_tenant` | Switch the active tenant (alias / host / URL) |
359
+ | `suppa_list_tenants` | List known tenants + which is active / authenticated |
360
+ | `suppa_logout` | Remove stored credentials for a tenant |
361
+ | `suppa_diagnostics` | Validate the whole multi-tenant setup |
362
+ | `suppa_health_check` | Config + upstream connectivity check (reports `version`) |
363
+ | `suppa_version` | Running build vs newest published, and how to upgrade |
364
+ | `suppa_validate_entity_code` | Run the schema gate over an app repo before calling entity code done |
365
+
366
+ ### Tasks
367
+
368
+ | Tool | Description |
369
+ |---|---|
370
+ | `suppa_search_tasks` | Search tasks (my / active / overdue / due-today filters, paginated); `task_ids` reads several known tasks in one call; `fields_json` narrows each row |
371
+ | `suppa_count_tasks` | Count tasks matching filters |
372
+ | `suppa_get_task` | Get a single task (full details, or only `fields_json`) |
373
+ | `suppa_create_task` | Create a task |
374
+ | `suppa_update_task` | Update a task (confirm-gated) |
375
+ | `suppa_delete_task` | Delete a task (confirm-gated) |
376
+ | `suppa_move_task` | Move a task to another stage (confirm-gated) |
377
+ | `suppa_close_task` | Close a task (confirm-gated) |
378
+ | `suppa_add_comment` | Add a comment (supports @mentions) |
379
+ | `suppa_get_comments` | Get comments on a task |
380
+ | `suppa_attach_file` | Attach a local file to a task |
381
+ | `suppa_list_workflows` | List Task workflows |
382
+ | `suppa_list_stages` | List stages of a workflow |
383
+ | `suppa_list_task_types` | List task types |
384
+ | `suppa_search_users` | Search users (feeds assignee / mentions) |
385
+
386
+ ### Docs & pages
387
+
388
+ | Tool | Description |
389
+ |---|---|
390
+ | `suppa_list_docs` | List docs (`fields_json` narrows each row) |
391
+ | `suppa_get_doc` | Get a doc (page tree included, or only `fields_json`) |
392
+ | `suppa_create_doc` | Create a doc |
393
+ | `suppa_update_doc` | Update a doc (confirm-gated) |
394
+ | `suppa_delete_doc` | Delete a doc (confirm-gated) |
395
+ | `suppa_list_pages` | List pages of a doc (`fields_json` narrows each row) |
396
+ | `suppa_get_page` | Get a page (metadata, or only `fields_json`) |
397
+ | `suppa_create_page` | Create a page |
398
+ | `suppa_update_page` | Update a page (confirm-gated) |
399
+ | `suppa_delete_page` | Delete a page (confirm-gated) |
400
+ | `suppa_get_blocks` | Get raw blocks of a page |
401
+ | `suppa_read_page` | Read a page rendered to text |
402
+ | `suppa_create_blocks` | Create blocks from a JSON array (11 block types) |
403
+ | `suppa_insert_block` | Insert a block at a position |
404
+ | `suppa_update_block` | Update a block (confirm-gated) |
405
+ | `suppa_delete_block` | Delete a block (confirm-gated) |
406
+ | `suppa_reorder_blocks` | Reorder blocks on a page |
407
+
408
+ ### Entities & records
409
+
410
+ | Tool | Description |
411
+ |---|---|
412
+ | `suppa_list_entities` | List entities (tables) |
413
+ | `suppa_describe_entity` | Field definitions + types for an entity (compact by default; `full=true` for the raw schema) |
414
+ | `suppa_list_tabular_parts` | List tabular parts (ТЧ) of an entity |
415
+ | `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows) |
416
+ | `suppa_validate_select` | Check a select/filter payload against the entity without running it — names the field that does not resolve |
417
+ | `suppa_get_record` | Get a single record (`deleted_scope` reads a soft-deleted one) |
418
+ | `suppa_create_entity` | Create a new entity (`options_json`: comments / globalSearch / hierarchy …) |
419
+ | `suppa_create_tabular_part` | Create a tabular part (owned rows) of a parent |
420
+ | `suppa_add_field` | Add a field to an entity (`options_json`: searchable / showInTable / canFilter …) |
421
+ | `suppa_update_field` | Edit an existing field — name, title, flags, options, encryption (confirm-gated) |
422
+ | `suppa_update_entity_options` | Toggle the 16 per-entity features — comments, hierarchy, approvals, customFields … (confirm-gated) |
423
+ | `suppa_add_enum_values` | Add values to an enum field — the group is read from the field's subType |
424
+ | `suppa_resolve_custom_fields` | Which custom fields are live for a record or context, and their values |
425
+ | `suppa_add_custom_field` | Create a custom field in one context (its set is created if missing) |
426
+ | `suppa_add_custom_fields_batch` | Create MANY custom fields in ONE atomic call — one bad entry creates nothing |
427
+ | `suppa_link_custom_field` | Put an existing custom field into another context, take it out, or set `required` there (confirm-gated) |
428
+ | `suppa_remove_custom_field` | Soft-remove custom fields; the column is parked, not dropped (confirm-gated) |
429
+ | `suppa_restore_custom_field` | Put a removed custom field and its values back (confirm-gated) |
430
+ | `suppa_set_title_field` | Set the representative/title field |
431
+ | `suppa_list_field_types` | List supported field types |
432
+ | `suppa_create_record` | Create a record — or a batch, by passing an array of records (one request) |
433
+ | `suppa_update_record` | Update a record (confirm-gated) |
434
+ | `suppa_delete_record` | Soft-delete a record — reversible (confirm-gated); permanent delete is blocked server-wide |
435
+ | `suppa_restore_record` | Undo a soft delete: clear `deletedAt` on a record (confirm-gated) |
436
+ | `suppa_copy_record` | Duplicate a record, optionally with its files / related records |
437
+ | `suppa_attach_file_to_record` | Attach a local file to any record |
438
+ | `suppa_list_record_files` | List the files attached to a record |
439
+ | `suppa_download_file` | Download one attachment (original, preview, or generated PDF) |
440
+ | `suppa_download_files_zip` | Download several attachments as a ZIP |
441
+
442
+ ### Automations
443
+
444
+ | Tool | Description |
445
+ |---|---|
446
+ | `suppa_list_automations` | List automation workflows |
447
+ | `suppa_get_automation` | Get one automation as a normalized graph (nodes + edges) |
448
+ | `suppa_list_automation_runs` | List runs (executions) of an automation |
449
+ | `suppa_get_automation_run` | Get one run with per-node steps + trigger payload |
450
+ | `suppa_list_automation_node_types` | Node-type catalog (authoritative + fallback) |
451
+ | `suppa_get_automation_node_schema` | Parameter schema for one node type |
452
+ | `suppa_search_entities` | Fuzzy-find an entity by name/title (+ record count) |
453
+ | `suppa_create_automation` | Create an automation (pre-flight validated; draft) |
454
+ | `suppa_update_automation` | Update an automation (read-modify-write; confirm-gated) |
455
+ | `suppa_delete_automation` | Delete an automation (confirm-gated) |
456
+ | `suppa_publish_automation` | Publish the draft snapshot (confirm-gated) |
457
+ | `suppa_unpublish_automation` | Deactivate an automation (confirm-gated) |
458
+
459
+ ### Forms
460
+
461
+ | Tool | Description |
462
+ |---|---|
463
+ | `suppa_list_forms` | List forms |
464
+ | `suppa_get_form` | Get a form |
465
+ | `suppa_create_form` | Create a form (optionally generated from an entity) |
466
+ | `suppa_update_form` | Update a form (confirm-gated) |
467
+ | `suppa_generate_form_schema` | Generate a grid form schema from an entity |
468
+ | `suppa_add_field_to_form` | Add a field element to a form (confirm-gated) |
469
+ | `suppa_list_form_field_types` | List form element types |
470
+
471
+ ### Migration (Suppa 1.0 → 2.0) & workspace
472
+
473
+ | Tool | Description |
474
+ |---|---|
475
+ | `suppa_migrate_entities_from_v1` | Migrate 1.0 entities → 2.0 (dry-run / create / gap-fill / reconcile) |
476
+ | `suppa_read_v1_entities` | Read entity list from a Suppa 1.0 tenant |
477
+ | `suppa_read_v1_entity_props` | Read 1.0 entity field definitions |
478
+ | `suppa_read_v1_enum` | Read 1.0 enum values |
479
+ | `suppa_create_workspace` | Create a workspace + nav item |
480
+ | `suppa_add_menu_item` | Add a navigation-menu item |
481
+
482
+ ---
483
+
484
+ ## Prompts
485
+
486
+ Guided workflows clients can expose as slash commands:
487
+
488
+ | Prompt | Arguments | Description |
489
+ |---|---|---|
490
+ | `plan_my_day` | — | Triage my Suppa tasks into a prioritized day plan |
491
+ | `build_entity` | `entity_purpose` | Guided design + creation of a new entity, fields, enums, and a form |
492
+ | `migrate_from_v1` | `entity_names?` | Guided Suppa 1.0 → 2.0 schema migration (dry-run, review, execute) |
493
+ | `write_entity_code` | `entity_purpose` | Guided: write v2 application schema code (entities, seeds, registration) instead of API calls |
494
+
495
+ ---
496
+
497
+ ## Bundled agent skill: suppa-entity-code
498
+
499
+ The package ships an agent skill at `skills/suppa-entity-code/` (also installed
500
+ via npm) that writes **Suppa v2 application schema code** — `*.entity.ts`
501
+ classes, `*.seed.ts` seeds, and the `EntityModule.forFeature()` registration —
502
+ following the platform's declarative-migration rules, where the entity class
503
+ *is* the migration.
504
+
505
+ Two flows:
506
+
507
+ - **Flow A** — design a new entity/seed in an application repo.
508
+ - **Flow B** — port a Suppa 1.0 entity to v2 code, using the same
509
+ type-mapping authority as `suppa_migrate_entities_from_v1`.
510
+
511
+ It includes a static validator that catches everything `tsc` cannot:
512
+
513
+ ```bash
514
+ node <this-skill-dir>/scripts/validate-suppa-schema.mjs <app-root>
515
+ # (installed via npm: node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs)
516
+ ```
517
+
518
+ Checks: SQL-string defaults, decorator misuse, thunk-less relations, an
519
+ `inverse` selector wrongly passed to `@ManyToOne`/`@ManyToMany` (W609) or
520
+ pointing at a non-relation property such as `id` on any of the four relation
521
+ decorators (E111), seed idempotency (importKeyFields / `$key`), forbidden
522
+ seed keys, numeric relation ids, reverse `@OneToMany` references, `forFeature`
523
+ membership, seed dependency order, `dist/` autoload paths, tsconfig decorator
524
+ flags, unknown `@Entity()`/`@Column()` options or field types, and tabular-part rules —
525
+ the `type: 'tabular-part'` + `relationEntityName` + `owner` triad, `owner`
526
+ resolving to the right parent, and `owner` first in `importKeyFields`
527
+ (E108/E109/E110/W607) — validated against the installed `@suppa/sdk` typings
528
+ when resolvable, falling back to the doc tables otherwise
529
+ (E101/E102/E107/E501/E502). Options/records/registration arrays delivered via
530
+ spread or by reference can't be statically checked and fire a W606 warning
531
+ instead. An entity or seed left out of `EntityModule.forFeature()` fires
532
+ E301/E302, naming the module file to edit so the fix is a find-and-add, not a
533
+ search. Use the `write_entity_code` MCP prompt to drive it from any client.
534
+
535
+ **Make the rules unskippable.** Stating a rule in a skill, in the server
536
+ instructions and in a tool description is optional at the moment code gets
537
+ written — an agent may open none of them, and that is exactly how an entity
538
+ shipped with restated defaults and four bare relation stand-ins. Install the
539
+ guards into an application repo:
540
+
541
+ ```bash
542
+ npx suppa-entity-guards .
543
+ # or, without npx:
544
+ node node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/install-entity-code-guards.mjs .
545
+ ```
546
+
547
+ It is idempotent, and it refuses to write a hook whose path does not resolve —
548
+ hooks pointing at nothing behave exactly like no hooks at all.
549
+
550
+ **Adding the package runs this for you.** A `postinstall` installs the guards into
551
+ the repo the install was run from, so a developer who never reads this file still
552
+ gets them. It refuses far more often than it acts: never when
553
+ `SUPPA_NO_GUARD_INSTALL` is set, never in CI (where hooks do nothing and the CI job
554
+ is its own layer), never for a global install, and never for a repo with no sign of
555
+ Suppa schema code — no `@suppa/*` dependency and no `*.entity.ts`. A package install
556
+ is not permission to configure an unrelated project. It also never fails an install:
557
+ whatever happens, it exits 0 and prints one line saying what to run by hand.
558
+
559
+ One caveat worth knowing: `npm ci --ignore-scripts` skips it, which is common in CI
560
+ and in locked-down organisations. There the CI job is the layer that holds.
561
+
562
+ Five layers, each covering a way the previous one is missed: Claude Code hooks
563
+ put the rules in an agent's context **before** it writes `*.entity.ts` and the
564
+ gate's findings in front of it **after**, a `Stop` hook refuses to end a turn
565
+ while a changed schema file still fails, `.githooks/pre-commit` refuses the
566
+ commit, a `.gitlab/suppa-schema-gate.yml` job refuses the merge request, and a
567
+ managed section in `AGENTS.md` / `CLAUDE.md` carries the same rules to editors
568
+ with no hook support. Re-running the installer is safe, `--dry-run` prints the
569
+ plan, and details are in `skills/suppa-entity-code/references/enforcement.md`.
570
+
571
+ It also enforces the **authoring rules** the platform doc does not: a
572
+ relation property must carry a TypeScript type that agrees with its decorator
573
+ (E114/E115/W610, and W615 when the type names no class at all — `any`), enum
574
+ member keys are PascalCase (W611), no field option may be written at its
575
+ platform default (W612), `@Enum`/`@MultiEnum` take a global name only when
576
+ the enum is actually shared (W613), and a relation target that already exists on
577
+ the tenant is declared as a **stub**: `@Entity({ name, key })` + `extends
578
+ SystemBaseEntity`, an **empty body**, alone in a `<name>.stub.entity.ts` file,
579
+ registered in `forFeature()`. A bare `export class Accounts {}` satisfies the
580
+ thunk but registers nothing, so the platform cannot resolve the relation — the
581
+ target is chased through its import (relative, `.js`-suffixed or tsconfig-aliased)
582
+ into the file that declares it and reported as E116. A stub that kept its fields
583
+ is E117, because each field is a column the migration would create on a table
584
+ another application owns; the `.stub.entity.ts` name is what makes that rule
585
+ checkable (W617 when it is missing, W616 when stubs share a file).
586
+
587
+ A stub stands in for a table so a relation can reach it. To **add columns** to an
588
+ entity you do not own — a platform system entity, or another application's — the
589
+ platform supports an **extension**: the entity's existing name, only your own
590
+ columns, in `<owner>.extension.entity.ts` (SKILL.md rule 20,
591
+ `references/extensions.md`). The mode is chosen by ownership at start, so the
592
+ filename is what lets the gate apply extension mode's restrictions before the
593
+ build does: entity options are ignored there (W618), `@OneToMany` /
594
+ `@ManyToManyBackRef` (E118) and `primary: true` (E119) are refused, `nullable:
595
+ false` needs a `default` (E120), and `@Index`/`@Check` may cover only the columns
596
+ you declare (E121). A relation to an entity you do not own names its target by
597
+ string and is typed by shape — right there, W620 anywhere else.
598
+
599
+ Those, plus
600
+ `owner` first in a tabular part's `importKeyFields` (W607) and no `inverse` on
601
+ `@ManyToOne`/`@ManyToMany` (W609), are the **rule violations** — W607, W609,
602
+ W610, W611, W612, W613, W615, W616, W617, W618, W620 — and like errors they exit 1, because a
603
+ rule that only warns is a rule that gets ignored. `--no-strict` demotes them for a legacy repo, and says so:
604
+ they print as `[rule violation, demoted]` and the summary ends `NOT a clean
605
+ run`. Advisory warnings — W601-W606, W608, W614 — never block; they report what
606
+ the checker could not see.
607
+
608
+ Tabular parts (owned child sub-tables like checklist items or order lines)
609
+ and the remove-and-re-add-a-field semantics — a re-added field restores its
610
+ old data because the key defaults to `<EntityName>.<fieldName>` — are both
611
+ covered; see `references/tabular-parts.md` and `references/registration.md`.
612
+
613
+ ---
614
+
615
+ ## Development
616
+
617
+ ```bash
618
+ # Install dependencies
619
+ npm install
620
+
621
+ # Build
622
+ npm run build
623
+
624
+ # Run locally (stdio)
625
+ node dist/bin.js
626
+
627
+ # Test with MCP Inspector
628
+ npm run inspect
629
+
630
+ # Tests
631
+ npm test
632
+
633
+ # Watch mode
634
+ npm run dev
635
+ ```
636
+
637
+ ### Run the tests through this package, not through npx
638
+
639
+ `npm test` and `npm --prefix <path>/suppa-mcp-node test` both use the vitest in
640
+ this package's `node_modules`. `npx vitest` does not: with nothing resolvable
641
+ locally it downloads the newest major from the registry, and from the repo root
642
+ it also never reads this package's `vitest.config.ts`. It still collects these
643
+ test files, and the failures it invents look real — a phantom timeout from
644
+ exactly that mistake was believed long enough for a `testTimeout` bump to be
645
+ committed on the strength of it.
646
+
647
+ Both halves now refuse rather than mislead: `vitest.config.ts` asserts the
648
+ running vitest is the one installed here, and the repo root carries a
649
+ `vitest.config.mjs` whose only job is to stop a run started from there.
650
+
651
+ ### Driving a real build against a tenant
652
+
653
+ ```bash
654
+ npm run live:install -- <harness-dir> # rebuild, pack, install, verify
655
+ npm run live:verify -- <harness-dir> # re-check before a long sweep
656
+ ```
657
+
658
+ npm resolves a `file:` dependency by name and version, so repacking after a
659
+ rebuild — same filename, same version — lets `npm install` decide there is
660
+ nothing to do and leave the previous build in `node_modules`, exit 0, no
661
+ warning. A sweep against a stale build reports confidence it did not earn.
662
+
663
+ `live:install` names the tarball after a hash of its own contents, clears the
664
+ target's `node_modules` and lockfile, and then compares every packed file
665
+ byte for byte against what npm extracted. Only that last step is trusted; the
666
+ manifest it leaves behind is what `live:verify` re-checks later.
667
+
668
+ ---
669
+
670
+ ## Publish to npm
671
+
672
+ ```bash
673
+ # 1. Make sure you're logged in
674
+ npm login
675
+
676
+ # 2. Build & publish
677
+ npm publish
678
+ ```
679
+
680
+ The `prepublishOnly` script automatically runs `tsc` + the full test suite before publishing.
681
+
682
+ ---
683
+
684
+ ## Project structure
685
+
686
+ ```
687
+ suppa-mcp-node/
688
+ ├── src/
689
+ │ ├── bin.ts # Entry point — stdio transport
690
+ │ ├── server.ts # McpServer + all 95 tool + 4 prompt registrations
691
+ │ ├── config.ts # Env / .env config surface
692
+ │ ├── store.ts # Credentials in the OS keychain (@napi-rs/keyring)
693
+ │ ├── registry.ts # Non-secret tenant registry (~/.suppa-mcp/tenants.json)
694
+ │ ├── tenants.ts # Tenant context, active tenant, resolve, diagnostics
695
+ │ ├── auth.ts # JWT refresh (single-flight) + browser Google login
696
+ │ ├── httpClient.ts # fetch client: retry, envelope unwrap, 401→refresh→retry
697
+ │ ├── utils.ts # filters, dates, JSON params, multipart, confirm gate
698
+ │ └── tools/
699
+ │ ├── tasks.ts docs.ts entity.ts forms.ts
700
+ │ ├── automation.ts # read + write automation tools
701
+ │ ├── migrate.ts nameMap.ts v1Fields.ts
702
+ │ └── workspace.ts
703
+ ├── skills/suppa-entity-code/ # bundled agent skill: write v2 schema code + validator
704
+ ├── test/ # vitest suite (ports the Python test suite)
705
+ ├── scripts/ # live read-only / write verify scripts
706
+ ├── package.json
707
+ ├── tsconfig.json
708
+ ├── vitest.config.ts
709
+ └── README.md
710
+ ```
711
+
712
+ ---
713
+
714
+ ## License
715
+
716
+ MIT — see [LICENSE](LICENSE).