suppa-mcp-2 1.17.0 → 1.19.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,524 +1,537 @@
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
- ### Deletes are reversible — permanent delete is blocked
170
-
171
- This server performs **reversible deletes only**. Every delete tool calls the platform's
172
- soft delete, `POST /core/data/:entity/remove`, which sets `deletedAt` and leaves the row in
173
- the table; `suppa_restore_record` clears it again.
174
-
175
- The platform's permanent delete — `POST /core/data/:entity/delete`, where *"the rows leave
176
- the table and cannot be restored"* — is **deliberately unavailable here**, and the block is
177
- not a tool-level check that a future tool could miss: `src/httpClient.ts` refuses that route
178
- shape at the single choke point every request to a 2.0 tenant passes through — `makeRequest`
179
- and `makeRequestRawBytes` — before any `fetch`. No tool, parameter, `confirm=true` or direct
180
- `makeRequest` call can reach it, and an attempt raises
181
-
182
- ```
183
- REFUSED BY POLICY — permanent delete is not available through this server. …
184
- Use the reversible pair instead: /remove … undone with suppa_restore_record.
185
- ```
186
-
187
- Neighbouring routes are untouched: `/remove`, `/restore`, `/copy/:id`,
188
- `/core/builder/:entity/remove-fields` and an entity legitimately named `DeleteRequests` all
189
- work normally. Erasing data for good is an admin action in the platform's own UI.
190
-
191
- ---
192
-
193
- ## Available tools
194
-
195
- 87 tools across the areas below.
196
-
197
- ### Session & identity
198
-
199
- | Tool | Description |
200
- |---|---|
201
- | `suppa_get_me` | Current authenticated user's profile |
202
- | `suppa_login` | Google browser sign-in for a tenant (stores tokens in OS keychain) |
203
- | `suppa_use_tenant` | Switch the active tenant (alias / host / URL) |
204
- | `suppa_list_tenants` | List known tenants + which is active / authenticated |
205
- | `suppa_logout` | Remove stored credentials for a tenant |
206
- | `suppa_diagnostics` | Validate the whole multi-tenant setup |
207
- | `suppa_health_check` | Config + upstream connectivity check (reports `version`) |
208
- | `suppa_version` | Running build vs newest published, and how to upgrade |
209
- | `suppa_validate_entity_code` | Run the schema gate over an app repo before calling entity code done |
210
-
211
- ### Tasks
212
-
213
- | Tool | Description |
214
- |---|---|
215
- | `suppa_search_tasks` | Search tasks (my / active / overdue / due-today filters, paginated) |
216
- | `suppa_count_tasks` | Count tasks matching filters |
217
- | `suppa_get_task` | Get a single task |
218
- | `suppa_create_task` | Create a task |
219
- | `suppa_update_task` | Update a task (confirm-gated) |
220
- | `suppa_delete_task` | Delete a task (confirm-gated) |
221
- | `suppa_move_task` | Move a task to another stage (confirm-gated) |
222
- | `suppa_close_task` | Close a task (confirm-gated) |
223
- | `suppa_add_comment` | Add a comment (supports @mentions) |
224
- | `suppa_get_comments` | Get comments on a task |
225
- | `suppa_attach_file` | Attach a local file to a task |
226
- | `suppa_list_workflows` | List Task workflows |
227
- | `suppa_list_stages` | List stages of a workflow |
228
- | `suppa_list_task_types` | List task types |
229
- | `suppa_search_users` | Search users (feeds assignee / mentions) |
230
-
231
- ### Docs & pages
232
-
233
- | Tool | Description |
234
- |---|---|
235
- | `suppa_list_docs` | List docs |
236
- | `suppa_get_doc` | Get a doc |
237
- | `suppa_create_doc` | Create a doc |
238
- | `suppa_update_doc` | Update a doc (confirm-gated) |
239
- | `suppa_delete_doc` | Delete a doc (confirm-gated) |
240
- | `suppa_list_pages` | List pages of a doc |
241
- | `suppa_get_page` | Get a page |
242
- | `suppa_create_page` | Create a page |
243
- | `suppa_update_page` | Update a page (confirm-gated) |
244
- | `suppa_delete_page` | Delete a page (confirm-gated) |
245
- | `suppa_get_blocks` | Get raw blocks of a page |
246
- | `suppa_read_page` | Read a page rendered to text |
247
- | `suppa_create_blocks` | Create blocks from a JSON array (11 block types) |
248
- | `suppa_insert_block` | Insert a block at a position |
249
- | `suppa_update_block` | Update a block (confirm-gated) |
250
- | `suppa_delete_block` | Delete a block (confirm-gated) |
251
- | `suppa_reorder_blocks` | Reorder blocks on a page |
252
-
253
- ### Entities & records
254
-
255
- | Tool | Description |
256
- |---|---|
257
- | `suppa_list_entities` | List entities (tables) |
258
- | `suppa_describe_entity` | Field definitions + types for an entity |
259
- | `suppa_list_tabular_parts` | List tabular parts (ТЧ) of an entity |
260
- | `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows) |
261
- | `suppa_validate_select` | Check a select/filter payload against the entity without running it — names the field that does not resolve |
262
- | `suppa_get_record` | Get a single record (`deleted_scope` reads a soft-deleted one) |
263
- | `suppa_create_entity` | Create a new entity (`options_json`: comments / globalSearch / hierarchy …) |
264
- | `suppa_create_tabular_part` | Create a tabular part (owned rows) of a parent |
265
- | `suppa_add_field` | Add a field to an entity (`options_json`: searchable / showInTable / canFilter …) |
266
- | `suppa_update_field` | Edit an existing field — name, title, flags, options, encryption (confirm-gated) |
267
- | `suppa_update_entity_options` | Toggle the 15 per-entity features — comments, hierarchy, approvals … (confirm-gated) |
268
- | `suppa_add_enum_values` | Add values to an enum field |
269
- | `suppa_set_title_field` | Set the representative/title field |
270
- | `suppa_list_field_types` | List supported field types |
271
- | `suppa_create_record` | Create a record — or a batch, by passing an array of records (one request) |
272
- | `suppa_update_record` | Update a record (confirm-gated) |
273
- | `suppa_delete_record` | Soft-delete a record — reversible (confirm-gated); permanent delete is blocked server-wide |
274
- | `suppa_restore_record` | Undo a soft delete: clear `deletedAt` on a record (confirm-gated) |
275
- | `suppa_copy_record` | Duplicate a record, optionally with its files / related records |
276
- | `suppa_attach_file_to_record` | Attach a local file to any record |
277
- | `suppa_list_record_files` | List the files attached to a record |
278
- | `suppa_download_file` | Download one attachment (original, preview, or generated PDF) |
279
- | `suppa_download_files_zip` | Download several attachments as a ZIP |
280
-
281
- ### Automations
282
-
283
- | Tool | Description |
284
- |---|---|
285
- | `suppa_list_automations` | List automation workflows |
286
- | `suppa_get_automation` | Get one automation as a normalized graph (nodes + edges) |
287
- | `suppa_list_automation_runs` | List runs (executions) of an automation |
288
- | `suppa_get_automation_run` | Get one run with per-node steps + trigger payload |
289
- | `suppa_list_automation_node_types` | Node-type catalog (authoritative + fallback) |
290
- | `suppa_get_automation_node_schema` | Parameter schema for one node type |
291
- | `suppa_search_entities` | Fuzzy-find an entity by name/title (+ record count) |
292
- | `suppa_create_automation` | Create an automation (pre-flight validated; draft) |
293
- | `suppa_update_automation` | Update an automation (read-modify-write; confirm-gated) |
294
- | `suppa_delete_automation` | Delete an automation (confirm-gated) |
295
- | `suppa_publish_automation` | Publish the draft snapshot (confirm-gated) |
296
- | `suppa_unpublish_automation` | Deactivate an automation (confirm-gated) |
297
-
298
- ### Forms
299
-
300
- | Tool | Description |
301
- |---|---|
302
- | `suppa_list_forms` | List forms |
303
- | `suppa_get_form` | Get a form |
304
- | `suppa_create_form` | Create a form (optionally generated from an entity) |
305
- | `suppa_update_form` | Update a form (confirm-gated) |
306
- | `suppa_generate_form_schema` | Generate a grid form schema from an entity |
307
- | `suppa_add_field_to_form` | Add a field element to a form (confirm-gated) |
308
- | `suppa_list_form_field_types` | List form element types |
309
-
310
- ### Migration (Suppa 1.0 → 2.0) & workspace
311
-
312
- | Tool | Description |
313
- |---|---|
314
- | `suppa_migrate_entities_from_v1` | Migrate 1.0 entities → 2.0 (dry-run / create / gap-fill / reconcile) |
315
- | `suppa_read_v1_entities` | Read entity list from a Suppa 1.0 tenant |
316
- | `suppa_read_v1_entity_props` | Read 1.0 entity field definitions |
317
- | `suppa_read_v1_enum` | Read 1.0 enum values |
318
- | `suppa_create_workspace` | Create a workspace + nav item |
319
- | `suppa_add_menu_item` | Add a navigation-menu item |
320
-
321
- ---
322
-
323
- ## Prompts
324
-
325
- Guided workflows clients can expose as slash commands:
326
-
327
- | Prompt | Arguments | Description |
328
- |---|---|---|
329
- | `plan_my_day` | — | Triage my Suppa tasks into a prioritized day plan |
330
- | `build_entity` | `entity_purpose` | Guided design + creation of a new entity, fields, enums, and a form |
331
- | `migrate_from_v1` | `entity_names?` | Guided Suppa 1.0 → 2.0 schema migration (dry-run, review, execute) |
332
- | `write_entity_code` | `entity_purpose` | Guided: write v2 application schema code (entities, seeds, registration) instead of API calls |
333
-
334
- ---
335
-
336
- ## Bundled agent skill: suppa-entity-code
337
-
338
- The package ships an agent skill at `skills/suppa-entity-code/` (also installed
339
- via npm) that writes **Suppa v2 application schema code** — `*.entity.ts`
340
- classes, `*.seed.ts` seeds, and the `EntityModule.forFeature()` registration —
341
- following the platform's declarative-migration rules, where the entity class
342
- *is* the migration.
343
-
344
- Two flows:
345
-
346
- - **Flow A** — design a new entity/seed in an application repo.
347
- - **Flow B** — port a Suppa 1.0 entity to v2 code, using the same
348
- type-mapping authority as `suppa_migrate_entities_from_v1`.
349
-
350
- It includes a static validator that catches everything `tsc` cannot:
351
-
352
- ```bash
353
- node <this-skill-dir>/scripts/validate-suppa-schema.mjs <app-root>
354
- # (installed via npm: node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs)
355
- ```
356
-
357
- Checks: SQL-string defaults, decorator misuse, thunk-less relations, an
358
- `inverse` selector wrongly passed to `@ManyToOne`/`@ManyToMany` (W609) or
359
- pointing at a non-relation property such as `id` on any of the four relation
360
- decorators (E111), seed idempotency (importKeyFields / `$key`), forbidden
361
- seed keys, numeric relation ids, reverse `@OneToMany` references, `forFeature`
362
- membership, seed dependency order, `dist/` autoload paths, tsconfig decorator
363
- flags, unknown `@Entity()`/`@Column()` options or field types, and tabular-part rules —
364
- the `type: 'tabular-part'` + `relationEntityName` + `owner` triad, `owner`
365
- resolving to the right parent, and `owner` first in `importKeyFields`
366
- (E108/E109/E110/W607) — validated against the installed `@suppa/sdk` typings
367
- when resolvable, falling back to the doc tables otherwise
368
- (E101/E102/E107/E501/E502). Options/records/registration arrays delivered via
369
- spread or by reference can't be statically checked and fire a W606 warning
370
- instead. An entity or seed left out of `EntityModule.forFeature()` fires
371
- E301/E302, naming the module file to edit so the fix is a find-and-add, not a
372
- search. Use the `write_entity_code` MCP prompt to drive it from any client.
373
-
374
- **Make the rules unskippable.** Stating a rule in a skill, in the server
375
- instructions and in a tool description is optional at the moment code gets
376
- written — an agent may open none of them, and that is exactly how an entity
377
- shipped with restated defaults and four bare relation stand-ins. Install the
378
- guards into an application repo:
379
-
380
- ```bash
381
- npx suppa-entity-guards .
382
- # or, without npx:
383
- node node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/install-entity-code-guards.mjs .
384
- ```
385
-
386
- It is idempotent, and it refuses to write a hook whose path does not resolve —
387
- hooks pointing at nothing behave exactly like no hooks at all.
388
-
389
- **Adding the package runs this for you.** A `postinstall` installs the guards into
390
- the repo the install was run from, so a developer who never reads this file still
391
- gets them. It refuses far more often than it acts: never when
392
- `SUPPA_NO_GUARD_INSTALL` is set, never in CI (where hooks do nothing and the CI job
393
- is its own layer), never for a global install, and never for a repo with no sign of
394
- Suppa schema code — no `@suppa/*` dependency and no `*.entity.ts`. A package install
395
- is not permission to configure an unrelated project. It also never fails an install:
396
- whatever happens, it exits 0 and prints one line saying what to run by hand.
397
-
398
- One caveat worth knowing: `npm ci --ignore-scripts` skips it, which is common in CI
399
- and in locked-down organisations. There the CI job is the layer that holds.
400
-
401
- Five layers, each covering a way the previous one is missed: Claude Code hooks
402
- put the rules in an agent's context **before** it writes `*.entity.ts` and the
403
- gate's findings in front of it **after**, a `Stop` hook refuses to end a turn
404
- while a changed schema file still fails, `.githooks/pre-commit` refuses the
405
- commit, a `.gitlab/suppa-schema-gate.yml` job refuses the merge request, and a
406
- managed section in `AGENTS.md` / `CLAUDE.md` carries the same rules to editors
407
- with no hook support. Re-running the installer is safe, `--dry-run` prints the
408
- plan, and details are in `skills/suppa-entity-code/references/enforcement.md`.
409
-
410
- It also enforces the **authoring rules** the platform doc does not: a
411
- relation property must carry a TypeScript type that agrees with its decorator
412
- (E114/E115/W610, and W615 when the type names no class at all — `any`), enum
413
- member keys are PascalCase (W611), no field option may be written at its
414
- platform default (W612), `@Enum`/`@MultiEnum` take a global name only when
415
- the enum is actually shared (W613), and a relation target that already exists on
416
- the tenant is declared as a **stub**: `@Entity({ name, key })` + `extends
417
- SystemBaseEntity`, an **empty body**, alone in a `<name>.stub.entity.ts` file,
418
- registered in `forFeature()`. A bare `export class Accounts {}` satisfies the
419
- thunk but registers nothing, so the platform cannot resolve the relation — the
420
- target is chased through its import (relative, `.js`-suffixed or tsconfig-aliased)
421
- into the file that declares it and reported as E116. A stub that kept its fields
422
- is E117, because each field is a column the migration would create on a table
423
- another application owns; the `.stub.entity.ts` name is what makes that rule
424
- checkable (W617 when it is missing, W616 when stubs share a file).
425
-
426
- A stub stands in for a table so a relation can reach it. To **add columns** to an
427
- entity you do not own — a platform system entity, or another application's — the
428
- platform supports an **extension**: the entity's existing name, only your own
429
- columns, in `<owner>.extension.entity.ts` (SKILL.md rule 20,
430
- `references/extensions.md`). The mode is chosen by ownership at start, so the
431
- filename is what lets the gate apply extension mode's restrictions before the
432
- build does: entity options are ignored there (W618), `@OneToMany` /
433
- `@ManyToManyBackRef` (E118) and `primary: true` (E119) are refused, `nullable:
434
- false` needs a `default` (E120), and `@Index`/`@Check` may cover only the columns
435
- you declare (E121). A relation to an entity you do not own names its target by
436
- string and is typed by shape — right there, W620 anywhere else.
437
-
438
- Those, plus
439
- `owner` first in a tabular part's `importKeyFields` (W607) and no `inverse` on
440
- `@ManyToOne`/`@ManyToMany` (W609), are the **rule violations** — W607, W609,
441
- W610, W611, W612, W613, W615, W616, W617, W618, W620 — and like errors they exit 1, because a
442
- rule that only warns is a rule that gets ignored. `--no-strict` demotes them for a legacy repo, and says so:
443
- they print as `[rule violation, demoted]` and the summary ends `NOT a clean
444
- run`. Advisory warnings — W601-W606, W608, W614 — never block; they report what
445
- the checker could not see.
446
-
447
- Tabular parts (owned child sub-tables like checklist items or order lines)
448
- and the remove-and-re-add-a-field semantics — a re-added field restores its
449
- old data because the key defaults to `<EntityName>.<fieldName>` — are both
450
- covered; see `references/tabular-parts.md` and `references/registration.md`.
451
-
452
- ---
453
-
454
- ## Development
455
-
456
- ```bash
457
- # Install dependencies
458
- npm install
459
-
460
- # Build
461
- npm run build
462
-
463
- # Run locally (stdio)
464
- node dist/bin.js
465
-
466
- # Test with MCP Inspector
467
- npm run inspect
468
-
469
- # Tests
470
- npm test
471
-
472
- # Watch mode
473
- npm run dev
474
- ```
475
-
476
- ---
477
-
478
- ## Publish to npm
479
-
480
- ```bash
481
- # 1. Make sure you're logged in
482
- npm login
483
-
484
- # 2. Build & publish
485
- npm publish
486
- ```
487
-
488
- The `prepublishOnly` script automatically runs `tsc` + the full test suite before publishing.
489
-
490
- ---
491
-
492
- ## Project structure
493
-
494
- ```
495
- suppa-mcp-node/
496
- ├── src/
497
- │ ├── bin.ts # Entry point — stdio transport
498
- │ ├── server.ts # McpServer + all 84 tool + 4 prompt registrations
499
- │ ├── config.ts # Env / .env config surface
500
- │ ├── store.ts # Credentials in the OS keychain (@napi-rs/keyring)
501
- │ ├── registry.ts # Non-secret tenant registry (~/.suppa-mcp/tenants.json)
502
- │ ├── tenants.ts # Tenant context, active tenant, resolve, diagnostics
503
- │ ├── auth.ts # JWT refresh (single-flight) + browser Google login
504
- │ ├── httpClient.ts # fetch client: retry, envelope unwrap, 401→refresh→retry
505
- │ ├── utils.ts # filters, dates, JSON params, multipart, confirm gate
506
- │ └── tools/
507
- │ ├── tasks.ts docs.ts entity.ts forms.ts
508
- │ ├── automation.ts # read + write automation tools
509
- │ ├── migrate.ts nameMap.ts v1Fields.ts
510
- │ └── workspace.ts
511
- ├── skills/suppa-entity-code/ # bundled agent skill: write v2 schema code + validator
512
- ├── test/ # vitest suite (ports the Python test suite)
513
- ├── scripts/ # live read-only / write verify scripts
514
- ├── package.json
515
- ├── tsconfig.json
516
- ├── vitest.config.ts
517
- └── README.md
518
- ```
519
-
520
- ---
521
-
522
- ## License
523
-
524
- 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
+
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. Three kinds of bytes are therefore removed on the way out — all three chosen because they carry nothing the caller does not already hold:
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. Only these three keys — never a blanket `$`-prefix rule, which would silently eat a future key that matters. |
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. 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
+ 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.
180
+
181
+
182
+ ### Deletes are reversible — permanent delete is blocked
183
+
184
+ This server performs **reversible deletes only**. Every delete tool calls the platform's
185
+ soft delete, `POST /core/data/:entity/remove`, which sets `deletedAt` and leaves the row in
186
+ the table; `suppa_restore_record` clears it again.
187
+
188
+ The platform's permanent delete — `POST /core/data/:entity/delete`, where *"the rows leave
189
+ the table and cannot be restored"* — is **deliberately unavailable here**, and the block is
190
+ not a tool-level check that a future tool could miss: `src/httpClient.ts` refuses that route
191
+ shape at the single choke point every request to a 2.0 tenant passes through — `makeRequest`
192
+ and `makeRequestRawBytes` — before any `fetch`. No tool, parameter, `confirm=true` or direct
193
+ `makeRequest` call can reach it, and an attempt raises
194
+
195
+ ```
196
+ REFUSED BY POLICY — permanent delete is not available through this server. …
197
+ Use the reversible pair instead: /remove … undone with suppa_restore_record.
198
+ ```
199
+
200
+ Neighbouring routes are untouched: `/remove`, `/restore`, `/copy/:id`,
201
+ `/core/builder/:entity/remove-fields` and an entity legitimately named `DeleteRequests` all
202
+ work normally. Erasing data for good is an admin action in the platform's own UI.
203
+
204
+ ---
205
+
206
+ ## Available tools
207
+
208
+ 87 tools across the areas below.
209
+
210
+ ### Session & identity
211
+
212
+ | Tool | Description |
213
+ |---|---|
214
+ | `suppa_get_me` | Current authenticated user's profile |
215
+ | `suppa_login` | Google browser sign-in for a tenant (stores tokens in OS keychain) |
216
+ | `suppa_use_tenant` | Switch the active tenant (alias / host / URL) |
217
+ | `suppa_list_tenants` | List known tenants + which is active / authenticated |
218
+ | `suppa_logout` | Remove stored credentials for a tenant |
219
+ | `suppa_diagnostics` | Validate the whole multi-tenant setup |
220
+ | `suppa_health_check` | Config + upstream connectivity check (reports `version`) |
221
+ | `suppa_version` | Running build vs newest published, and how to upgrade |
222
+ | `suppa_validate_entity_code` | Run the schema gate over an app repo before calling entity code done |
223
+
224
+ ### Tasks
225
+
226
+ | Tool | Description |
227
+ |---|---|
228
+ | `suppa_search_tasks` | Search tasks (my / active / overdue / due-today filters, paginated) |
229
+ | `suppa_count_tasks` | Count tasks matching filters |
230
+ | `suppa_get_task` | Get a single task |
231
+ | `suppa_create_task` | Create a task |
232
+ | `suppa_update_task` | Update a task (confirm-gated) |
233
+ | `suppa_delete_task` | Delete a task (confirm-gated) |
234
+ | `suppa_move_task` | Move a task to another stage (confirm-gated) |
235
+ | `suppa_close_task` | Close a task (confirm-gated) |
236
+ | `suppa_add_comment` | Add a comment (supports @mentions) |
237
+ | `suppa_get_comments` | Get comments on a task |
238
+ | `suppa_attach_file` | Attach a local file to a task |
239
+ | `suppa_list_workflows` | List Task workflows |
240
+ | `suppa_list_stages` | List stages of a workflow |
241
+ | `suppa_list_task_types` | List task types |
242
+ | `suppa_search_users` | Search users (feeds assignee / mentions) |
243
+
244
+ ### Docs & pages
245
+
246
+ | Tool | Description |
247
+ |---|---|
248
+ | `suppa_list_docs` | List docs |
249
+ | `suppa_get_doc` | Get a doc |
250
+ | `suppa_create_doc` | Create a doc |
251
+ | `suppa_update_doc` | Update a doc (confirm-gated) |
252
+ | `suppa_delete_doc` | Delete a doc (confirm-gated) |
253
+ | `suppa_list_pages` | List pages of a doc |
254
+ | `suppa_get_page` | Get a page |
255
+ | `suppa_create_page` | Create a page |
256
+ | `suppa_update_page` | Update a page (confirm-gated) |
257
+ | `suppa_delete_page` | Delete a page (confirm-gated) |
258
+ | `suppa_get_blocks` | Get raw blocks of a page |
259
+ | `suppa_read_page` | Read a page rendered to text |
260
+ | `suppa_create_blocks` | Create blocks from a JSON array (11 block types) |
261
+ | `suppa_insert_block` | Insert a block at a position |
262
+ | `suppa_update_block` | Update a block (confirm-gated) |
263
+ | `suppa_delete_block` | Delete a block (confirm-gated) |
264
+ | `suppa_reorder_blocks` | Reorder blocks on a page |
265
+
266
+ ### Entities & records
267
+
268
+ | Tool | Description |
269
+ |---|---|
270
+ | `suppa_list_entities` | List entities (tables) |
271
+ | `suppa_describe_entity` | Field definitions + types for an entity |
272
+ | `suppa_list_tabular_parts` | List tabular parts (ТЧ) of an entity |
273
+ | `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows) |
274
+ | `suppa_validate_select` | Check a select/filter payload against the entity without running it — names the field that does not resolve |
275
+ | `suppa_get_record` | Get a single record (`deleted_scope` reads a soft-deleted one) |
276
+ | `suppa_create_entity` | Create a new entity (`options_json`: comments / globalSearch / hierarchy …) |
277
+ | `suppa_create_tabular_part` | Create a tabular part (owned rows) of a parent |
278
+ | `suppa_add_field` | Add a field to an entity (`options_json`: searchable / showInTable / canFilter …) |
279
+ | `suppa_update_field` | Edit an existing field — name, title, flags, options, encryption (confirm-gated) |
280
+ | `suppa_update_entity_options` | Toggle the 15 per-entity features — comments, hierarchy, approvals … (confirm-gated) |
281
+ | `suppa_add_enum_values` | Add values to an enum field |
282
+ | `suppa_set_title_field` | Set the representative/title field |
283
+ | `suppa_list_field_types` | List supported field types |
284
+ | `suppa_create_record` | Create a record — or a batch, by passing an array of records (one request) |
285
+ | `suppa_update_record` | Update a record (confirm-gated) |
286
+ | `suppa_delete_record` | Soft-delete a record — reversible (confirm-gated); permanent delete is blocked server-wide |
287
+ | `suppa_restore_record` | Undo a soft delete: clear `deletedAt` on a record (confirm-gated) |
288
+ | `suppa_copy_record` | Duplicate a record, optionally with its files / related records |
289
+ | `suppa_attach_file_to_record` | Attach a local file to any record |
290
+ | `suppa_list_record_files` | List the files attached to a record |
291
+ | `suppa_download_file` | Download one attachment (original, preview, or generated PDF) |
292
+ | `suppa_download_files_zip` | Download several attachments as a ZIP |
293
+
294
+ ### Automations
295
+
296
+ | Tool | Description |
297
+ |---|---|
298
+ | `suppa_list_automations` | List automation workflows |
299
+ | `suppa_get_automation` | Get one automation as a normalized graph (nodes + edges) |
300
+ | `suppa_list_automation_runs` | List runs (executions) of an automation |
301
+ | `suppa_get_automation_run` | Get one run with per-node steps + trigger payload |
302
+ | `suppa_list_automation_node_types` | Node-type catalog (authoritative + fallback) |
303
+ | `suppa_get_automation_node_schema` | Parameter schema for one node type |
304
+ | `suppa_search_entities` | Fuzzy-find an entity by name/title (+ record count) |
305
+ | `suppa_create_automation` | Create an automation (pre-flight validated; draft) |
306
+ | `suppa_update_automation` | Update an automation (read-modify-write; confirm-gated) |
307
+ | `suppa_delete_automation` | Delete an automation (confirm-gated) |
308
+ | `suppa_publish_automation` | Publish the draft snapshot (confirm-gated) |
309
+ | `suppa_unpublish_automation` | Deactivate an automation (confirm-gated) |
310
+
311
+ ### Forms
312
+
313
+ | Tool | Description |
314
+ |---|---|
315
+ | `suppa_list_forms` | List forms |
316
+ | `suppa_get_form` | Get a form |
317
+ | `suppa_create_form` | Create a form (optionally generated from an entity) |
318
+ | `suppa_update_form` | Update a form (confirm-gated) |
319
+ | `suppa_generate_form_schema` | Generate a grid form schema from an entity |
320
+ | `suppa_add_field_to_form` | Add a field element to a form (confirm-gated) |
321
+ | `suppa_list_form_field_types` | List form element types |
322
+
323
+ ### Migration (Suppa 1.0 → 2.0) & workspace
324
+
325
+ | Tool | Description |
326
+ |---|---|
327
+ | `suppa_migrate_entities_from_v1` | Migrate 1.0 entities → 2.0 (dry-run / create / gap-fill / reconcile) |
328
+ | `suppa_read_v1_entities` | Read entity list from a Suppa 1.0 tenant |
329
+ | `suppa_read_v1_entity_props` | Read 1.0 entity field definitions |
330
+ | `suppa_read_v1_enum` | Read 1.0 enum values |
331
+ | `suppa_create_workspace` | Create a workspace + nav item |
332
+ | `suppa_add_menu_item` | Add a navigation-menu item |
333
+
334
+ ---
335
+
336
+ ## Prompts
337
+
338
+ Guided workflows clients can expose as slash commands:
339
+
340
+ | Prompt | Arguments | Description |
341
+ |---|---|---|
342
+ | `plan_my_day` | — | Triage my Suppa tasks into a prioritized day plan |
343
+ | `build_entity` | `entity_purpose` | Guided design + creation of a new entity, fields, enums, and a form |
344
+ | `migrate_from_v1` | `entity_names?` | Guided Suppa 1.0 → 2.0 schema migration (dry-run, review, execute) |
345
+ | `write_entity_code` | `entity_purpose` | Guided: write v2 application schema code (entities, seeds, registration) instead of API calls |
346
+
347
+ ---
348
+
349
+ ## Bundled agent skill: suppa-entity-code
350
+
351
+ The package ships an agent skill at `skills/suppa-entity-code/` (also installed
352
+ via npm) that writes **Suppa v2 application schema code** — `*.entity.ts`
353
+ classes, `*.seed.ts` seeds, and the `EntityModule.forFeature()` registration —
354
+ following the platform's declarative-migration rules, where the entity class
355
+ *is* the migration.
356
+
357
+ Two flows:
358
+
359
+ - **Flow A** — design a new entity/seed in an application repo.
360
+ - **Flow B** — port a Suppa 1.0 entity to v2 code, using the same
361
+ type-mapping authority as `suppa_migrate_entities_from_v1`.
362
+
363
+ It includes a static validator that catches everything `tsc` cannot:
364
+
365
+ ```bash
366
+ node <this-skill-dir>/scripts/validate-suppa-schema.mjs <app-root>
367
+ # (installed via npm: node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs)
368
+ ```
369
+
370
+ Checks: SQL-string defaults, decorator misuse, thunk-less relations, an
371
+ `inverse` selector wrongly passed to `@ManyToOne`/`@ManyToMany` (W609) or
372
+ pointing at a non-relation property such as `id` on any of the four relation
373
+ decorators (E111), seed idempotency (importKeyFields / `$key`), forbidden
374
+ seed keys, numeric relation ids, reverse `@OneToMany` references, `forFeature`
375
+ membership, seed dependency order, `dist/` autoload paths, tsconfig decorator
376
+ flags, unknown `@Entity()`/`@Column()` options or field types, and tabular-part rules —
377
+ the `type: 'tabular-part'` + `relationEntityName` + `owner` triad, `owner`
378
+ resolving to the right parent, and `owner` first in `importKeyFields`
379
+ (E108/E109/E110/W607) — validated against the installed `@suppa/sdk` typings
380
+ when resolvable, falling back to the doc tables otherwise
381
+ (E101/E102/E107/E501/E502). Options/records/registration arrays delivered via
382
+ spread or by reference can't be statically checked and fire a W606 warning
383
+ instead. An entity or seed left out of `EntityModule.forFeature()` fires
384
+ E301/E302, naming the module file to edit so the fix is a find-and-add, not a
385
+ search. Use the `write_entity_code` MCP prompt to drive it from any client.
386
+
387
+ **Make the rules unskippable.** Stating a rule in a skill, in the server
388
+ instructions and in a tool description is optional at the moment code gets
389
+ written — an agent may open none of them, and that is exactly how an entity
390
+ shipped with restated defaults and four bare relation stand-ins. Install the
391
+ guards into an application repo:
392
+
393
+ ```bash
394
+ npx suppa-entity-guards .
395
+ # or, without npx:
396
+ node node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/install-entity-code-guards.mjs .
397
+ ```
398
+
399
+ It is idempotent, and it refuses to write a hook whose path does not resolve —
400
+ hooks pointing at nothing behave exactly like no hooks at all.
401
+
402
+ **Adding the package runs this for you.** A `postinstall` installs the guards into
403
+ the repo the install was run from, so a developer who never reads this file still
404
+ gets them. It refuses far more often than it acts: never when
405
+ `SUPPA_NO_GUARD_INSTALL` is set, never in CI (where hooks do nothing and the CI job
406
+ is its own layer), never for a global install, and never for a repo with no sign of
407
+ Suppa schema code — no `@suppa/*` dependency and no `*.entity.ts`. A package install
408
+ is not permission to configure an unrelated project. It also never fails an install:
409
+ whatever happens, it exits 0 and prints one line saying what to run by hand.
410
+
411
+ One caveat worth knowing: `npm ci --ignore-scripts` skips it, which is common in CI
412
+ and in locked-down organisations. There the CI job is the layer that holds.
413
+
414
+ Five layers, each covering a way the previous one is missed: Claude Code hooks
415
+ put the rules in an agent's context **before** it writes `*.entity.ts` and the
416
+ gate's findings in front of it **after**, a `Stop` hook refuses to end a turn
417
+ while a changed schema file still fails, `.githooks/pre-commit` refuses the
418
+ commit, a `.gitlab/suppa-schema-gate.yml` job refuses the merge request, and a
419
+ managed section in `AGENTS.md` / `CLAUDE.md` carries the same rules to editors
420
+ with no hook support. Re-running the installer is safe, `--dry-run` prints the
421
+ plan, and details are in `skills/suppa-entity-code/references/enforcement.md`.
422
+
423
+ It also enforces the **authoring rules** the platform doc does not: a
424
+ relation property must carry a TypeScript type that agrees with its decorator
425
+ (E114/E115/W610, and W615 when the type names no class at all — `any`), enum
426
+ member keys are PascalCase (W611), no field option may be written at its
427
+ platform default (W612), `@Enum`/`@MultiEnum` take a global name only when
428
+ the enum is actually shared (W613), and a relation target that already exists on
429
+ the tenant is declared as a **stub**: `@Entity({ name, key })` + `extends
430
+ SystemBaseEntity`, an **empty body**, alone in a `<name>.stub.entity.ts` file,
431
+ registered in `forFeature()`. A bare `export class Accounts {}` satisfies the
432
+ thunk but registers nothing, so the platform cannot resolve the relation — the
433
+ target is chased through its import (relative, `.js`-suffixed or tsconfig-aliased)
434
+ into the file that declares it and reported as E116. A stub that kept its fields
435
+ is E117, because each field is a column the migration would create on a table
436
+ another application owns; the `.stub.entity.ts` name is what makes that rule
437
+ checkable (W617 when it is missing, W616 when stubs share a file).
438
+
439
+ A stub stands in for a table so a relation can reach it. To **add columns** to an
440
+ entity you do not own — a platform system entity, or another application's — the
441
+ platform supports an **extension**: the entity's existing name, only your own
442
+ columns, in `<owner>.extension.entity.ts` (SKILL.md rule 20,
443
+ `references/extensions.md`). The mode is chosen by ownership at start, so the
444
+ filename is what lets the gate apply extension mode's restrictions before the
445
+ build does: entity options are ignored there (W618), `@OneToMany` /
446
+ `@ManyToManyBackRef` (E118) and `primary: true` (E119) are refused, `nullable:
447
+ false` needs a `default` (E120), and `@Index`/`@Check` may cover only the columns
448
+ you declare (E121). A relation to an entity you do not own names its target by
449
+ string and is typed by shape — right there, W620 anywhere else.
450
+
451
+ Those, plus
452
+ `owner` first in a tabular part's `importKeyFields` (W607) and no `inverse` on
453
+ `@ManyToOne`/`@ManyToMany` (W609), are the **rule violations** — W607, W609,
454
+ W610, W611, W612, W613, W615, W616, W617, W618, W620 — and like errors they exit 1, because a
455
+ rule that only warns is a rule that gets ignored. `--no-strict` demotes them for a legacy repo, and says so:
456
+ they print as `[rule violation, demoted]` and the summary ends `NOT a clean
457
+ run`. Advisory warnings — W601-W606, W608, W614 — never block; they report what
458
+ the checker could not see.
459
+
460
+ Tabular parts (owned child sub-tables like checklist items or order lines)
461
+ and the remove-and-re-add-a-field semantics — a re-added field restores its
462
+ old data because the key defaults to `<EntityName>.<fieldName>` — are both
463
+ covered; see `references/tabular-parts.md` and `references/registration.md`.
464
+
465
+ ---
466
+
467
+ ## Development
468
+
469
+ ```bash
470
+ # Install dependencies
471
+ npm install
472
+
473
+ # Build
474
+ npm run build
475
+
476
+ # Run locally (stdio)
477
+ node dist/bin.js
478
+
479
+ # Test with MCP Inspector
480
+ npm run inspect
481
+
482
+ # Tests
483
+ npm test
484
+
485
+ # Watch mode
486
+ npm run dev
487
+ ```
488
+
489
+ ---
490
+
491
+ ## Publish to npm
492
+
493
+ ```bash
494
+ # 1. Make sure you're logged in
495
+ npm login
496
+
497
+ # 2. Build & publish
498
+ npm publish
499
+ ```
500
+
501
+ The `prepublishOnly` script automatically runs `tsc` + the full test suite before publishing.
502
+
503
+ ---
504
+
505
+ ## Project structure
506
+
507
+ ```
508
+ suppa-mcp-node/
509
+ ├── src/
510
+ │ ├── bin.ts # Entry point — stdio transport
511
+ │ ├── server.ts # McpServer + all 84 tool + 4 prompt registrations
512
+ │ ├── config.ts # Env / .env config surface
513
+ │ ├── store.ts # Credentials in the OS keychain (@napi-rs/keyring)
514
+ │ ├── registry.ts # Non-secret tenant registry (~/.suppa-mcp/tenants.json)
515
+ │ ├── tenants.ts # Tenant context, active tenant, resolve, diagnostics
516
+ │ ├── auth.ts # JWT refresh (single-flight) + browser Google login
517
+ │ ├── httpClient.ts # fetch client: retry, envelope unwrap, 401→refresh→retry
518
+ │ ├── utils.ts # filters, dates, JSON params, multipart, confirm gate
519
+ │ └── tools/
520
+ │ ├── tasks.ts docs.ts entity.ts forms.ts
521
+ │ ├── automation.ts # read + write automation tools
522
+ │ ├── migrate.ts nameMap.ts v1Fields.ts
523
+ │ └── workspace.ts
524
+ ├── skills/suppa-entity-code/ # bundled agent skill: write v2 schema code + validator
525
+ ├── test/ # vitest suite (ports the Python test suite)
526
+ ├── scripts/ # live read-only / write verify scripts
527
+ ├── package.json
528
+ ├── tsconfig.json
529
+ ├── vitest.config.ts
530
+ └── README.md
531
+ ```
532
+
533
+ ---
534
+
535
+ ## License
536
+
537
+ MIT — see [LICENSE](LICENSE).