suppa-mcp-2 1.16.1 → 1.18.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.
@@ -434,7 +434,12 @@ export async function searchEntity(entity, filters = null, fields = null, limit
434
434
  offset: Math.max(0, offset),
435
435
  orderBy: orderBy !== null ? orderBy : [{ field: "createdAt", order: "desc" }],
436
436
  searchValue,
437
- getAccessByFields: true,
437
+ // data.txt:72 — "Adds $readAccess and $updateAccess to each record". Those
438
+ // arrays are the same field names on every row of an entity, and NOTHING in
439
+ // this server reads them: a token audit over 104 transcripts put them at a
440
+ // third of everything suppa tools ever returned. The platform omits them
441
+ // unless asked, and asking was inherited from the v1 client.
442
+ getAccessByFields: false,
438
443
  // data.txt:75 — includeDeletedRelations "Keep related records that are
439
444
  // soft-deleted. Defaults to true." This client used to hard-code false,
440
445
  // which silently dropped soft-deleted relations from every read: a deleted
@@ -451,7 +456,7 @@ export async function selectEntity(entity, filters, fields = null, deletedScope
451
456
  const body = {
452
457
  conditions: { operator: "and", filters },
453
458
  fields: fields || { id: true },
454
- getAccessByFields: true,
459
+ getAccessByFields: false, // data.txt:72 — see searchEntity
455
460
  includeDeletedRelations, // data.txt:75 (platform default true; was hard-coded false)
456
461
  deletedScope, // data.txt:76
457
462
  };
@@ -492,7 +497,10 @@ export async function validateSelect(entity, payload) {
492
497
  : null;
493
498
  }
494
499
  export async function insertEntity(entity, fieldsList, returning = null) {
495
- const body = { fields: fieldsList };
500
+ // data.txt:325 — on insert the flag "Defaults to TRUE", so a write answers
501
+ // with the access arrays unless it is told not to. Same reasoning as the read
502
+ // path: nothing here reads them.
503
+ const body = { fields: fieldsList, getAccessByFields: false };
496
504
  if (returning) {
497
505
  body.returning = returning;
498
506
  }
package/dist/server.js CHANGED
@@ -230,55 +230,27 @@ AUTHENTICATION — RESOLVE THIS BEFORE ANY OTHER SUPPA WORK
230
230
  - suppa_use_tenant switches the active instance for ALL later calls; suppa_list_tenants shows what's known and authenticated.
231
231
 
232
232
  DATA BASICS
233
- - IDs are integers (not UUIDs).
234
- - Dates are ISO-8601 strings. A naive datetime (no offset) is treated as UTC — include an explicit offset (e.g. +03:00) or pre-convert local times to UTC to avoid a silent shift.
235
- - Task deadlines also accept 'today', 'tomorrow', '+3d', '+2h', '+30m', '+1w'.
236
- - WRITE relations as {"id": N} and enum fields as {"id": <enumValueId>} — a bare number/string would return 201 but silently store null; suppa_create_record/suppa_update_record therefore REFUSE malformed shapes with guidance.
237
- - REPLACE vs MERGE — an update REPLACES a list-valued field. {"watchers": [{"id": 15}]} does NOT add watcher 15; it makes 15 the ONLY watcher and the others are gone. To ADD items pass their field names in suppa_update_record's merge_json (e.g. ["watchers"]); to REMOVE only the items you list, pass them in unmerge_json. Every merged/unmerged name must also be in fields_json with an array value and no name may be in both lists; there is no cap on list length — the platform's 500 bounds the RECORDS one merge/unmerge update matches ("Cannot perform 'merge'/'unmerge': update query returned maximum allowed records; limit is 500"), and suppa_update_record matches a single record by id. suppa_update_task / suppa_update_doc / suppa_update_page / suppa_update_block have NO merge option — every list-valued field they write is replaced wholesale.
238
- - DELETE IS A SOFT DELETE — every delete tool here sets deletedAt and leaves the row in the database; the delete is reversible with suppa_restore_record(entity_name, record_id). Don't tell the user their data was destroyed. It still needs confirm=true, because the record disappears from all normal reads.
233
+ - IDs are integers (not UUIDs). Dates are ISO-8601 strings; a naive datetime (no offset) is read as UTC, so include an explicit offset (+03:00) or convert local times yourself. Task deadlines also accept 'today', 'tomorrow', '+3d', '+2h', '+30m', '+1w'.
234
+ - Every write tool's description carries the shapes it demands — relations and enums as {"id": N}, list fields REPLACED unless merge_json says otherwise, and validation against the live schema before anything is written. Read the one you are about to call; a bare number where a reference belongs returns 201 and stores null.
235
+ - DELETE IS A SOFT DELETE — every delete tool here sets deletedAt and leaves the row in place, reversible with suppa_restore_record(entity_name, record_id). Don't tell the user their data was destroyed. It still needs confirm=true, because the record disappears from all normal reads. To find a removed row again, read with deleted_scope='deleted'.
239
236
  - PERMANENT DELETE IS UNAVAILABLE HERE, BY DESIGN — this server performs REVERSIBLE deletes only. The platform's PERMANENT delete (POST /core/data/:entityName/delete: the rows leave the table and cannot be restored) is BLOCKED in the HTTP client itself, so no tool, no flag, no confirm=true and no direct call can reach it; an attempt is refused before the request is sent. Don't look for a tool, a parameter or a workaround — there is none. If a user asks to erase data for good, say so plainly and offer the soft delete (suppa_delete_record → /remove, undone by suppa_restore_record); permanent removal has to be done by an admin in the platform's own UI.
240
- - FINDING A DELETED RECORD — soft-deleted rows are hidden from every normal read. suppa_search_records / suppa_get_record take deleted_scope: 'active' (default), 'deleted' (only removed rows — this is how you get the id for suppa_restore_record), or 'all'. Project deletedAt to see which rows are removed and when.
241
- - Record writes are validated against the live schema BEFORE writing: an unknown field name or a non-existent entity is REFUSED (the platform silently drops unknown keys → a record missing data). Use only real fields (suppa_describe_entity), or add the field first with suppa_add_field. Don't invent field names.
242
- - READ enum fields back as objects: project {"myEnum": {"value": true}} and read .value, never as a bare string.
243
- - HTML content (descriptions, comments, blocks): plain text is auto-wrapped in <p>…</p>; to pass raw HTML start the string with <.
244
- - A document's LAST page cannot be deleted (platform rule) — delete the doc itself instead.
245
237
 
246
- SEARCH & FILTERS
247
- - Filters: {"field": "name", "value": "...", "comparator": "="} — comparators: =, !=, <, >, <=, >=, like, in, is null, is not null.
248
- - 'like' requires SQL wildcards: %substring%. 'in' takes a JSON array value.
249
- - Filters combine with AND by default; pass match_any=true (search_records) for OR.
250
- - MIXED AND/OR IN ONE CALL — a filters_json entry may be a nested GROUP {"operator": "and"|"or", "filters": [...]} (shorthand: {"or": [...]}), nested to any depth. (status=open AND owner=me) OR priority=high is: [{"or": [{"and": [{"field":"status.value","value":"open","comparator":"="},{"field":"owner.id","value":"$current-user","comparator":"="}]},{"field":"priority.value","value":"high","comparator":"="}]}]. Don't run several searches and merge them yourself.
251
- - AN EMPTY SEARCH RESULT IS DIAGNOSED FOR YOU — a misspelled field returns no records rather than an error, so suppa_search_records validates the payload (select/validate) whenever it gets zero rows or a 400 and returns a "validation" block naming the reference that does not resolve. Read it before concluding "there is no such data". suppa_validate_select does the same check on demand, without running the query.
252
- - CREATING MANY RECORDS — pass a JSON ARRAY to suppa_create_record's fields_json; the whole batch goes in ONE request with one schema check. Don't loop the tool per record.
253
- - Dotted field paths work in filters: "stage.status.value", "owner.id".
254
- - Magic value "$current-user" resolves to the authenticated user's ID.
255
- - Project only the fields you need (fields_json) — it keeps responses small and fast.
256
- - suppa_search_tasks / suppa_search_records return {…, "has_more", "next_offset"}: when has_more is true, re-call with offset=next_offset to page; never assume the first page is everything.
257
- - One record by id: suppa_get_record (any entity) / suppa_get_task / suppa_get_doc — no filters needed.
258
- - Discover schema first when unsure: suppa_list_entities → suppa_describe_entity, then suppa_search_records.
238
+ SEARCH & FILTERS — suppa_search_records' description carries the comparators, nested AND/OR groups, dotted field paths, "$current-user", paging and the auto-diagnosis of an empty result. Read it before your first search.
239
+ - PROJECT ONLY THE FIELDS YOU NEED (fields_json). It is the difference between a 600-character answer and a 50 000-character one, and every answer is re-sent on every later turn of the conversation.
240
+ - Discover schema first when unsure: suppa_list_entities → suppa_describe_entity, then suppa_search_records. One record by id needs no filters at all: suppa_get_record / suppa_get_task / suppa_get_doc.
259
241
 
260
242
  APPROVAL GATES (human-in-the-loop)
261
243
  - Every update/move/close/delete tool returns {"status": "confirmation_required"} when called without confirm=true, and performs NOTHING.
262
244
  - On that response: show the user what will change, get explicit approval, then re-call the same tool with confirm=true. Never set confirm=true on the first call without the user's go-ahead.
263
245
  - Create/read tools (and comments) need no confirmation.
264
246
 
265
- ENTITY BUILDER (create + edit fields; removal is UI-only)
266
- - Real field types only: text, numeric, integer, serial, boolean, timestamp, json, uuid, multi-language, bytea, tsvector, multi-type, icon, enum, multi-enum, file, multi-file, many-to-one, many-to-many, many-to-many-backref. There is NO date/datetime/richtext/email/url/phone type — use timestamp (+sub_type='date') or multi-language.
267
- - sub_type matrix: timestamp → 'date' | 'time' | 'timestamp'; text → 'encrypted'; enum/multi-enum → the enum's global name, set by the platform (never pass it); every other type takes none. Anything else is refused before the request.
268
- - FIELD OPTIONS: searchable, searchPriority (1-4), readOnly, canGroup, canSort, showInTable, editFromTable, canFilter. Omit options_json and the platform fills in its own defaults — visible, sortable, groupable, filterable, editable, not read-only, and NOT searchable. So the one worth passing is searchable (+searchPriority): suppa_search_records' free-text search only covers fields marked searchable. Turn any of them on later with suppa_update_field.
269
- - OWNED CHILD COLLECTIONS ARE TABULAR PARTS. Repeating rows that belong to one parent record (e.g. a part's BOM items) → suppa_create_tabular_part(parent_entity, name), which auto-creates the child's 'owner' relation and the parent link. NEVER model this by hand as parent.one-to-many + child.owner: suppa_add_field REFUSES field_type='one-to-many'. Use 'many-to-many' only for a shared lookup referenced by many records.
270
- - Relations need relation_entity; enums need enum_name (the enum's global name, conventionally 'Entity.field'). Add the values FIRST with suppa_add_enum_values, then create the field with the same enum_name — the field is bound to the enum by that name.
271
- - An enum value on a RECORD is a reference, not a string: write {"id": <Enums row id>} for enum and [{"id": ...}, ...] for multi-enum. A bare code like "red" is refused with 'field must contain id for many-to-one relationship'. Read the ids with suppa_search_records on 'Enums' filtered by name = the enum name.
272
- - Existing fields CAN be edited with suppa_update_field (name, title, notNull/unique/default, relation target, and the options above), within the platform's own limits: a field's TYPE can never be changed, its SUBTYPE only toggles 'encrypted' on/off (text fields only), and a system field takes just title + the options keys. Removing a field is still UI-only — this server has no remove-field call.
247
+ ENTITY BUILDER (create + edit fields; removal is UI-only) — suppa_add_field's description carries the real field types, the sub_type matrix and the field options; suppa_update_field's carries what may still be changed on a field that exists. Two things those cannot decide for you:
248
+ - OWNED CHILD COLLECTIONS ARE TABULAR PARTS. Repeating rows belonging to ONE parent record (a part's BOM items) go through suppa_create_tabular_part(parent_entity, name), which creates the child's 'owner' relation and the parent link. Never model it by hand — suppa_add_field REFUSES field_type='one-to-many'. 'many-to-many' is for a shared lookup referenced by many records.
249
+ - An enum value on a RECORD is a reference, not a string: {"id": <Enums row id>}, or an array of those for multi-enum. A bare code like "red" is refused. Read the ids with suppa_search_records on 'Enums' filtered by name.
273
250
 
274
251
  ${HOUSE_RULES_DIGEST}
275
252
 
276
- ATTACHMENTS (files on a record)
277
- - A record can carry files only if its entity has a 'file' or 'multi-file' field; check with suppa_describe_entity and add one with suppa_add_field if it has none.
278
- - WRITE: suppa_attach_file_to_record(entity, record_id, absolute_path) uploads from the local disk and returns file_ids — keep them, they are the only handle that gets the bytes back.
279
- - READ: suppa_list_record_files(entity, record_id) lists fileName/size/mimeType/paths for one record. It does NOT return ids; get those from the attach response, or with suppa_search_records on the 'Files' entity.
280
- - GET THE BYTES: suppa_download_file(file_id, absolute_dest_path) writes one file to disk — file_type='file' (original), 'preview' or 'pdf'. suppa_download_files_zip fetches several as one archive — by file_ids, or by entity_name + record_ids for everything attached to those records. Nothing is overwritten unless overwrite=true.
281
- - To duplicate a record's attachments onto a copy, use suppa_copy_record(copy_files=true) — there is no local path for a file that already lives on the platform.
253
+ ATTACHMENTS (files on a record) — an entity can hold files only if it has a 'file' or 'multi-file' field; add one with suppa_add_field. suppa_attach_file_to_record uploads from local disk and returns the file_ids that are the only handle to the bytes; suppa_list_record_files lists what a record carries; suppa_download_file and suppa_download_files_zip fetch them. Those descriptions carry the rest.
282
254
 
283
255
  MIGRATION (Suppa 1.0 → 2.0)
284
256
  - Always dry-run first: suppa_migrate_entities_from_v1(dry_run=true, output_file="plan.json"), review/edit the plan, then execute with plan_file="plan.json", dry_run=false.
@@ -370,7 +342,9 @@ export function buildServer() {
370
342
  annotations: _READ,
371
343
  }, async (a) => text(await tasks.getTask(a.task_id)));
372
344
  reg("suppa_create_task", {
373
- description: "Create a new task. Deadline accepts: 'today', 'tomorrow', '+3d', '+2h', '+30m', '+1w', or ISO datetime.",
345
+ description: "Create a new task. Deadline accepts: 'today', 'tomorrow', '+3d', '+2h', '+30m', '+1w', or ISO datetime.\n" +
346
+ " HTML: plain text is auto-wrapped in <p>…</p>; to pass raw HTML, start the\n" +
347
+ " string with <.",
374
348
  inputSchema: {
375
349
  title: z.string(),
376
350
  description: TaskDescriptionNew.default(""),
@@ -483,7 +457,9 @@ export function buildServer() {
483
457
  return text(await tasks.closeTask(a.task_id));
484
458
  });
485
459
  reg("suppa_add_comment", {
486
- description: "Add a comment to a task. Supports HTML. mention_ids: comma-separated 'userId:Name' pairs for @mentions.",
460
+ description: "Add a comment to a task. Supports HTML — plain text is auto-wrapped in <p>…</p>, so\n" +
461
+ " start the string with < to pass raw markup. mention_ids: comma-separated\n" +
462
+ " 'userId:Name' pairs for @mentions.",
487
463
  inputSchema: {
488
464
  task_id: z.number().int(),
489
465
  content: z
@@ -739,7 +715,8 @@ export function buildServer() {
739
715
  annotations: _ADD,
740
716
  }, async (a) => text(await docs.insertBlock(a.page_id, a.blocks_json, a.after_id, a.before_id)));
741
717
  reg("suppa_update_block", {
742
- description: "Update a block's content. Provide title (text/HTML) or full properties_json.\n\n" +
718
+ description: "Update a block's content. Provide title (text/HTML) or full properties_json.\n" +
719
+ " Plain text is auto-wrapped in <p>…</p>; start the string with < for raw HTML.\n\n" +
743
720
  " properties_json REPLACES the block's properties wholesale (as does any\n" +
744
721
  " list-valued field) — this tool has no merge option; read the current\n" +
745
722
  " properties with suppa_get_blocks first and re-send them in full.\n\n" +
@@ -855,6 +832,10 @@ export function buildServer() {
855
832
  }, async (a) => text(await entity.listTabularParts(a.entity_name)));
856
833
  reg("suppa_search_records", {
857
834
  description: "Search records of any entity. filters_json: [{field, value, comparator}]. fields_json: {field: true}.\n" +
835
+ " Comparators: =, !=, <, >, <=, >=, like, in, is null, is not null. 'like' needs SQL\n" +
836
+ " wildcards ('%substring%'); 'in' takes a JSON array. Field paths may be dotted —\n" +
837
+ ' "stage.status.value", "owner.id" — and the value "$current-user" resolves to the\n' +
838
+ " signed-in user's id.\n" +
858
839
  " match_any=true combines filters with OR instead of AND.\n" +
859
840
  ' NESTED GROUPS: a filters_json entry may be {"operator": "and"|"or", "filters": [...]}\n' +
860
841
  " (nested to any depth), so (status=open AND owner=me) OR priority=high is ONE call.\n" +
@@ -1057,7 +1038,10 @@ export function buildServer() {
1057
1038
  " There is NO date/datetime/richtext/email/url/phone type — use timestamp\n" +
1058
1039
  " (+sub_type='date' for date-only) and multi-language for localized text.\n" +
1059
1040
  " 'relation' is accepted as an alias for many-to-one. Provide relation_entity for\n" +
1060
- " relations, enum_name for enums. Constraints: max_length/min_length (text),\n" +
1041
+ " relations, enum_name for enums. sub_type matrix: timestamp takes 'date' | 'time' |\n" +
1042
+ " 'timestamp', text takes 'encrypted', every other type takes none — for enum and\n" +
1043
+ " multi-enum the subtype IS the enum's global name and the platform sets it, so never\n" +
1044
+ " pass one. Constraints: max_length/min_length (text),\n" +
1061
1045
  " decimal_places / min_value / max_value / only_positive (numeric).\n" +
1062
1046
  " options_json tunes the field: showInTable, canFilter, canSort, canGroup,\n" +
1063
1047
  " editFromTable, readOnly, searchable + searchPriority (1-4). Omitted, the\n" +
@@ -1581,7 +1565,15 @@ export function buildServer() {
1581
1565
  description: "Attach a local file to a record (instance) of any entity.\n\n" +
1582
1566
  " Auto-detects the entity's file/attachment field from its schema; pass\n" +
1583
1567
  " field_name only when the entity has more than one file field. Provide the\n" +
1584
- " absolute file_path.",
1568
+ " absolute file_path.\n\n" +
1569
+ " A record can carry files at all only if its entity has a 'file' or 'multi-file'\n" +
1570
+ " field — check with suppa_describe_entity and add one with suppa_add_field if it\n" +
1571
+ " has none. KEEP THE RETURNED file_ids: they are the only handle that gets the bytes\n" +
1572
+ " back (suppa_download_file / suppa_download_files_zip). suppa_list_record_files\n" +
1573
+ " lists what a record carries but does NOT return ids; the other source for them is\n" +
1574
+ " suppa_search_records on the 'Files' entity. To put a record's attachments on a\n" +
1575
+ " copy, use suppa_copy_record(copy_files=true) — a file already on the platform has\n" +
1576
+ " no local path to re-upload from.",
1585
1577
  inputSchema: {
1586
1578
  entity_name: EntityName,
1587
1579
  record_id: z.number().int(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.16.1",
3
+ "version": "1.18.0",
4
4
  "description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
5
5
  "type": "module",
6
6
  "bin": {