suppa-mcp-2 1.3.1 → 1.3.2

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/dist/server.js CHANGED
@@ -260,7 +260,8 @@ ENTITY BUILDER (create + edit fields; removal is UI-only)
260
260
  - 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.
261
261
  - FIELD OPTIONS decide whether a field is usable: searchable, searchPriority (1-4), readOnly, canGroup, canSort, showInTable, editFromTable, canFilter. Pass options_json on suppa_add_field — a field created without them is missing from table views, and suppa_search_records' free-text search only covers fields marked searchable. Turn them on later with suppa_update_field.
262
262
  - 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.
263
- - Relations need relation_entity; enums need enum_name (qualified 'Entity.field') with values added via suppa_add_enum_values.
263
+ - 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.
264
+ - 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.
264
265
  - 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.
265
266
 
266
267
  MIGRATION (Suppa 1.0 → 2.0)
@@ -296,7 +297,7 @@ export function buildServer() {
296
297
  // Reset so repeated buildServer() calls (e.g. in tests) do not double-count.
297
298
  TOOL_NAMES.length = 0;
298
299
  PROMPT_NAMES.length = 0;
299
- const server = new McpServer({ name: "suppa-2.0", version: "1.3.1" }, { instructions: INSTRUCTIONS });
300
+ const server = new McpServer({ name: "suppa-2.0", version: "1.3.2" }, { instructions: INSTRUCTIONS });
300
301
  const reg = (name, cfg, handler) => {
301
302
  server.registerTool(name, {
302
303
  description: cfg.description,
@@ -1272,15 +1273,21 @@ export function buildServer() {
1272
1273
  }));
1273
1274
  });
1274
1275
  reg("suppa_add_enum_values", {
1275
- description: "Add values to an enum (lookup table). enum_name: qualified 'Entity.field'\n" +
1276
- " key (e.g. 'Receipts.type'). values: comma-separated list.",
1276
+ description: "Add values to an enum (lookup table). enum_name: the enum's global name,\n" +
1277
+ " conventionally 'Entity.field' (e.g. 'Receipts.type'). values:\n" +
1278
+ " comma-separated 'code' or 'code:Label' — a value with no label is\n" +
1279
+ " stored with the code as its label, never blank.\n" +
1280
+ " Call this BEFORE creating the enum field, then pass the same\n" +
1281
+ " enum_name to suppa_add_field.",
1277
1282
  inputSchema: {
1278
1283
  enum_name: z
1279
1284
  .string()
1280
- .describe("Qualified 'Entity.field' enum key, e.g. 'Receipts.type'."),
1285
+ .describe("The enum's global name, conventionally 'Entity.field' (e.g. 'Receipts.type'). " +
1286
+ "It need not match the field name — one enum can back several fields."),
1281
1287
  values: z
1282
1288
  .string()
1283
- .describe("Comma-separated values to add; existing ones are skipped."),
1289
+ .describe("Comma-separated 'code' or 'code:Label' (e.g. \"new:New request,done:Done\"). " +
1290
+ "The label is what users see in the picker. Existing codes are skipped."),
1284
1291
  },
1285
1292
  annotations: _ADD,
1286
1293
  }, async (a) => text(await entity.addEnumValues(a.enum_name, a.values)));
@@ -1398,8 +1398,21 @@ export async function addField(entityName, fieldName, fieldType, title, opts = {
1398
1398
  if (relTarget) {
1399
1399
  fieldDef.relationTarget = relTarget;
1400
1400
  }
1401
- if (enumName) {
1402
- fieldDef.enumName = enumName;
1401
+ // An enum field is bound to its enum through `relationTarget`, exactly like a
1402
+ // relation — builder.txt:63 groups enum/multi-enum under "Relation types" and
1403
+ // :44 types relationTarget as "Related entity", which for these is the enum's
1404
+ // global name.
1405
+ //
1406
+ // This server used to send `enumName` instead. That key is in no doc capture,
1407
+ // and it is INERT: verified on a live 2.0 tenant (modern-expo.dev.suppa.me,
1408
+ // 2026-08-05) by creating the same field both ways and reading the schema
1409
+ // back — `enumName` produced subType=null, relationTarget=null (an unbound
1410
+ // field with no values behind it), while `relationTarget` produced
1411
+ // subType=relationTarget=<enum name>, matching every working enum field on
1412
+ // that tenant. The add-fields response echoes `enumName` back, which is why
1413
+ // the failure looked like success for so long.
1414
+ if (enumName && (resolvedType === "enum" || resolvedType === "multi-enum")) {
1415
+ fieldDef.relationTarget = enumName;
1403
1416
  }
1404
1417
  // builder.txt:60 — "options | object | false | Field options configuration."
1405
1418
  // (example body: builder.txt:127-132).
@@ -1638,27 +1651,50 @@ export async function updateField(entityName, fieldName, opts = {}) {
1638
1651
  * create duplicate rows.
1639
1652
  */
1640
1653
  export async function addEnumValues(enumName, values) {
1641
- const valueList = values
1654
+ // "code" or "code:Label". The label is what a user sees in the picker; the
1655
+ // code is what the row stores. Every working enum on a live tenant carries a
1656
+ // title, and a row inserted without one reads back title:null — an option
1657
+ // that shows up blank. This server used to insert {name, value} only, so
1658
+ // every enum it created had untitled options.
1659
+ const parsed = values
1642
1660
  .split(",")
1643
- .map((v) => v.trim())
1644
- .filter((v) => v);
1645
- if (valueList.length === 0) {
1646
- return jsonResponse({ error: "No values provided — pass a comma-separated list." });
1661
+ .map((raw) => raw.trim())
1662
+ .filter((raw) => raw)
1663
+ .map((raw) => {
1664
+ const sep = raw.indexOf(":");
1665
+ const value = (sep === -1 ? raw : raw.slice(0, sep)).trim();
1666
+ const title = (sep === -1 ? "" : raw.slice(sep + 1).trim()) || value;
1667
+ return { value, title };
1668
+ })
1669
+ .filter((v) => v.value);
1670
+ if (parsed.length === 0) {
1671
+ return jsonResponse({
1672
+ error: "No values provided — pass a comma-separated list, e.g. \"new,inProgress\" or " +
1673
+ '"new:New request,inProgress:In progress" to set the labels users see.',
1674
+ });
1647
1675
  }
1648
1676
  const existingRows = await searchEntity("Enums", [makeFilter("name", enumName)], { id: true, value: true }, 1000);
1649
1677
  const existing = new Set(existingRows
1650
1678
  .filter((r) => r !== null && typeof r === "object")
1651
1679
  .map((r) => String(r.value)));
1652
- const newValues = valueList.filter((v) => !existing.has(v));
1653
- const skipped = valueList.filter((v) => existing.has(v));
1680
+ const newValues = parsed.filter((v) => !existing.has(v.value));
1681
+ const skipped = parsed.filter((v) => existing.has(v.value)).map((v) => v.value);
1654
1682
  let result = [];
1655
1683
  if (newValues.length > 0) {
1656
1684
  // The /api/core/data-bulk/{entity} endpoint returns 201 but silently
1657
1685
  // persists nothing; the regular insert action actually stores the batch.
1658
- result = await insertEntity("Enums", newValues.map((v) => ({ name: enumName, value: v })));
1686
+ // `title` goes as a plain string: that is the shape the platform's own enum
1687
+ // rows read back as, while a localization object read back as raw JSON.
1688
+ result = await insertEntity("Enums", newValues.map((v, i) => ({
1689
+ name: enumName,
1690
+ value: v.value,
1691
+ title: v.title,
1692
+ order: existing.size + i,
1693
+ })));
1659
1694
  }
1660
1695
  return jsonResponse({
1661
- added: newValues,
1696
+ added: newValues.map((v) => v.value),
1697
+ titles: Object.fromEntries(newValues.map((v) => [v.value, v.title])),
1662
1698
  skipped_existing: skipped,
1663
1699
  result,
1664
1700
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
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": {