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