apple-notes-mcp 2.6.5 → 2.6.6

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
@@ -807,6 +807,8 @@ Lists attachments in a note.
807
807
 
808
808
  **Returns:** List of attachments with IDs, names, content identifiers, URLs when available, created/modified dates, and shared state.
809
809
 
810
+ **⚠️ Safety:** A lookup failure is reported as an error, never as an empty list — so an empty result reliably means the note has no attachments and is safe to replace wholesale. Treat an error as "unknown", not "none".
811
+
810
812
  ---
811
813
 
812
814
  #### `save-attachment`
package/build/index.js CHANGED
@@ -40865,7 +40865,9 @@ var AppleNotesManager = class {
40865
40865
  * Note: The position within the note cannot be determined via AppleScript.
40866
40866
  *
40867
40867
  * @param id - CoreData URL identifier for the note
40868
- * @returns Array of Attachment objects, or empty array if none found
40868
+ * @returns Array of Attachment objects, or empty array if the note genuinely has none
40869
+ * @throws If the AppleScript call fails, so a lookup failure is never mistaken for
40870
+ * an attachment-free note (callers gate destructive full-body updates on this)
40869
40871
  *
40870
40872
  * @example
40871
40873
  * ```typescript
@@ -40879,19 +40881,34 @@ var AppleNotesManager = class {
40879
40881
  tell application "Notes"
40880
40882
  set theNote to note id "${safeId}"
40881
40883
  set attachmentList to {}
40882
- repeat with a in attachments of theNote
40883
- set attachId to id of a
40884
- set attachName to name of a
40885
- set attachContentId to content identifier of a
40886
- set attachUrl to ""
40887
- try
40888
- set attachUrl to URL of a as text
40889
- end try
40890
- set createdDate to creation date of a
40891
- set modifiedDate to modification date of a
40884
+ set attachmentIds to id of every attachment of theNote
40885
+ set attachmentNames to name of every attachment of theNote
40886
+ set attachmentContentIds to content identifier of every attachment of theNote
40887
+ set attachmentUrls to URL of every attachment of theNote
40888
+ set attachmentCreatedDates to creation date of every attachment of theNote
40889
+ set attachmentModifiedDates to modification date of every attachment of theNote
40890
+ set attachmentSharedFlags to shared of every attachment of theNote
40891
+ set attachmentIdsAfter to id of every attachment of theNote
40892
+ if (count of attachmentNames) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40893
+ if (count of attachmentContentIds) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40894
+ if (count of attachmentUrls) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40895
+ if (count of attachmentCreatedDates) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40896
+ if (count of attachmentModifiedDates) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40897
+ if (count of attachmentSharedFlags) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40898
+ if (count of attachmentIdsAfter) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40899
+ repeat with i from 1 to count of attachmentIds
40900
+ if (item i of attachmentIdsAfter) is not (item i of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40901
+ end repeat
40902
+ repeat with i from 1 to count of attachmentIds
40903
+ set attachId to item i of attachmentIds
40904
+ set attachName to item i of attachmentNames
40905
+ set attachContentId to item i of attachmentContentIds
40906
+ set attachUrl to item i of attachmentUrls as text
40907
+ set createdDate to item i of attachmentCreatedDates
40908
+ set modifiedDate to item i of attachmentModifiedDates
40892
40909
  set createdParts to ${asDatePartsExpr("createdDate")}
40893
40910
  set modifiedParts to ${asDatePartsExpr("modifiedDate")}
40894
- set sharedFlag to shared of a as text
40911
+ set sharedFlag to item i of attachmentSharedFlags as text
40895
40912
  set end of attachmentList to attachId & ${AS_FIELD_SEP} & attachName & ${AS_FIELD_SEP} & attachContentId & ${AS_FIELD_SEP} & attachUrl & ${AS_FIELD_SEP} & createdParts & ${AS_FIELD_SEP} & modifiedParts & ${AS_FIELD_SEP} & sharedFlag
40896
40913
  end repeat
40897
40914
  set output to ""
@@ -40902,10 +40919,12 @@ var AppleNotesManager = class {
40902
40919
  end tell
40903
40920
  `;
40904
40921
  const result = executeAppleScript(script);
40905
- if (!result.success || !result.output) {
40906
- if (result.error) {
40907
- console.error(`Failed to list attachments for note ID "${id}":`, result.error);
40908
- }
40922
+ if (!result.success) {
40923
+ throw new Error(
40924
+ `Failed to list attachments for note ID "${id}": ${result.error ?? "unknown AppleScript error"}`
40925
+ );
40926
+ }
40927
+ if (!result.output) {
40909
40928
  return [];
40910
40929
  }
40911
40930
  const attachments = [];
@@ -40932,7 +40951,9 @@ var AppleNotesManager = class {
40932
40951
  *
40933
40952
  * @param title - Title of the note
40934
40953
  * @param account - Account containing the note (defaults to iCloud)
40935
- * @returns Array of Attachment objects, or empty array if none found
40954
+ * @returns Array of Attachment objects, or empty array if the note genuinely has none
40955
+ * @throws If the AppleScript call fails, so a lookup failure is never mistaken for
40956
+ * an attachment-free note (callers gate destructive full-body updates on this)
40936
40957
  */
40937
40958
  listAttachments(title, account) {
40938
40959
  const targetAccount = this.resolveAccount(account);
@@ -40943,19 +40964,34 @@ var AppleNotesManager = class {
40943
40964
  tell account "${safeAccount}"
40944
40965
  set theNote to note "${safeTitle}"
40945
40966
  set attachmentList to {}
40946
- repeat with a in attachments of theNote
40947
- set attachId to id of a
40948
- set attachName to name of a
40949
- set attachContentId to content identifier of a
40950
- set attachUrl to ""
40951
- try
40952
- set attachUrl to URL of a as text
40953
- end try
40954
- set createdDate to creation date of a
40955
- set modifiedDate to modification date of a
40967
+ set attachmentIds to id of every attachment of theNote
40968
+ set attachmentNames to name of every attachment of theNote
40969
+ set attachmentContentIds to content identifier of every attachment of theNote
40970
+ set attachmentUrls to URL of every attachment of theNote
40971
+ set attachmentCreatedDates to creation date of every attachment of theNote
40972
+ set attachmentModifiedDates to modification date of every attachment of theNote
40973
+ set attachmentSharedFlags to shared of every attachment of theNote
40974
+ set attachmentIdsAfter to id of every attachment of theNote
40975
+ if (count of attachmentNames) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40976
+ if (count of attachmentContentIds) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40977
+ if (count of attachmentUrls) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40978
+ if (count of attachmentCreatedDates) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40979
+ if (count of attachmentModifiedDates) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40980
+ if (count of attachmentSharedFlags) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40981
+ if (count of attachmentIdsAfter) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40982
+ repeat with i from 1 to count of attachmentIds
40983
+ if (item i of attachmentIdsAfter) is not (item i of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
40984
+ end repeat
40985
+ repeat with i from 1 to count of attachmentIds
40986
+ set attachId to item i of attachmentIds
40987
+ set attachName to item i of attachmentNames
40988
+ set attachContentId to item i of attachmentContentIds
40989
+ set attachUrl to item i of attachmentUrls as text
40990
+ set createdDate to item i of attachmentCreatedDates
40991
+ set modifiedDate to item i of attachmentModifiedDates
40956
40992
  set createdParts to ${asDatePartsExpr("createdDate")}
40957
40993
  set modifiedParts to ${asDatePartsExpr("modifiedDate")}
40958
- set sharedFlag to shared of a as text
40994
+ set sharedFlag to item i of attachmentSharedFlags as text
40959
40995
  set end of attachmentList to attachId & ${AS_FIELD_SEP} & attachName & ${AS_FIELD_SEP} & attachContentId & ${AS_FIELD_SEP} & attachUrl & ${AS_FIELD_SEP} & createdParts & ${AS_FIELD_SEP} & modifiedParts & ${AS_FIELD_SEP} & sharedFlag
40960
40996
  end repeat
40961
40997
  set output to ""
@@ -40967,10 +41003,12 @@ var AppleNotesManager = class {
40967
41003
  end tell
40968
41004
  `;
40969
41005
  const result = executeAppleScript(script);
40970
- if (!result.success || !result.output) {
40971
- if (result.error) {
40972
- console.error(`Failed to list attachments for note "${title}":`, result.error);
40973
- }
41006
+ if (!result.success) {
41007
+ throw new Error(
41008
+ `Failed to list attachments for note "${title}": ${result.error ?? "unknown AppleScript error"}`
41009
+ );
41010
+ }
41011
+ if (!result.output) {
40974
41012
  return [];
40975
41013
  }
40976
41014
  const attachments = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apple-notes-mcp",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
4
4
  "description": "MCP server for Apple Notes - create, search, update, and manage notes via Claude and other AI assistants",
5
5
  "type": "module",
6
6
  "main": "build/index.js",