suppa-mcp-2 1.1.1 → 1.1.2
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/dist/server.js +1 -1
- package/dist/store.js +127 -2
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -199,7 +199,7 @@ export function buildServer() {
|
|
|
199
199
|
// Reset so repeated buildServer() calls (e.g. in tests) do not double-count.
|
|
200
200
|
TOOL_NAMES.length = 0;
|
|
201
201
|
PROMPT_NAMES.length = 0;
|
|
202
|
-
const server = new McpServer({ name: "suppa-2.0", version: "1.1.
|
|
202
|
+
const server = new McpServer({ name: "suppa-2.0", version: "1.1.2" }, { instructions: INSTRUCTIONS });
|
|
203
203
|
const reg = (name, cfg, handler) => {
|
|
204
204
|
server.registerTool(name, {
|
|
205
205
|
description: cfg.description,
|
package/dist/store.js
CHANGED
|
@@ -17,9 +17,71 @@
|
|
|
17
17
|
* `refresh_exp`). This matches the Python server's on-disk format exactly, so an
|
|
18
18
|
* entry written by either server loads in the other. The camelCase `Credentials`
|
|
19
19
|
* shape is a boundary-only convenience.
|
|
20
|
+
*
|
|
21
|
+
* WINDOWS BLOB LIMIT + CHUNKING: Windows Credential Manager caps a credential
|
|
22
|
+
* blob at 2560 bytes (`CRED_MAX_CREDENTIAL_BLOB_SIZE`; `@napi-rs/keyring` stores
|
|
23
|
+
* the secret as UTF-16, so ~1280 ASCII chars). Some tenants' Google tokens are
|
|
24
|
+
* far larger than that, so the single-blob write throws. When it does, we fall
|
|
25
|
+
* back to CHUNKED storage: the tokens are split across sibling keychain entries
|
|
26
|
+
* (`<host>#suppa-chunk#<i>`) and the main `<host>` entry holds a small manifest
|
|
27
|
+
* `{"__suppa_chunks__": N}`. Reads/deletes detect the manifest and reassemble.
|
|
28
|
+
* The single-blob format is still used whenever it fits (the common case), so
|
|
29
|
+
* normal-size tenants stay byte-compatible with the Python server. Chunked
|
|
30
|
+
* entries are Node-only (Python would hit the same Windows limit anyway).
|
|
20
31
|
*/
|
|
21
32
|
import { Entry } from "@napi-rs/keyring";
|
|
22
33
|
export const SERVICE = "suppa-mcp";
|
|
34
|
+
/**
|
|
35
|
+
* Conservative per-chunk size in characters. Windows' limit is 2560 bytes of
|
|
36
|
+
* UTF-16 (= 1280 BMP chars); 1000 chars → ~2000 bytes leaves comfortable margin
|
|
37
|
+
* for surrogate pairs and backend overhead.
|
|
38
|
+
*/
|
|
39
|
+
const CHUNK_CHARS = 1000;
|
|
40
|
+
/** Keychain account name holding chunk `i` of `host`'s credential blob. */
|
|
41
|
+
function chunkAccount(host, i) {
|
|
42
|
+
return `${host}#suppa-chunk#${i}`;
|
|
43
|
+
}
|
|
44
|
+
/** True iff a thrown keychain error is the platform blob-size-limit rejection. */
|
|
45
|
+
function isBlobSizeError(err) {
|
|
46
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
47
|
+
return /platform limit|too long|longer than|blob|size/i.test(msg);
|
|
48
|
+
}
|
|
49
|
+
/** Split `s` into <=CHUNK_CHARS pieces. */
|
|
50
|
+
function splitChunks(s) {
|
|
51
|
+
const out = [];
|
|
52
|
+
for (let i = 0; i < s.length; i += CHUNK_CHARS) {
|
|
53
|
+
out.push(s.slice(i, i + CHUNK_CHARS));
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Delete any chunk entries belonging to `host`. Best-effort: reads the manifest
|
|
59
|
+
* to learn the count, then falls back to probing until a chunk is absent (so
|
|
60
|
+
* orphans from an interrupted write are still cleaned up).
|
|
61
|
+
*/
|
|
62
|
+
function clearChunks(host, knownCount) {
|
|
63
|
+
const upTo = knownCount ?? 256; // hard cap; a real token needs a handful
|
|
64
|
+
for (let i = 0; i < upTo; i++) {
|
|
65
|
+
const e = entryFor(chunkAccount(host, i));
|
|
66
|
+
if (e === null)
|
|
67
|
+
break;
|
|
68
|
+
let had = false;
|
|
69
|
+
try {
|
|
70
|
+
had = e.getPassword() !== null;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
had = false;
|
|
74
|
+
}
|
|
75
|
+
if (!had && knownCount === undefined)
|
|
76
|
+
break; // no more chunks
|
|
77
|
+
try {
|
|
78
|
+
e.deletePassword();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
/* ignore */
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
23
85
|
/**
|
|
24
86
|
* Return a keychain `Entry` for `host`, or `null` if the backend cannot load.
|
|
25
87
|
*
|
|
@@ -61,7 +123,35 @@ export function load(host) {
|
|
|
61
123
|
return null;
|
|
62
124
|
}
|
|
63
125
|
try {
|
|
64
|
-
const
|
|
126
|
+
const parsed = JSON.parse(raw);
|
|
127
|
+
// Chunked entry: main blob is a manifest; reassemble from chunk entries.
|
|
128
|
+
const manifest = parsed;
|
|
129
|
+
if (typeof manifest.__suppa_chunks__ === "number") {
|
|
130
|
+
const n = manifest.__suppa_chunks__;
|
|
131
|
+
let assembled = "";
|
|
132
|
+
for (let i = 0; i < n; i++) {
|
|
133
|
+
const e = entryFor(chunkAccount(host, i));
|
|
134
|
+
let piece = null;
|
|
135
|
+
try {
|
|
136
|
+
piece = e ? e.getPassword() : null;
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
piece = null;
|
|
140
|
+
}
|
|
141
|
+
if (piece === null) {
|
|
142
|
+
return null; // a chunk is missing → corrupt, treat as absent
|
|
143
|
+
}
|
|
144
|
+
assembled += piece;
|
|
145
|
+
}
|
|
146
|
+
const data = JSON.parse(assembled);
|
|
147
|
+
return {
|
|
148
|
+
accessToken: typeof data.access_token === "string" ? data.access_token : "",
|
|
149
|
+
refreshToken: typeof data.refresh_token === "string" ? data.refresh_token : "",
|
|
150
|
+
accessExp: typeof data.access_exp === "number" ? data.access_exp : 0,
|
|
151
|
+
refreshExp: typeof data.refresh_exp === "number" ? data.refresh_exp : 0,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const data = parsed;
|
|
65
155
|
// Keep only known keys, defaulting missing ones (tolerate a partial blob).
|
|
66
156
|
return {
|
|
67
157
|
accessToken: typeof data.access_token === "string" ? data.access_token : "",
|
|
@@ -87,7 +177,32 @@ export function save(host, creds) {
|
|
|
87
177
|
access_exp: creds.accessExp,
|
|
88
178
|
refresh_exp: creds.refreshExp,
|
|
89
179
|
};
|
|
90
|
-
|
|
180
|
+
const blob = JSON.stringify(stored);
|
|
181
|
+
// Fast path: single blob (byte-compatible with the Python server). Only when
|
|
182
|
+
// the backend rejects it for size do we fall back to chunked storage. This
|
|
183
|
+
// keeps normal-size tenants interoperable and unchanged on every platform.
|
|
184
|
+
try {
|
|
185
|
+
entry.setPassword(blob);
|
|
186
|
+
// Success — make sure no stale chunks linger from a prior chunked write.
|
|
187
|
+
clearChunks(host);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
if (!isBlobSizeError(err)) {
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Chunked path: split the blob across sibling entries, then write a manifest.
|
|
196
|
+
const chunks = splitChunks(blob);
|
|
197
|
+
clearChunks(host); // remove any previous chunk set first
|
|
198
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
199
|
+
const e = entryFor(chunkAccount(host, i));
|
|
200
|
+
if (e === null) {
|
|
201
|
+
throw new Error("No OS keychain backend available for chunked write.");
|
|
202
|
+
}
|
|
203
|
+
e.setPassword(chunks[i]);
|
|
204
|
+
}
|
|
205
|
+
entry.setPassword(JSON.stringify({ __suppa_chunks__: chunks.length }));
|
|
91
206
|
}
|
|
92
207
|
/**
|
|
93
208
|
* Delete stored credentials for `host`. Returns `true` iff something was
|
|
@@ -111,6 +226,16 @@ export function del(host) {
|
|
|
111
226
|
if (raw === null) {
|
|
112
227
|
return false;
|
|
113
228
|
}
|
|
229
|
+
// If this is a chunked entry, remove its chunk siblings too.
|
|
230
|
+
try {
|
|
231
|
+
const manifest = JSON.parse(raw);
|
|
232
|
+
if (typeof manifest.__suppa_chunks__ === "number") {
|
|
233
|
+
clearChunks(host, manifest.__suppa_chunks__);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
/* not a manifest — plain blob, nothing extra to clean */
|
|
238
|
+
}
|
|
114
239
|
// deletePassword returns whether an entry was removed.
|
|
115
240
|
return entry.deletePassword();
|
|
116
241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "suppa-mcp": "dist/bin.js" },
|