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 +2 -0
- package/build/index.js +70 -32
- package/package.json +1 -1
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
|
|
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
|
-
|
|
40883
|
-
|
|
40884
|
-
|
|
40885
|
-
|
|
40886
|
-
|
|
40887
|
-
|
|
40888
|
-
|
|
40889
|
-
|
|
40890
|
-
|
|
40891
|
-
|
|
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
|
|
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
|
|
40906
|
-
|
|
40907
|
-
|
|
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
|
|
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
|
-
|
|
40947
|
-
|
|
40948
|
-
|
|
40949
|
-
|
|
40950
|
-
|
|
40951
|
-
|
|
40952
|
-
|
|
40953
|
-
|
|
40954
|
-
|
|
40955
|
-
|
|
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
|
|
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
|
|
40971
|
-
|
|
40972
|
-
|
|
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