apple-notes-mcp 2.9.30 → 2.9.31
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 +21 -1
- package/build/index.js +80 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -198,6 +198,24 @@ The server is a standard MCP server over stdio, so any client that can launch a
|
|
|
198
198
|
|
|
199
199
|
Read/list/get tools also return **structured JSON** (`structuredContent`) alongside the text, so agents can consume results without parsing prose.
|
|
200
200
|
|
|
201
|
+
Some clients (Claude Desktop among them) pass the model only a result's text
|
|
202
|
+
and drop `structuredContent`. So every result that has `structuredContent` also
|
|
203
|
+
ends with one more text block holding the same data as a single JSON line:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
structuredContent: {"id":"x-coredata://…/ICNote/p123","contentHash":"sha256:…","writable":true,…}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
That line carries every token a follow-up call needs: the `contentHash`
|
|
210
|
+
revision token for `expectedContentHash`, new ids, `nativeTags`, `writable`,
|
|
211
|
+
`page.nextOffset`, and an error's `code`, `committed` and `indeterminate`. A
|
|
212
|
+
long value the text above already shows in full, such as the body from
|
|
213
|
+
`get-note-content`, appears as `"[shown in full above]"` instead of twice. If
|
|
214
|
+
the line would still exceed 16 KB, fields larger than 1 KB (usually a list
|
|
215
|
+
already printed above) are left out and named in `_omitted`. Tools whose text
|
|
216
|
+
already is that JSON get no extra block. `structuredContent` itself is
|
|
217
|
+
unchanged.
|
|
218
|
+
|
|
201
219
|
### MCP resources & prompts
|
|
202
220
|
|
|
203
221
|
Resources expose read-only context the client can attach without a tool call:
|
|
@@ -238,7 +256,9 @@ When Full Disk Access is granted, list and read tools also return stable identif
|
|
|
238
256
|
### Error results
|
|
239
257
|
|
|
240
258
|
A failed call returns `isError: true` with the same human-readable text as
|
|
241
|
-
before, plus `structuredContent` carrying a stable machine-readable `code
|
|
259
|
+
before, plus `structuredContent` carrying a stable machine-readable `code`
|
|
260
|
+
(also repeated in the trailing `structuredContent:` text line, for clients
|
|
261
|
+
that drop `structuredContent`).
|
|
242
262
|
Branch on `code`, not on the prose, which may be reworded.
|
|
243
263
|
|
|
244
264
|
| `code` | Meaning |
|
package/build/index.js
CHANGED
|
@@ -53486,6 +53486,85 @@ function exportWithTemplate(request, deps, chosen, notes, skipped, { output, ass
|
|
|
53486
53486
|
return { ...receipt, markdown };
|
|
53487
53487
|
}
|
|
53488
53488
|
|
|
53489
|
+
// src/utils/structuredText.ts
|
|
53490
|
+
import { isDeepStrictEqual } from "node:util";
|
|
53491
|
+
var STRUCTURED_TEXT_PREFIX = "structuredContent: ";
|
|
53492
|
+
var SHOWN_ABOVE = "[shown in full above]";
|
|
53493
|
+
var MIN_ELIDED_CHARS = 64;
|
|
53494
|
+
var MAX_MIRROR_CHARS = 16384;
|
|
53495
|
+
var MAX_FIELD_CHARS = 1024;
|
|
53496
|
+
function textOf(content) {
|
|
53497
|
+
return content.map(
|
|
53498
|
+
(item) => item && typeof item === "object" && item.type === "text" ? String(item.text ?? "") : ""
|
|
53499
|
+
).join("\n");
|
|
53500
|
+
}
|
|
53501
|
+
function elide(value, text2) {
|
|
53502
|
+
if (typeof value === "string") {
|
|
53503
|
+
return value.length >= MIN_ELIDED_CHARS && text2.includes(value) ? SHOWN_ABOVE : value;
|
|
53504
|
+
}
|
|
53505
|
+
if (Array.isArray(value)) return value.map((item) => elide(item, text2));
|
|
53506
|
+
if (value && typeof value === "object") {
|
|
53507
|
+
const out = {};
|
|
53508
|
+
for (const [key, item] of Object.entries(value)) {
|
|
53509
|
+
if (item !== void 0) out[key] = elide(item, text2);
|
|
53510
|
+
}
|
|
53511
|
+
return out;
|
|
53512
|
+
}
|
|
53513
|
+
return value;
|
|
53514
|
+
}
|
|
53515
|
+
function textIsTheJson(content, structured) {
|
|
53516
|
+
const plain = JSON.parse(JSON.stringify(structured));
|
|
53517
|
+
return content.some((item) => {
|
|
53518
|
+
const text2 = item?.text;
|
|
53519
|
+
if (item?.type !== "text" || typeof text2 !== "string") return false;
|
|
53520
|
+
const trimmed = text2.trim();
|
|
53521
|
+
if (!trimmed.startsWith("{")) return false;
|
|
53522
|
+
try {
|
|
53523
|
+
return isDeepStrictEqual(JSON.parse(trimmed), plain);
|
|
53524
|
+
} catch {
|
|
53525
|
+
return false;
|
|
53526
|
+
}
|
|
53527
|
+
});
|
|
53528
|
+
}
|
|
53529
|
+
function structuredTextLine(structured, text2) {
|
|
53530
|
+
const elided = elide(structured, text2);
|
|
53531
|
+
let json2 = JSON.stringify(elided);
|
|
53532
|
+
if (json2.length > MAX_MIRROR_CHARS) {
|
|
53533
|
+
const kept = {};
|
|
53534
|
+
const omitted = [];
|
|
53535
|
+
for (const [key, value] of Object.entries(elided)) {
|
|
53536
|
+
if (JSON.stringify(value).length > MAX_FIELD_CHARS) omitted.push(key);
|
|
53537
|
+
else kept[key] = value;
|
|
53538
|
+
}
|
|
53539
|
+
json2 = JSON.stringify({ ...kept, _omitted: omitted });
|
|
53540
|
+
}
|
|
53541
|
+
return STRUCTURED_TEXT_PREFIX + json2;
|
|
53542
|
+
}
|
|
53543
|
+
function withStructuredText(result) {
|
|
53544
|
+
const r = result;
|
|
53545
|
+
if (!r || typeof r !== "object") return result;
|
|
53546
|
+
const structured = r.structuredContent;
|
|
53547
|
+
if (!structured || typeof structured !== "object" || Array.isArray(structured)) return result;
|
|
53548
|
+
const content = Array.isArray(r.content) ? r.content : [];
|
|
53549
|
+
if (textIsTheJson(content, structured)) return result;
|
|
53550
|
+
const line = structuredTextLine(structured, textOf(content));
|
|
53551
|
+
return { ...r, content: [...content, { type: "text", text: line }] };
|
|
53552
|
+
}
|
|
53553
|
+
function installStructuredText(server2) {
|
|
53554
|
+
const target = server2;
|
|
53555
|
+
const register = target.registerTool;
|
|
53556
|
+
if (typeof register === "function") {
|
|
53557
|
+
target.registerTool = function(name, config2, cb) {
|
|
53558
|
+
const wrapped = typeof cb === "function" ? async (...args) => withStructuredText(await cb(...args)) : cb;
|
|
53559
|
+
return register.call(this, name, config2, wrapped);
|
|
53560
|
+
};
|
|
53561
|
+
}
|
|
53562
|
+
const createError = target.createToolError;
|
|
53563
|
+
if (typeof createError === "function") {
|
|
53564
|
+
target.createToolError = (message) => withStructuredText(createError.call(target, message));
|
|
53565
|
+
}
|
|
53566
|
+
}
|
|
53567
|
+
|
|
53489
53568
|
// src/tools/directOperations.ts
|
|
53490
53569
|
import { createHash as createHash3 } from "node:crypto";
|
|
53491
53570
|
import {
|
|
@@ -59303,6 +59382,7 @@ var server = new McpServer({
|
|
|
59303
59382
|
description: "MCP server for managing Apple Notes - create, search, update, and organize notes"
|
|
59304
59383
|
});
|
|
59305
59384
|
installSdkErrorCodes(server);
|
|
59385
|
+
installStructuredText(server);
|
|
59306
59386
|
var notesManager = new AppleNotesManager();
|
|
59307
59387
|
registerDirectOperations(server, notesManager);
|
|
59308
59388
|
registerFolderDelete(server, notesManager);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apple-notes-mcp",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.31",
|
|
4
4
|
"description": "MCP server for Apple Notes - read, search, create, edit, organize, and export notes on macOS via Claude and other AI assistants",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|