suppa-mcp-2 1.6.0 → 1.6.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/dist/server.js +25 -8
- package/dist/tools/files.js +67 -20
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -269,7 +269,7 @@ ATTACHMENTS (files on a record)
|
|
|
269
269
|
- 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.
|
|
270
270
|
- 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.
|
|
271
271
|
- 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.
|
|
272
|
-
- 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
|
|
272
|
+
- 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.
|
|
273
273
|
- 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.
|
|
274
274
|
|
|
275
275
|
MIGRATION (Suppa 1.0 → 2.0)
|
|
@@ -305,7 +305,7 @@ export function buildServer() {
|
|
|
305
305
|
// Reset so repeated buildServer() calls (e.g. in tests) do not double-count.
|
|
306
306
|
TOOL_NAMES.length = 0;
|
|
307
307
|
PROMPT_NAMES.length = 0;
|
|
308
|
-
const server = new McpServer({ name: "suppa-2.0", version: "1.6.
|
|
308
|
+
const server = new McpServer({ name: "suppa-2.0", version: "1.6.1" }, { instructions: INSTRUCTIONS });
|
|
309
309
|
const reg = (name, cfg, handler) => {
|
|
310
310
|
server.registerTool(name, {
|
|
311
311
|
description: cfg.description,
|
|
@@ -1519,16 +1519,33 @@ export function buildServer() {
|
|
|
1519
1519
|
annotations: _READ,
|
|
1520
1520
|
}, async (a) => text(await files.downloadFile(a.file_id, a.dest_path, a.file_type, a.overwrite)));
|
|
1521
1521
|
reg("suppa_download_files_zip", {
|
|
1522
|
-
description: "Download several
|
|
1522
|
+
description: "Download several attachments at once as one ZIP archive.\n" +
|
|
1523
1523
|
"\n" +
|
|
1524
|
-
"
|
|
1525
|
-
"
|
|
1524
|
+
" Two ways to choose what goes in, and exactly one of them at a time:\n" +
|
|
1525
|
+
" file_ids — those specific files\n" +
|
|
1526
|
+
" entity_name + record_ids — EVERY file attached to those records\n" +
|
|
1527
|
+
" file_ids are ids from the 'Files' entity, as returned by\n" +
|
|
1528
|
+
" suppa_list_record_files or suppa_attach_file_to_record.\n" +
|
|
1529
|
+
"\n" +
|
|
1530
|
+
" dest_path must be ABSOLUTE; point it at a directory and the archive is\n" +
|
|
1531
|
+
" named download.zip, since this endpoint sends no filename of its own.\n" +
|
|
1526
1532
|
" Nothing is overwritten unless overwrite=true.\n",
|
|
1527
1533
|
inputSchema: {
|
|
1528
1534
|
file_ids: z
|
|
1529
1535
|
.array(z.number().int())
|
|
1530
|
-
.
|
|
1531
|
-
.
|
|
1536
|
+
.nullable()
|
|
1537
|
+
.default(null)
|
|
1538
|
+
.describe("Ids of rows in the 'Files' entity. Use this OR entity_name + record_ids."),
|
|
1539
|
+
entity_name: z
|
|
1540
|
+
.string()
|
|
1541
|
+
.nullable()
|
|
1542
|
+
.default(null)
|
|
1543
|
+
.describe("Entity whose records' attachments to fetch. Pair with record_ids."),
|
|
1544
|
+
record_ids: z
|
|
1545
|
+
.array(z.number().int())
|
|
1546
|
+
.nullable()
|
|
1547
|
+
.default(null)
|
|
1548
|
+
.describe("Record ids whose every attachment goes into the archive."),
|
|
1532
1549
|
dest_path: z
|
|
1533
1550
|
.string()
|
|
1534
1551
|
.describe("Absolute path to write the .zip to — a file, or a directory."),
|
|
@@ -1538,7 +1555,7 @@ export function buildServer() {
|
|
|
1538
1555
|
.describe("Allow replacing an existing archive at dest_path."),
|
|
1539
1556
|
},
|
|
1540
1557
|
annotations: _READ,
|
|
1541
|
-
}, async (a) => text(await files.downloadFilesZip(a.file_ids, a.dest_path, a.overwrite)));
|
|
1558
|
+
}, async (a) => text(await files.downloadFilesZip(a.file_ids, a.dest_path, a.overwrite, a.entity_name, a.record_ids)));
|
|
1542
1559
|
reg("suppa_attach_file_to_record", {
|
|
1543
1560
|
description: "Attach a local file to a record (instance) of any entity.\n\n" +
|
|
1544
1561
|
" Auto-detects the entity's file/attachment field from its schema; pass\n" +
|
package/dist/tools/files.js
CHANGED
|
@@ -27,8 +27,8 @@ const MAX_LIMIT = 500;
|
|
|
27
27
|
*
|
|
28
28
|
* Body is {recordId, limit, offset} (files.txt:164-167; limit is REQUIRED).
|
|
29
29
|
* The response rows carry fileName/filePath/pdfPath/previewPath/size/mimeType/
|
|
30
|
-
* type (files.txt:176-183)
|
|
31
|
-
*
|
|
30
|
+
* type (files.txt:176-183) plus an `id` the doc's table omits — see the note
|
|
31
|
+
* where the ids are collected.
|
|
32
32
|
*/
|
|
33
33
|
export async function listRecordFiles(entityName, recordId, limit = 50, offset = 0) {
|
|
34
34
|
const name = String(entityName ?? "").trim();
|
|
@@ -45,19 +45,29 @@ export async function listRecordFiles(entityName, recordId, limit = 50, offset =
|
|
|
45
45
|
};
|
|
46
46
|
const result = await makeRequest("POST", `/api/core/files/${name}`, body);
|
|
47
47
|
const rows = Array.isArray(result) ? result : [];
|
|
48
|
+
// The doc's response table (files.txt:176-183) lists no id, but the platform
|
|
49
|
+
// does return one — verified on modern-expo.dev.suppa.me, 2026-08-17, where
|
|
50
|
+
// every row came back with `id` alongside fileName/filePath/size/mimeType.
|
|
51
|
+
// That id is what suppa_download_file takes, so surface it rather than
|
|
52
|
+
// sending the caller off to the Files entity as the doc's shape would imply.
|
|
53
|
+
const ids = rows
|
|
54
|
+
.filter((r) => r !== null && typeof r === "object")
|
|
55
|
+
.map((r) => r.id)
|
|
56
|
+
.filter((id) => typeof id === "number");
|
|
48
57
|
return jsonResponse({
|
|
49
58
|
entity: name,
|
|
50
59
|
record_id: body.recordId,
|
|
51
60
|
count: rows.length,
|
|
61
|
+
file_ids: ids,
|
|
52
62
|
files: rows,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
note: rows.length === 0
|
|
64
|
+
? "No files attached to this record — or the entity has no file field at all " +
|
|
65
|
+
"(check with suppa_describe_entity)."
|
|
66
|
+
: ids.length === rows.length
|
|
67
|
+
? "Pass any file_ids entry to suppa_download_file, or all of them to " +
|
|
68
|
+
"suppa_download_files_zip."
|
|
69
|
+
: "Some rows carry no id; for those, look the file up on the 'Files' entity with " +
|
|
70
|
+
"suppa_search_records to get one.",
|
|
61
71
|
});
|
|
62
72
|
}
|
|
63
73
|
/** Where a download may be written, and under what name. */
|
|
@@ -145,35 +155,72 @@ export async function downloadFile(fileId, destPath, fileType = "file", overwrit
|
|
|
145
155
|
return jsonResponse({ ...dest, bytes_received: res.bytes.length, not_written: true });
|
|
146
156
|
}
|
|
147
157
|
writeFileSync(dest.path, res.bytes);
|
|
148
|
-
|
|
158
|
+
const out = {
|
|
149
159
|
file_id: id,
|
|
150
160
|
file_type: fileType,
|
|
151
161
|
saved_to: dest.path,
|
|
152
162
|
bytes: res.bytes.length,
|
|
153
163
|
content_type: res.contentType,
|
|
154
164
|
suggested_name: suggested,
|
|
155
|
-
}
|
|
165
|
+
};
|
|
166
|
+
if (fileType !== "file") {
|
|
167
|
+
// Verified on modern-expo.dev.suppa.me, 2026-08-17: asking for 'preview' or
|
|
168
|
+
// 'pdf' on a file that has neither returns the ORIGINAL bytes, byte for
|
|
169
|
+
// byte, with no error — so a caller can end up with a .pdf that is not a
|
|
170
|
+
// PDF. The row's pdfPath / previewPath is what says whether the variant
|
|
171
|
+
// exists at all.
|
|
172
|
+
out.caveat =
|
|
173
|
+
`A '${fileType}' variant is not generated for every file. When it does not exist the ` +
|
|
174
|
+
"platform returns the ORIGINAL bytes with no error, so check the file's " +
|
|
175
|
+
`${fileType === "pdf" ? "pdfPath" : "previewPath"} in suppa_list_record_files before ` +
|
|
176
|
+
"trusting the format.";
|
|
177
|
+
}
|
|
178
|
+
return jsonResponse(out);
|
|
156
179
|
}
|
|
157
180
|
/**
|
|
158
181
|
* Several files at once, as a ZIP — POST core/files/download-all (files.txt:83).
|
|
159
182
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
183
|
+
* THE DOC'S BODY IS WRONG. files.txt:91 gives one required field,
|
|
184
|
+
* `instanceIds: number[]`, described as "List of file IDs (Files)". Sending
|
|
185
|
+
* exactly that is rejected — verified on modern-expo.dev.suppa.me, 2026-08-17:
|
|
186
|
+
*
|
|
187
|
+
* {"instanceIds":[2859,2860]}
|
|
188
|
+
* -> HTTP 400 validation.invalid_payload
|
|
189
|
+
* "Provide either fileIds or entityName with instanceIds"
|
|
190
|
+
*
|
|
191
|
+
* The endpoint takes one of two selections, both of which return a real zip
|
|
192
|
+
* (magic 50 4b 03 04), and neither of which sends Content-Type or
|
|
193
|
+
* Content-Disposition:
|
|
194
|
+
* {fileIds: [...]} — those files
|
|
195
|
+
* {entityName: "X", instanceIds: [...]} — every file of those RECORDS
|
|
196
|
+
* So `instanceIds` means RECORD ids, not file ids, and only alongside an
|
|
197
|
+
* entityName. Both modes are exposed here rather than picking one, because the
|
|
198
|
+
* second answers "give me everything attached to these records" in one call.
|
|
162
199
|
*/
|
|
163
|
-
export async function downloadFilesZip(fileIds, destPath, overwrite = false) {
|
|
200
|
+
export async function downloadFilesZip(fileIds, destPath, overwrite = false, entityName = null, recordIds = null) {
|
|
164
201
|
const ids = (fileIds ?? []).map((n) => Math.trunc(Number(n))).filter((n) => Number.isFinite(n));
|
|
165
|
-
|
|
202
|
+
const records = (recordIds ?? []).map((n) => Math.trunc(Number(n))).filter((n) => Number.isFinite(n));
|
|
203
|
+
const entity = String(entityName ?? "").trim();
|
|
204
|
+
const byFile = ids.length > 0;
|
|
205
|
+
const byRecord = entity !== "" && records.length > 0;
|
|
206
|
+
if (byFile === byRecord) {
|
|
166
207
|
return jsonResponse({
|
|
167
|
-
error:
|
|
208
|
+
error: byFile
|
|
209
|
+
? "Pass EITHER file_ids OR entity_name + record_ids, not both — the platform accepts " +
|
|
210
|
+
"one selection at a time."
|
|
211
|
+
: "Nothing selected. Pass file_ids (ids from the 'Files' entity), or entity_name " +
|
|
212
|
+
"together with record_ids to get every file attached to those records.",
|
|
168
213
|
});
|
|
169
214
|
}
|
|
215
|
+
const body = byFile ? { fileIds: ids } : { entityName: entity, instanceIds: records };
|
|
170
216
|
let res;
|
|
171
217
|
try {
|
|
172
|
-
res = await makeRequestBinary("POST", "/api/core/files/download-all",
|
|
218
|
+
res = await makeRequestBinary("POST", "/api/core/files/download-all", body);
|
|
173
219
|
}
|
|
174
220
|
catch (e) {
|
|
175
221
|
return jsonResponse({
|
|
176
|
-
error: `Download
|
|
222
|
+
error: `Download failed: ${e instanceof Error ? e.message : String(e)}`,
|
|
223
|
+
sent: body,
|
|
177
224
|
});
|
|
178
225
|
}
|
|
179
226
|
const suggested = filenameFromDisposition(res.contentDisposition) ?? "download.zip";
|
|
@@ -183,7 +230,7 @@ export async function downloadFilesZip(fileIds, destPath, overwrite = false) {
|
|
|
183
230
|
}
|
|
184
231
|
writeFileSync(dest.path, res.bytes);
|
|
185
232
|
return jsonResponse({
|
|
186
|
-
file_ids: ids,
|
|
233
|
+
selection: byFile ? { file_ids: ids } : { entity: entity, record_ids: records },
|
|
187
234
|
saved_to: dest.path,
|
|
188
235
|
bytes: res.bytes.length,
|
|
189
236
|
content_type: res.contentType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
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": {
|