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