@lostgradient/mcp 0.2.4 → 0.2.5
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/http/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
createMcpServer,
|
|
7
7
|
hasValidLocalhostRebindingHeaders,
|
|
8
8
|
isLoopbackHostname
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-qxwd8est.js";
|
|
10
10
|
import"../chunk-taxyscge.js";
|
|
11
|
-
import"../chunk-
|
|
11
|
+
import"../chunk-wsnfttyg.js";
|
|
12
12
|
import {
|
|
13
13
|
resolveOauthNetworkIdentity
|
|
14
14
|
} from "../chunk-en76akaq.js";
|
|
@@ -307,22 +307,54 @@ var maximumRetryDelayMilliseconds2 = 30000;
|
|
|
307
307
|
function channelForUser(userId) {
|
|
308
308
|
return `mcp:events:user:${userId}`;
|
|
309
309
|
}
|
|
310
|
+
|
|
311
|
+
class ServerEventDecodeError extends Error {
|
|
312
|
+
constructor() {
|
|
313
|
+
super("Invalid MCP server event message.");
|
|
314
|
+
this.name = "ServerEventDecodeError";
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function isObjectRecord(value) {
|
|
318
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
319
|
+
}
|
|
320
|
+
function decodeServerEvent(value) {
|
|
321
|
+
if (!isObjectRecord(value))
|
|
322
|
+
throw new ServerEventDecodeError;
|
|
323
|
+
switch (value.kind) {
|
|
324
|
+
case "tools_list_changed":
|
|
325
|
+
case "prompts_list_changed":
|
|
326
|
+
case "resources_list_changed":
|
|
327
|
+
return { kind: value.kind };
|
|
328
|
+
case "resource_updated":
|
|
329
|
+
if (typeof value.uri !== "string")
|
|
330
|
+
throw new ServerEventDecodeError;
|
|
331
|
+
return { kind: value.kind, uri: value.uri };
|
|
332
|
+
default:
|
|
333
|
+
throw new ServerEventDecodeError;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function parseServerEventMessage(message) {
|
|
337
|
+
try {
|
|
338
|
+
return JSON.parse(message);
|
|
339
|
+
} catch {
|
|
340
|
+
throw new ServerEventDecodeError;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
310
343
|
function readServerEvent(message) {
|
|
311
|
-
const parsed =
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return
|
|
344
|
+
const parsed = parseServerEventMessage(message);
|
|
345
|
+
if (!isObjectRecord(parsed))
|
|
346
|
+
throw new ServerEventDecodeError;
|
|
347
|
+
if ("event" in parsed) {
|
|
348
|
+
if (typeof parsed.sourceId !== "string")
|
|
349
|
+
throw new ServerEventDecodeError;
|
|
350
|
+
return {
|
|
351
|
+
event: decodeServerEvent(parsed.event),
|
|
352
|
+
sourceId: parsed.sourceId
|
|
353
|
+
};
|
|
318
354
|
}
|
|
319
|
-
if (typeof envelope.kind !== "string")
|
|
320
|
-
return;
|
|
321
|
-
const event = { ...parsed };
|
|
322
|
-
delete event.sourceId;
|
|
323
355
|
return {
|
|
324
|
-
event,
|
|
325
|
-
sourceId: typeof
|
|
356
|
+
event: decodeServerEvent(parsed),
|
|
357
|
+
sourceId: typeof parsed.sourceId === "string" ? parsed.sourceId : undefined
|
|
326
358
|
};
|
|
327
359
|
}
|
|
328
360
|
|
package/dist/index.js
CHANGED
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
readRequestSender,
|
|
12
12
|
readSessionIdentifier,
|
|
13
13
|
stringifyUnknown
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-qxwd8est.js";
|
|
15
15
|
import {
|
|
16
16
|
metricsCollector
|
|
17
17
|
} from "./chunk-taxyscge.js";
|
|
18
18
|
import {
|
|
19
19
|
PACKAGE_VERSION
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-wsnfttyg.js";
|
|
21
21
|
import {
|
|
22
22
|
getSupportedScopes,
|
|
23
23
|
hasRegisteredUiExtensionResource
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lostgradient/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A Model Context Protocol server engine: registries, scope vocabularies, and an OAuth-ready request boundary.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Steve Kinney <hello@stevekinney.net>",
|