@hiai-gg/docsmint 2.1.5 → 2.2.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.
@@ -300,6 +300,12 @@ class DocsClient {
300
300
  }, context);
301
301
  }
302
302
  async listDocuments(options = {}, context) {
303
+ return this.listDocumentCursor(options, context);
304
+ }
305
+ async listCatalogDocuments(options = {}, context) {
306
+ return this.listDocumentCursor(options, context, "catalog");
307
+ }
308
+ async listDocumentCursor(options, context, view) {
303
309
  return this.request("GET", "/api/documents/cursor", {
304
310
  query: this.cleanQuery({
305
311
  categoryId: options.categoryId,
@@ -314,6 +320,8 @@ class DocsClient {
314
320
  updatedTo: options.updatedTo,
315
321
  cursor: options.cursor,
316
322
  limit: options.limit,
323
+ view,
324
+ includeTotal: options.includeTotal === undefined ? undefined : String(options.includeTotal),
317
325
  sortBy: options.sortBy,
318
326
  sortOrder: options.sortOrder
319
327
  })
@@ -524,6 +532,12 @@ class DocsClient {
524
532
  async listAttachments(documentId, context) {
525
533
  return this.request("GET", `/api/documents/${encodeURIComponent(documentId)}/attachments`, undefined, context);
526
534
  }
535
+ async fetchAttachment(id, context) {
536
+ const response = await this.fetchRaw("GET", `/api/attachments/${encodeURIComponent(id)}/raw`, {}, context);
537
+ if (!response.ok)
538
+ throw await this.toApiError(response);
539
+ return response;
540
+ }
527
541
  async deleteAttachment(id, context) {
528
542
  await this.request("DELETE", `/api/attachments/${encodeURIComponent(id)}`, undefined, context);
529
543
  }
@@ -585,8 +599,11 @@ class DocsClient {
585
599
  headers.set("Cookie", requestContext.cookie);
586
600
  if (requestContext?.requestId)
587
601
  headers.set("X-Request-Id", requestContext.requestId);
588
- if (requestContext?.idempotencyKey)
602
+ if (requestContext?.idempotencyKey === null) {
603
+ headers.delete("Idempotency-Key");
604
+ } else if (requestContext?.idempotencyKey) {
589
605
  headers.set("Idempotency-Key", requestContext.idempotencyKey);
606
+ }
590
607
  if (method === "POST" && path === "/api/documents" && !headers.has("Idempotency-Key")) {
591
608
  headers.set("Idempotency-Key", crypto.randomUUID());
592
609
  }
@@ -1025,6 +1042,14 @@ var operationOutputSchemas = {
1025
1042
  permanently_delete_document: deleteAcknowledgmentSchema
1026
1043
  };
1027
1044
  var variant = (operation, result) => z.object({ operation: z.literal(operation), result });
1045
+ var attachment = z.object({
1046
+ id: z.string().uuid(),
1047
+ documentId: z.string().uuid().optional(),
1048
+ filename: z.string(),
1049
+ mimeType: z.string(),
1050
+ size: z.number().int().nonnegative(),
1051
+ url: z.string()
1052
+ });
1028
1053
  var singleToolOutputSchemas = {
1029
1054
  delete_document: operationOutputSchemas.delete_document,
1030
1055
  delete_folder: operationOutputSchemas.delete_folder,
@@ -1046,6 +1071,16 @@ var singleToolOutputSchemas = {
1046
1071
  variant("markdown", operationOutputSchemas.export_document),
1047
1072
  variant("versions", operationOutputSchemas.get_version_history)
1048
1073
  ]),
1074
+ upload_document_image: attachment,
1075
+ check_document_attachments: z.strictObject({
1076
+ items: z.array(attachment),
1077
+ verifiedAttachmentId: z.string().uuid().optional(),
1078
+ verification: z.strictObject({
1079
+ size: z.number().int().positive(),
1080
+ mimeType: z.string(),
1081
+ sha256: z.string().regex(/^[a-f0-9]{64}$/)
1082
+ }).optional()
1083
+ }),
1049
1084
  save_document: z.union([
1050
1085
  variant("create", operationOutputSchemas.create_document),
1051
1086
  variant("update", operationOutputSchemas.update_document)
@@ -1116,8 +1151,55 @@ function createMcpScopedResult(toolName, input) {
1116
1151
  // ../mcp-server/src/compact.ts
1117
1152
  import { z as z4 } from "zod";
1118
1153
 
1119
- // ../mcp-server/src/batch-workspace.ts
1120
- import { z as z3 } from "zod";
1154
+ // ../mcp-server/src/client.ts
1155
+ import { createHash as createHash2 } from "crypto";
1156
+
1157
+ // ../mcp-server/src/attachment-verification.ts
1158
+ import { createHash } from "crypto";
1159
+ var MAX_VERIFIED_IMAGE_BYTES = 16 * 1024 * 1024;
1160
+ async function verifyAttachmentResponse(response, attachment) {
1161
+ const reader = response.body?.getReader();
1162
+ if (!reader)
1163
+ throw new Error("The attachment response has no body.");
1164
+ try {
1165
+ const mimeType = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
1166
+ if (!response.ok || mimeType !== attachment.mimeType.toLowerCase())
1167
+ throw new Error("The stored attachment MIME type does not match its record.");
1168
+ if (!Number.isSafeInteger(attachment.size) || attachment.size <= 0 || attachment.size > MAX_VERIFIED_IMAGE_BYTES)
1169
+ throw new Error("The attachment exceeds the verification size limit.");
1170
+ const declaredLength = response.headers.get("content-length");
1171
+ if (declaredLength !== null && (!/^[0-9]+$/.test(declaredLength) || Number(declaredLength) !== attachment.size))
1172
+ throw new Error("The stored attachment length does not match its record.");
1173
+ const hash = createHash("sha256");
1174
+ let size = 0;
1175
+ let prefix = Buffer.alloc(0);
1176
+ for (;; ) {
1177
+ const { done, value } = await reader.read();
1178
+ if (done)
1179
+ break;
1180
+ size += value.byteLength;
1181
+ if (size > attachment.size || size > MAX_VERIFIED_IMAGE_BYTES)
1182
+ throw new Error("The attachment response exceeds its recorded size.");
1183
+ if (prefix.length < 12)
1184
+ prefix = Buffer.concat([
1185
+ prefix,
1186
+ Buffer.from(value.subarray(0, 12 - prefix.length))
1187
+ ]);
1188
+ hash.update(value);
1189
+ }
1190
+ if (size !== attachment.size)
1191
+ throw new Error("The attachment response is incomplete.");
1192
+ const imageMatches = mimeType === "image/webp" && prefix.toString("ascii", 0, 4) === "RIFF" && prefix.toString("ascii", 8, 12) === "WEBP" || mimeType === "image/png" && prefix.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])) || mimeType === "image/jpeg" && prefix[0] === 255 && prefix[1] === 216 && prefix[2] === 255 || mimeType === "image/gif" && ["GIF87a", "GIF89a"].includes(prefix.toString("ascii", 0, 6));
1193
+ if (!imageMatches)
1194
+ throw new Error("The attachment bytes do not match its image MIME type.");
1195
+ return { size, mimeType, sha256: hash.digest("hex") };
1196
+ } finally {
1197
+ await reader.cancel().catch(() => {
1198
+ return;
1199
+ });
1200
+ reader.releaseLock();
1201
+ }
1202
+ }
1121
1203
 
1122
1204
  // ../mcp-server/src/client.ts
1123
1205
  var DEFAULT_BASE_URL = "http://localhost:50700";
@@ -1157,6 +1239,45 @@ function sanitizeMcpRequestContext(context) {
1157
1239
  function createMcpDocsClient(docsClient, requestContext) {
1158
1240
  const context = sanitizeMcpRequestContext(requestContext);
1159
1241
  return {
1242
+ uploadDocumentImage: async (id, filename, mimeType, bytes, operationId) => {
1243
+ const descriptor = {
1244
+ filename,
1245
+ contentType: mimeType,
1246
+ size: bytes.byteLength,
1247
+ ...operationId ? { sourceSha256: createHash2("sha256").update(bytes).digest("hex") } : {}
1248
+ };
1249
+ const signal = context?.signal ? AbortSignal.any([context.signal, AbortSignal.timeout(30000)]) : AbortSignal.timeout(30000);
1250
+ const uploadContext = { ...context, signal, idempotencyKey: operationId ?? null };
1251
+ const upload = await docsClient.presignAttachment(id, descriptor, uploadContext);
1252
+ if (!upload.alreadyConfirmed) {
1253
+ const response = await fetch(upload.url, {
1254
+ method: "PUT",
1255
+ body: new Blob([Uint8Array.from(bytes)], { type: mimeType }),
1256
+ redirect: "error",
1257
+ signal
1258
+ }).catch(() => {
1259
+ throw new HiaiDocsError("Could not send image bytes to DocsMint storage.", 502, null, "IMAGE_STORAGE_UNAVAILABLE");
1260
+ });
1261
+ await response.body?.cancel();
1262
+ if (!response.ok)
1263
+ throw new HiaiDocsError(`DocsMint storage rejected the image (${response.status}).`, response.status, null, "IMAGE_STORAGE_REJECTED");
1264
+ }
1265
+ return docsClient.confirmAttachment(id, {
1266
+ ...descriptor,
1267
+ key: upload.key,
1268
+ uploadToken: upload.uploadToken,
1269
+ quotaReservationId: upload.quotaReservationId
1270
+ }, uploadContext);
1271
+ },
1272
+ listAttachments: (id) => docsClient.listAttachments(id, context),
1273
+ verifyAttachment: async (attachment) => {
1274
+ const signal = context?.signal ? AbortSignal.any([context.signal, AbortSignal.timeout(30000)]) : AbortSignal.timeout(30000);
1275
+ const response = await docsClient.fetchAttachment(attachment.id, {
1276
+ ...context,
1277
+ signal
1278
+ });
1279
+ return verifyAttachmentResponse(response, attachment);
1280
+ },
1160
1281
  getFolder: (id) => docsClient.getFolder(id, context),
1161
1282
  createTag: (input) => docsClient.createTag(input, context),
1162
1283
  updateTag: (id, input) => docsClient.updateTag(id, input, context),
@@ -1213,6 +1334,9 @@ var client = new Proxy({}, {
1213
1334
  }
1214
1335
  });
1215
1336
 
1337
+ // ../mcp-server/src/batch-workspace.ts
1338
+ import { z as z3 } from "zod";
1339
+
1216
1340
  // ../mcp-server/src/client-routing-schema.ts
1217
1341
  import { z as z2 } from "zod";
1218
1342
  function canonical(value) {
@@ -1422,6 +1546,18 @@ var content = z4.string().describe("Markdown document content; an empty string c
1422
1546
  var read = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
1423
1547
  var write = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
1424
1548
  var destructive = { ...write, destructiveHint: true };
1549
+ function matchesImageType(bytes, mimeType) {
1550
+ switch (mimeType) {
1551
+ case "image/png":
1552
+ return bytes.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]));
1553
+ case "image/jpeg":
1554
+ return bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255;
1555
+ case "image/webp":
1556
+ return bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP";
1557
+ default:
1558
+ return false;
1559
+ }
1560
+ }
1425
1561
  function required2(value, name) {
1426
1562
  if (!value)
1427
1563
  throw new Error(`The injected legacy MCP client does not support ${name}; use a public DocsClient.`);
@@ -1457,6 +1593,35 @@ function registerCompactCapabilities(server, client, wrap) {
1457
1593
  const { action: _action, id, ...data } = input;
1458
1594
  return { operation: "update", result: await client.updateDocument(id, data) };
1459
1595
  });
1596
+ const maxImageBytes = 2 * 1024 * 1024;
1597
+ register("upload_document_image", "Upload one PNG, JPEG or WebP image to an existing editable document. Send the file bytes as base64, up to 2 MiB before encoding. Insert the returned url as an image using save_document. If the result is lost, check attachments before uploading again.", z4.strictObject({
1598
+ documentId: uuid2,
1599
+ filename: z4.string().min(1).max(255).regex(/^[^/\\\u0000-\u001f\u007f]+$/).describe("Image file name with extension and without path segments."),
1600
+ mimeType: z4.enum(["image/png", "image/jpeg", "image/webp"]).describe("MIME type of the source image."),
1601
+ operationId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/).optional().describe("Stable upload operation ID. Reuse with identical bytes and metadata after timeout to prevent duplicates. Requires WebP finalization on the server."),
1602
+ contentBase64: z4.base64().min(4).max(Math.ceil(maxImageBytes / 3) * 4).describe("Base64 file bytes without a data: prefix.")
1603
+ }), write, async ({ documentId, filename, mimeType, contentBase64, operationId }) => {
1604
+ const bytes = Buffer.from(contentBase64, "base64");
1605
+ if (!bytes.length || bytes.length > maxImageBytes)
1606
+ throw new HiaiDocsError("Image must be between 1 byte and 2 MiB.", 413, null, "IMAGE_TOO_LARGE");
1607
+ if (!matchesImageType(bytes, mimeType))
1608
+ throw new HiaiDocsError("Image bytes do not match the declared MIME type.", 415, null, "IMAGE_MIME_MISMATCH");
1609
+ return { ...await required2(client.uploadDocumentImage, "upload_document_image")(documentId, filename, mimeType, bytes, operationId), documentId };
1610
+ });
1611
+ register("check_document_attachments", "List attachments on a readable document. Supply attachmentId to verify that this attachment belongs to the document and that its stored bytes can be opened with the current access.", z4.strictObject({
1612
+ documentId: uuid2,
1613
+ attachmentId: uuid2.optional()
1614
+ }), read, async ({ documentId, attachmentId }) => {
1615
+ const response = await required2(client.listAttachments, "check_document_attachments")(documentId);
1616
+ const items = response.items.map((item) => ({ ...item, documentId }));
1617
+ if (!attachmentId)
1618
+ return { items };
1619
+ const attachment = items.find((item) => item.id === attachmentId);
1620
+ if (!attachment)
1621
+ throw new HiaiDocsError("Attachment not found in this document.", 404, null, "ATTACHMENT_NOT_FOUND");
1622
+ const verification = await required2(client.verifyAttachment, "check_document_attachments")(attachment);
1623
+ return { items, verifiedAttachmentId: attachmentId, verification };
1624
+ });
1460
1625
  register("delete_document", "Move one document to trash without purging content or versions. Use batch_documents(action=trash) for multiple explicit IDs. Requires write access and an explicit delete request; permanently_delete_document is a separate irreversible action.", z4.strictObject({ id: uuid2 }), destructive, async ({ id }) => {
1461
1626
  await required2(client.deleteDocument, "delete_document")(id);
1462
1627
  return { id, deleted: true };
@@ -1624,6 +1789,8 @@ var capabilityCatalog = {
1624
1789
  "find_documents",
1625
1790
  "read_document",
1626
1791
  "save_document",
1792
+ "upload_document_image",
1793
+ "check_document_attachments",
1627
1794
  "delete_document",
1628
1795
  "list_workspace_structure",
1629
1796
  "save_folder",
@@ -1676,6 +1843,8 @@ function example(schema) {
1676
1843
  if (schema.type === "object" || schema.properties) {
1677
1844
  return Object.fromEntries(Object.entries(object2(schema.properties)).filter(([name]) => Array.isArray(schema.required) && schema.required.includes(name) || name === "title" || name === "name").map(([name, value]) => [name, example(object2(value))]));
1678
1845
  }
1846
+ if (schema.contentEncoding === "base64" || schema.format === "base64")
1847
+ return "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aCdwAAAAASUVORK5CYII=";
1679
1848
  if (schema.format === "uuid")
1680
1849
  return "11111111-1111-4111-8111-111111111111";
1681
1850
  if (schema.format === "date-time")
@@ -1885,7 +2054,7 @@ function registerDocsmintMcpCapabilities(server, client, workspaceRouting, decor
1885
2054
  registerPromptsAndResources(server, client);
1886
2055
  }
1887
2056
  function createDocsmintMcpServer(options = {}) {
1888
- const server = new DocsMintMcpServer({ name: "docsmint", version: "2.1.5" });
2057
+ const server = new DocsMintMcpServer({ name: "docsmint", version: "2.2.1" });
1889
2058
  const client = options.docsClient ? createMcpDocsClient(options.docsClient, options.requestContext) : options.client ?? createMcpDocsClient(createDefaultDocsClient(), options.requestContext);
1890
2059
  registerDocsmintMcpCapabilities(server, client, options.workspaceRouting, options.decorateResult);
1891
2060
  return server;
package/dist/types.d.ts CHANGED
@@ -83,6 +83,17 @@ export interface DocsDocumentCursorPage {
83
83
  items: DocsDocumentListItem[];
84
84
  nextCursor: string | null;
85
85
  }
86
+ export interface DocsCatalogCursorPage {
87
+ total?: number;
88
+ items: {
89
+ id: string;
90
+ title: string;
91
+ preview: string;
92
+ folderId: string | null;
93
+ folderName: string | null;
94
+ }[];
95
+ nextCursor: string | null;
96
+ }
86
97
  export type DocsDocumentSortField = "title" | "category" | "folder" | "updated" | "updatedAt" | "createdAt";
87
98
  export type DocsSortOrder = "asc" | "desc";
88
99
  export interface DocsFolder {
@@ -333,11 +344,15 @@ export interface DocsAttachmentListResponse {
333
344
  items: DocsAttachment[];
334
345
  }
335
346
  export interface DocsAttachmentPresignInput {
347
+ /** Optional original-byte SHA-256 for WebP finalization. */
348
+ sourceSha256?: string;
336
349
  filename: string;
337
350
  contentType: string;
338
351
  size: number;
339
352
  }
340
353
  export interface DocsAttachmentPresignResponse {
354
+ /** A completed replay. Skip PUT and repeat confirmAttachment. */
355
+ alreadyConfirmed?: boolean;
341
356
  url: string;
342
357
  key: string;
343
358
  /** Signed, exact admission identity required by confirmAttachment. */
@@ -487,8 +502,8 @@ export interface DocsRequestContext {
487
502
  signal?: AbortSignal;
488
503
  /** Per-request timeout in milliseconds, overriding the client default. */
489
504
  timeoutMs?: number;
490
- /** Idempotency key forwarded as the standard Idempotency-Key header. */
491
- idempotencyKey?: string;
505
+ /** Idempotency key forwarded as a header. Null clears any inherited key. */
506
+ idempotencyKey?: string | null;
492
507
  }
493
508
  /** Additive page-based list filters. All filters are applied server-side. */
494
509
  export interface DocsListOptions {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hiai-gg/docsmint",
3
3
  "mcpName": "io.github.HiAi-gg/docsmint",
4
- "version": "2.1.5",
4
+ "version": "2.2.1",
5
5
  "type": "module",
6
6
  "browser": {
7
7
  "./dist/backend-launcher.js": false,
@@ -386,7 +386,8 @@
386
386
  "commander": "^15.0.0",
387
387
  "ioredis": "^6.0.0",
388
388
  "zod": "4.6.7",
389
- "happy-dom": "21.0.4"
389
+ "happy-dom": "21.0.4",
390
+ "sharp": "0.35.5"
390
391
  },
391
392
  "peerDependencies": {
392
393
  "drizzle-orm": "^0.45.2",
@@ -25,7 +25,7 @@ import { registerSearch } from './commands/search.js';
25
25
  import { registerSnapshot } from './commands/snapshot.js';
26
26
  import { registerUpdate } from './commands/update.js';
27
27
 
28
- const VERSION = '2.1.5';
28
+ const VERSION = '2.2.1';
29
29
 
30
30
  const program = new Command();
31
31
  program.name('docsmint').description('CLI for the DocsMint knowledge workspace').version(VERSION);
@@ -695,6 +695,41 @@ export const pendingAttachmentUploads = pgTable(
695
695
  // DB-authoritative intents for object removal and quota release. Source rows
696
696
  // are deleted in the same transaction that inserts an intent; S3 and quota
697
697
  // effects happen only after commit and remain recoverable across crashes.
698
+ export const attachmentUploadOperations = pgTable(
699
+ "attachment_upload_operations",
700
+ {
701
+ id: uuid("id").primaryKey().defaultRandom(),
702
+ workspaceId: text("workspace_id").notNull(),
703
+ actorUserId: uuid("actor_user_id")
704
+ .notNull()
705
+ .references(() => users.id, { onDelete: "cascade" }),
706
+ documentId: uuid("document_id")
707
+ .notNull()
708
+ .references(() => documents.id, { onDelete: "cascade" }),
709
+ idempotencyKey: text("idempotency_key").notNull(),
710
+ requestFingerprint: text("request_fingerprint").notNull(),
711
+ sourceSha256: text("source_sha256").notNull(),
712
+ storageKey: text("storage_key").notNull(),
713
+ expiresAt: timestamp("expires_at").notNull(),
714
+ createdAt: timestamp("created_at").defaultNow().notNull(),
715
+ },
716
+ (table) => [
717
+ uniqueIndex("attachment_upload_operations_actor_document_key_unique").on(
718
+ table.workspaceId,
719
+ table.actorUserId,
720
+ table.documentId,
721
+ table.idempotencyKey,
722
+ ),
723
+ uniqueIndex("attachment_upload_operations_storage_key_unique").on(
724
+ table.storageKey,
725
+ ),
726
+ ],
727
+ );
728
+
729
+ // DB-authoritative intents for object removal and quota release. Source rows
730
+ // are deleted in the same transaction that inserts an intent; S3 and quota
731
+ // effects happen only after commit and remain recoverable across crashes.
732
+
698
733
  export const attachmentStorageCleanupOutbox = pgTable(
699
734
  "attachment_storage_cleanup_outbox",
700
735
  {
@@ -998,6 +1033,25 @@ export const documentCreateOperations = pgTable(
998
1033
  ],
999
1034
  );
1000
1035
 
1036
+ export const folderCreateOperations = pgTable(
1037
+ "folder_create_operations",
1038
+ {
1039
+ id: uuid("id").primaryKey().defaultRandom(),
1040
+ workspaceId: text("workspace_id").notNull(),
1041
+ actorUserId: uuid("actor_user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
1042
+ idempotencyKey: text("idempotency_key").notNull(),
1043
+ folderId: uuid("folder_id").notNull(),
1044
+ requestFingerprint: text("request_fingerprint").notNull(),
1045
+ createdAt: timestamp("created_at").defaultNow().notNull(),
1046
+ },
1047
+ (table) => [
1048
+ uniqueIndex("folder_create_operations_workspace_actor_key_unique").on(
1049
+ table.workspaceId, table.actorUserId, table.idempotencyKey,
1050
+ ),
1051
+ uniqueIndex("folder_create_operations_folder_idx").on(table.folderId),
1052
+ ],
1053
+ );
1054
+
1001
1055
  export const versionRelations = relations(versions, ({ one }) => ({
1002
1056
  document: one(documents, {
1003
1057
  fields: [versions.documentId],
package/server.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "id": "1249550690",
11
11
  "subfolder": "packages/mcp-server"
12
12
  },
13
- "version": "2.1.5",
13
+ "version": "2.2.1",
14
14
  "icons": [
15
15
  {
16
16
  "src": "https://raw.githubusercontent.com/HiAi-gg/docsmint/main/frontend/static/logo-dark.png",
@@ -34,7 +34,7 @@
34
34
  "registryType": "npm",
35
35
  "registryBaseUrl": "https://registry.npmjs.org",
36
36
  "identifier": "@hiai-gg/docsmint",
37
- "version": "2.1.5",
37
+ "version": "2.2.1",
38
38
  "runtimeHint": "npx",
39
39
  "transport": {
40
40
  "type": "stdio"
@@ -87,7 +87,7 @@
87
87
  "licenseFile": "https://github.com/HiAi-gg/docsmint/blob/main/LICENSE",
88
88
  "documentationUrl": "https://docsmint.com/mcp/connect?source=mcp_registry",
89
89
  "catalog": {
90
- "tools": 22,
90
+ "tools": 24,
91
91
  "prompts": 2,
92
92
  "resources": 3
93
93
  }
@@ -31,4 +31,11 @@ Use this skill when an agent must create, organize, edit, or research documents
31
31
  5. Use `create_snapshot` before a substantial rewrite; choose a version through `read_document(view=versions)` before `restore_document_version`.
32
32
  6. Treat `delete_document`, `restore_trashed_document`, and `permanently_delete_document` as distinct lifecycle actions. Purge only on an explicit request.
33
33
 
34
+ ## Image attachments
35
+
36
+ 1. Read the document with `read_document(view=detail)`. Check existing files with `check_document_attachments` before retrying a previous upload.
37
+ 2. Call `upload_document_image` with `documentId`, `filename`, `mimeType`, and `contentBase64`. The document requires edit access. Supply PNG, JPEG or WebP bytes up to 2 MiB, without a data URL prefix.
38
+ 3. Insert the returned `url` as a Markdown image with descriptive alt text via `save_document(action=update)`, preserving the existing content.
39
+ 4. Reread the document and use `check_document_attachments` with the returned `attachmentId` to confirm the bytes open with the current access.
40
+
34
41
  DocsMint owns chunking, embeddings, multilingual hybrid retrieval, cross-encoder rerank, entity extraction, and GraphRAG indexing. Agents must use the MCP tools and never write those persistence layers directly.