suppa-mcp-2 1.26.0 → 1.27.1

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