apple-notes-mcp 2.6.5 → 2.6.7
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 +89 -48
- 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
|
@@ -40622,12 +40622,9 @@ var AppleNotesManager = class {
|
|
|
40622
40622
|
tell application "Notes"
|
|
40623
40623
|
set theNote to note id "${safeNoteId}"
|
|
40624
40624
|
set theAttachment to missing value
|
|
40625
|
-
|
|
40626
|
-
|
|
40627
|
-
|
|
40628
|
-
exit repeat
|
|
40629
|
-
end if
|
|
40630
|
-
end repeat
|
|
40625
|
+
try
|
|
40626
|
+
set theAttachment to attachment id "${safeAttId}" of theNote
|
|
40627
|
+
end try
|
|
40631
40628
|
if theAttachment is missing value then
|
|
40632
40629
|
return "ERR" & ${AS_FIELD_SEP} & "attachment not found"
|
|
40633
40630
|
end if
|
|
@@ -40865,7 +40862,9 @@ var AppleNotesManager = class {
|
|
|
40865
40862
|
* Note: The position within the note cannot be determined via AppleScript.
|
|
40866
40863
|
*
|
|
40867
40864
|
* @param id - CoreData URL identifier for the note
|
|
40868
|
-
* @returns Array of Attachment objects, or empty array if none
|
|
40865
|
+
* @returns Array of Attachment objects, or empty array if the note genuinely has none
|
|
40866
|
+
* @throws If the AppleScript call fails, so a lookup failure is never mistaken for
|
|
40867
|
+
* an attachment-free note (callers gate destructive full-body updates on this)
|
|
40869
40868
|
*
|
|
40870
40869
|
* @example
|
|
40871
40870
|
* ```typescript
|
|
@@ -40879,19 +40878,34 @@ var AppleNotesManager = class {
|
|
|
40879
40878
|
tell application "Notes"
|
|
40880
40879
|
set theNote to note id "${safeId}"
|
|
40881
40880
|
set attachmentList to {}
|
|
40882
|
-
|
|
40883
|
-
|
|
40884
|
-
|
|
40885
|
-
|
|
40886
|
-
|
|
40887
|
-
|
|
40888
|
-
|
|
40889
|
-
|
|
40890
|
-
|
|
40891
|
-
|
|
40881
|
+
set attachmentIds to id of every attachment of theNote
|
|
40882
|
+
set attachmentNames to name of every attachment of theNote
|
|
40883
|
+
set attachmentContentIds to content identifier of every attachment of theNote
|
|
40884
|
+
set attachmentUrls to URL of every attachment of theNote
|
|
40885
|
+
set attachmentCreatedDates to creation date of every attachment of theNote
|
|
40886
|
+
set attachmentModifiedDates to modification date of every attachment of theNote
|
|
40887
|
+
set attachmentSharedFlags to shared of every attachment of theNote
|
|
40888
|
+
set attachmentIdsAfter to id of every attachment of theNote
|
|
40889
|
+
if (count of attachmentNames) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40890
|
+
if (count of attachmentContentIds) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40891
|
+
if (count of attachmentUrls) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40892
|
+
if (count of attachmentCreatedDates) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40893
|
+
if (count of attachmentModifiedDates) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40894
|
+
if (count of attachmentSharedFlags) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40895
|
+
if (count of attachmentIdsAfter) is not (count of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40896
|
+
repeat with i from 1 to count of attachmentIds
|
|
40897
|
+
if (item i of attachmentIdsAfter) is not (item i of attachmentIds) then error "${BULK_LIST_MUTATION_ERROR}"
|
|
40898
|
+
end repeat
|
|
40899
|
+
repeat with i from 1 to count of attachmentIds
|
|
40900
|
+
set attachId to item i of attachmentIds
|
|
40901
|
+
set attachName to item i of attachmentNames
|
|
40902
|
+
set attachContentId to item i of attachmentContentIds
|
|
40903
|
+
set attachUrl to item i of attachmentUrls as text
|
|
40904
|
+
set createdDate to item i of attachmentCreatedDates
|
|
40905
|
+
set modifiedDate to item i of attachmentModifiedDates
|
|
40892
40906
|
set createdParts to ${asDatePartsExpr("createdDate")}
|
|
40893
40907
|
set modifiedParts to ${asDatePartsExpr("modifiedDate")}
|
|
40894
|
-
set sharedFlag to
|
|
40908
|
+
set sharedFlag to item i of attachmentSharedFlags as text
|
|
40895
40909
|
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
40910
|
end repeat
|
|
40897
40911
|
set output to ""
|
|
@@ -40902,10 +40916,12 @@ var AppleNotesManager = class {
|
|
|
40902
40916
|
end tell
|
|
40903
40917
|
`;
|
|
40904
40918
|
const result = executeAppleScript(script);
|
|
40905
|
-
if (!result.success
|
|
40906
|
-
|
|
40907
|
-
|
|
40908
|
-
|
|
40919
|
+
if (!result.success) {
|
|
40920
|
+
throw new Error(
|
|
40921
|
+
`Failed to list attachments for note ID "${id}": ${result.error ?? "unknown AppleScript error"}`
|
|
40922
|
+
);
|
|
40923
|
+
}
|
|
40924
|
+
if (!result.output) {
|
|
40909
40925
|
return [];
|
|
40910
40926
|
}
|
|
40911
40927
|
const attachments = [];
|
|
@@ -40915,7 +40931,10 @@ var AppleNotesManager = class {
|
|
|
40915
40931
|
if (parts.length >= 3) {
|
|
40916
40932
|
attachments.push({
|
|
40917
40933
|
id: parts[0].trim(),
|
|
40918
|
-
name
|
|
40934
|
+
// Unnamed attachments render `name` as the AppleScript sentinel; surfacing
|
|
40935
|
+
// the literal "missing value" as a filename is worse than saying nothing,
|
|
40936
|
+
// and `name` is a required string, so fall back to the content identifier.
|
|
40937
|
+
name: normalizeAppleScriptText(parts[1]) ?? normalizeAppleScriptText(parts[2]) ?? "",
|
|
40919
40938
|
contentType: parts[2].trim(),
|
|
40920
40939
|
contentId: parts[2].trim() || void 0,
|
|
40921
40940
|
url: normalizeAppleScriptText(parts[3]),
|
|
@@ -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 = [];
|
|
@@ -40980,7 +41018,10 @@ var AppleNotesManager = class {
|
|
|
40980
41018
|
if (parts.length >= 3) {
|
|
40981
41019
|
attachments.push({
|
|
40982
41020
|
id: parts[0].trim(),
|
|
40983
|
-
name
|
|
41021
|
+
// Unnamed attachments render `name` as the AppleScript sentinel; surfacing
|
|
41022
|
+
// the literal "missing value" as a filename is worse than saying nothing,
|
|
41023
|
+
// and `name` is a required string, so fall back to the content identifier.
|
|
41024
|
+
name: normalizeAppleScriptText(parts[1]) ?? normalizeAppleScriptText(parts[2]) ?? "",
|
|
40984
41025
|
contentType: parts[2].trim(),
|
|
40985
41026
|
contentId: parts[2].trim() || void 0,
|
|
40986
41027
|
url: normalizeAppleScriptText(parts[3]),
|
|
@@ -41016,12 +41057,9 @@ var AppleNotesManager = class {
|
|
|
41016
41057
|
tell application "Notes"
|
|
41017
41058
|
set theNote to note id "${safeNoteId}"
|
|
41018
41059
|
set theAttachment to missing value
|
|
41019
|
-
|
|
41020
|
-
|
|
41021
|
-
|
|
41022
|
-
exit repeat
|
|
41023
|
-
end if
|
|
41024
|
-
end repeat
|
|
41060
|
+
try
|
|
41061
|
+
set theAttachment to attachment id "${safeAttId}" of theNote
|
|
41062
|
+
end try
|
|
41025
41063
|
if theAttachment is missing value then
|
|
41026
41064
|
return "ERR" & ${AS_FIELD_SEP} & "attachment not found"
|
|
41027
41065
|
end if
|
|
@@ -41061,8 +41099,11 @@ var AppleNotesManager = class {
|
|
|
41061
41099
|
return {
|
|
41062
41100
|
success: true,
|
|
41063
41101
|
savedPath: abs,
|
|
41064
|
-
|
|
41065
|
-
|
|
41102
|
+
// Unnamed attachments render as the AppleScript sentinel here too; leaving it
|
|
41103
|
+
// undefined lets save-attachment/fetch-attachment fall back to "attachment"
|
|
41104
|
+
// rather than reporting `Saved "missing value"`.
|
|
41105
|
+
name: normalizeAppleScriptText(parts[1]),
|
|
41106
|
+
contentType: normalizeAppleScriptText(parts[2])
|
|
41066
41107
|
};
|
|
41067
41108
|
}
|
|
41068
41109
|
/**
|
package/package.json
CHANGED