@agentcomms/events-daemon 0.16.0 → 0.18.0
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 +138 -11
- package/THIRD_PARTY_LICENSES +2 -2
- package/dist/{b3-contract-03AO67VB.mjs → b3-contract-B6UBBK7F.mjs} +306 -55
- package/dist/cli.mjs +5083 -1385
- package/dist/index.d.mts +192 -35
- package/dist/index.mjs +1 -1
- package/dist/{mcp-DXXb3Vv3-B0sHZfig.mjs → mcp-DIH4cS6P-YuKZfqTg.mjs} +181 -68
- package/dist/records-DjE5a4_H.mjs +2 -0
- package/dist/{records-3rGS8spn.mjs → records-DsUxYBwb.mjs} +2 -2
- package/dist/{stdio-CD7QQBAh.mjs → stdio-Dp1EE6ok.mjs} +28 -3
- package/dist/{webhook-target-BkA_wHIu.mjs → webhook-target-DyDTwWhV.mjs} +38 -27
- package/package.json +11 -11
- package/dist/records-DojbuTaG.mjs +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process$1 from "node:process";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.3.1/node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -31,7 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
enumerable: true
|
|
32
32
|
}) : target, mod));
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.
|
|
34
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.3.1/node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs
|
|
35
35
|
/**
|
|
36
36
|
* Canonical `$schema` URIs per supported dialect (http + https variants, trailing-`#` stripped).
|
|
37
37
|
*/
|
|
@@ -7465,7 +7465,8 @@ const OAuthMetadataSchema = looseObject({
|
|
|
7465
7465
|
introspection_endpoint_auth_signing_alg_values_supported: array(string()).optional(),
|
|
7466
7466
|
code_challenge_methods_supported: array(string()).optional(),
|
|
7467
7467
|
client_id_metadata_document_supported: boolean().optional(),
|
|
7468
|
-
authorization_response_iss_parameter_supported: boolean().optional().catch(void 0)
|
|
7468
|
+
authorization_response_iss_parameter_supported: boolean().optional().catch(void 0),
|
|
7469
|
+
dpop_signing_alg_values_supported: array(string()).optional()
|
|
7469
7470
|
});
|
|
7470
7471
|
/**
|
|
7471
7472
|
* OpenID Connect Discovery 1.0 Provider Metadata
|
|
@@ -7529,7 +7530,8 @@ const OAuthTokensSchema = object({
|
|
|
7529
7530
|
token_type: string(),
|
|
7530
7531
|
expires_in: number().optional(),
|
|
7531
7532
|
scope: string().optional(),
|
|
7532
|
-
refresh_token: string().optional()
|
|
7533
|
+
refresh_token: string().optional(),
|
|
7534
|
+
issuer: string().optional().catch(void 0)
|
|
7533
7535
|
}).strip();
|
|
7534
7536
|
/**
|
|
7535
7537
|
* RFC 8693 §2.2.1 Token Exchange response for ID-JAG tokens.
|
|
@@ -7586,7 +7588,8 @@ const OAuthClientInformationSchema = object({
|
|
|
7586
7588
|
client_id: string(),
|
|
7587
7589
|
client_secret: string().optional(),
|
|
7588
7590
|
client_id_issued_at: number$1().optional(),
|
|
7589
|
-
client_secret_expires_at: number$1().optional()
|
|
7591
|
+
client_secret_expires_at: number$1().optional(),
|
|
7592
|
+
issuer: string().optional().catch(void 0)
|
|
7590
7593
|
}).strip();
|
|
7591
7594
|
/**
|
|
7592
7595
|
* RFC 7591 OAuth 2.0 Dynamic Client Registration full response (client information plus metadata)
|
|
@@ -7607,7 +7610,7 @@ const OAuthTokenRevocationRequestSchema = object({
|
|
|
7607
7610
|
token_type_hint: string().optional()
|
|
7608
7611
|
}).strip();
|
|
7609
7612
|
//#endregion
|
|
7610
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.
|
|
7613
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.3.1/node_modules/@modelcontextprotocol/server/dist/src-Cqbh3MYc.mjs
|
|
7611
7614
|
/**
|
|
7612
7615
|
* Cross-bundle `instanceof` support for the SDK error classes.
|
|
7613
7616
|
*
|
|
@@ -7872,8 +7875,18 @@ var SdkError = class extends Error {
|
|
|
7872
7875
|
if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
|
|
7873
7876
|
return brandedHasInstance(this, value);
|
|
7874
7877
|
}
|
|
7875
|
-
|
|
7876
|
-
|
|
7878
|
+
/**
|
|
7879
|
+
* @param code - Stable string code identifying the failure ({@linkcode SdkErrorCode}).
|
|
7880
|
+
* @param message - Human-readable description.
|
|
7881
|
+
* @param data - Optional structured payload (for example the HTTP status carried by
|
|
7882
|
+
* {@linkcode SdkHttpError}). Opaque to the SDK: a `cause` key inside `data` is not
|
|
7883
|
+
* promoted to `Error.cause`.
|
|
7884
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error`. Pass the underlying
|
|
7885
|
+
* failure as `{ cause }` so it is reachable through the `Error.cause` chain that
|
|
7886
|
+
* loggers and error trackers walk.
|
|
7887
|
+
*/
|
|
7888
|
+
constructor(code, message, data, options) {
|
|
7889
|
+
super(message, options);
|
|
7877
7890
|
this.code = code;
|
|
7878
7891
|
this.data = data;
|
|
7879
7892
|
this.name = "SdkError";
|
|
@@ -7900,8 +7913,11 @@ var SdkHttpError = class extends SdkError {
|
|
|
7900
7913
|
static {
|
|
7901
7914
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
|
|
7902
7915
|
}
|
|
7903
|
-
|
|
7904
|
-
|
|
7916
|
+
/**
|
|
7917
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error` (see {@linkcode SdkError}).
|
|
7918
|
+
*/
|
|
7919
|
+
constructor(code, message, data, options) {
|
|
7920
|
+
super(code, message, data, options);
|
|
7905
7921
|
this.name = "SdkHttpError";
|
|
7906
7922
|
}
|
|
7907
7923
|
get status() {
|
|
@@ -10554,7 +10570,7 @@ function build() {
|
|
|
10554
10570
|
const subscriptionsListenParamsShape = { notifications: SubscriptionFilterSchema$1 };
|
|
10555
10571
|
const SubscriptionsListenRequestSchema$1 = wireRequest("subscriptions/listen", subscriptionsListenParamsShape);
|
|
10556
10572
|
/**
|
|
10557
|
-
* Anchor
|
|
10573
|
+
* Anchor SubscriptionsListenResultMetaObject — required subscriptionId stamp on
|
|
10558
10574
|
* the graceful-close result. Extends `ResultMetaObject` since spec PR
|
|
10559
10575
|
* #3002 (composed, so the serverInfo key and its leniency stay single-sourced).
|
|
10560
10576
|
*/
|
|
@@ -10827,7 +10843,8 @@ function build() {
|
|
|
10827
10843
|
ListResourceTemplatesResultResponseSchema: wireResultResponse(ListResourceTemplatesResultSchema$1),
|
|
10828
10844
|
ReadResourceResultResponseSchema: wireResultResponse(union([ReadResourceResultSchema$1, InputRequiredResultSchema])),
|
|
10829
10845
|
CompleteResultResponseSchema: wireResultResponse(CompleteResultSchema$1),
|
|
10830
|
-
DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1)
|
|
10846
|
+
DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1),
|
|
10847
|
+
SubscriptionsListenResultResponseSchema: wireResultResponse(SubscriptionsListenResultSchema$1)
|
|
10831
10848
|
};
|
|
10832
10849
|
}
|
|
10833
10850
|
let memo;
|
|
@@ -11460,6 +11477,8 @@ const rev2026Codec = {
|
|
|
11460
11477
|
const rawInputRequests = raw["inputRequests"];
|
|
11461
11478
|
const inputRequests = isPlainObject$4(rawInputRequests) ? rawInputRequests : {};
|
|
11462
11479
|
const requestState = raw["requestState"];
|
|
11480
|
+
const metaParse = raw["_meta"] === void 0 ? void 0 : buildSchemas2026().ResultMetaSchema.safeParse(raw["_meta"]);
|
|
11481
|
+
const meta = metaParse?.success ? metaParse.data : void 0;
|
|
11463
11482
|
if (Object.keys(inputRequests).length === 0 && typeof requestState !== "string") return {
|
|
11464
11483
|
kind: "invalid",
|
|
11465
11484
|
error: new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${method}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`, {
|
|
@@ -11470,7 +11489,8 @@ const rev2026Codec = {
|
|
|
11470
11489
|
return {
|
|
11471
11490
|
kind: "input_required",
|
|
11472
11491
|
inputRequests,
|
|
11473
|
-
...typeof requestState === "string" && { requestState }
|
|
11492
|
+
...typeof requestState === "string" && { requestState },
|
|
11493
|
+
...meta !== void 0 && { _meta: meta }
|
|
11474
11494
|
};
|
|
11475
11495
|
}
|
|
11476
11496
|
if (rawResultType !== "complete") return {
|
|
@@ -11568,6 +11588,10 @@ function isSpecRequestMethod(method) {
|
|
|
11568
11588
|
function isSpecNotificationMethod(method) {
|
|
11569
11589
|
return ALL_CODECS.some((codec) => codec.hasNotificationMethod(method));
|
|
11570
11590
|
}
|
|
11591
|
+
/** The names SEP-2663 re-defines for the Tasks extension on the era that removed them from core. */
|
|
11592
|
+
function isExtensionReusedRequestMethod(method) {
|
|
11593
|
+
return method === "tasks/get" || method === "tasks/cancel";
|
|
11594
|
+
}
|
|
11571
11595
|
const ALL_CODECS = [rev2025Codec, rev2026Codec];
|
|
11572
11596
|
var schemas_exports = /* @__PURE__ */ __exportAll({
|
|
11573
11597
|
AnnotationsSchema: () => AnnotationsSchema,
|
|
@@ -12599,6 +12623,8 @@ var Protocol = class {
|
|
|
12599
12623
|
_transport;
|
|
12600
12624
|
_requestMessageId = 0;
|
|
12601
12625
|
_requestHandlers = /* @__PURE__ */ new Map();
|
|
12626
|
+
/** Methods registered with an explicit schema; the era gate in `_onrequest` reads it for the Tasks extension names. */
|
|
12627
|
+
_customSchemaRequestMethods = /* @__PURE__ */ new Set();
|
|
12602
12628
|
_requestHandlerAbortControllers = /* @__PURE__ */ new Map();
|
|
12603
12629
|
_notificationHandlers = /* @__PURE__ */ new Map();
|
|
12604
12630
|
_responseHandlers = /* @__PURE__ */ new Map();
|
|
@@ -12729,7 +12755,7 @@ var Protocol = class {
|
|
|
12729
12755
|
return this._requestHandlers.get(method);
|
|
12730
12756
|
}
|
|
12731
12757
|
async _oncancel(notification) {
|
|
12732
|
-
if (
|
|
12758
|
+
if (notification.params.requestId === void 0) return;
|
|
12733
12759
|
this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
|
|
12734
12760
|
}
|
|
12735
12761
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
@@ -12876,7 +12902,7 @@ var Protocol = class {
|
|
|
12876
12902
|
return;
|
|
12877
12903
|
}
|
|
12878
12904
|
}
|
|
12879
|
-
if (isSpecRequestMethod(request.method) && !codec.hasRequestMethod(request.method)) {
|
|
12905
|
+
if (isSpecRequestMethod(request.method) && !codec.hasRequestMethod(request.method) && !(isExtensionReusedRequestMethod(request.method) && this._customSchemaRequestMethods.has(request.method))) {
|
|
12880
12906
|
sendErrorResponse(ProtocolErrorCode.MethodNotFound, "Method not found");
|
|
12881
12907
|
return;
|
|
12882
12908
|
}
|
|
@@ -13009,8 +13035,11 @@ var Protocol = class {
|
|
|
13009
13035
|
}
|
|
13010
13036
|
request(request, schemaOrOptions, maybeOptions) {
|
|
13011
13037
|
const codec = this._resolveOutboundCodec(request.method);
|
|
13038
|
+
if (isStandardSchema(schemaOrOptions)) {
|
|
13039
|
+
if (!isExtensionReusedRequestMethod(request.method)) this._assertOutboundRequestInEra(codec, request.method);
|
|
13040
|
+
return this._requestWithSchemaViaCodec(codec, request, schemaOrOptions, maybeOptions);
|
|
13041
|
+
}
|
|
13012
13042
|
this._assertOutboundRequestInEra(codec, request.method);
|
|
13013
|
-
if (isStandardSchema(schemaOrOptions)) return this._requestWithSchemaViaCodec(codec, request, schemaOrOptions, maybeOptions);
|
|
13014
13043
|
const validate = codecResultValidator(codec, request.method);
|
|
13015
13044
|
if (validate === void 0) throw new TypeError(`'${request.method}' is not a spec method; pass a result schema as the second argument to request().`);
|
|
13016
13045
|
return this._requestWithSchemaViaCodec(codec, request, validate, schemaOrOptions);
|
|
@@ -13128,19 +13157,20 @@ var Protocol = class {
|
|
|
13128
13157
|
const cancel = (reason) => {
|
|
13129
13158
|
if (responseReceived) return;
|
|
13130
13159
|
this._progressHandlers.delete(messageId);
|
|
13131
|
-
if (requestAbort === void 0)
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
|
|
13160
|
+
if (requestAbort === void 0) {
|
|
13161
|
+
if (request.method !== "initialize") this._transport?.send(this._envelopeOutbound({
|
|
13162
|
+
jsonrpc: "2.0",
|
|
13163
|
+
method: "notifications/cancelled",
|
|
13164
|
+
params: {
|
|
13165
|
+
requestId: messageId,
|
|
13166
|
+
reason: String(reason)
|
|
13167
|
+
}
|
|
13168
|
+
}), {
|
|
13169
|
+
relatedRequestId,
|
|
13170
|
+
resumptionToken,
|
|
13171
|
+
onresumptiontoken
|
|
13172
|
+
}).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error}`)));
|
|
13173
|
+
} else requestAbort.abort();
|
|
13144
13174
|
reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
|
|
13145
13175
|
};
|
|
13146
13176
|
this._responseHandlers.set(messageId, (response) => {
|
|
@@ -13202,7 +13232,7 @@ var Protocol = class {
|
|
|
13202
13232
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
13203
13233
|
*/
|
|
13204
13234
|
async notification(notification, options) {
|
|
13205
|
-
return this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
|
|
13235
|
+
return await this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
|
|
13206
13236
|
}
|
|
13207
13237
|
/**
|
|
13208
13238
|
* The notification funnel proper, keyed by the resolved era codec —
|
|
@@ -13220,7 +13250,7 @@ var Protocol = class {
|
|
|
13220
13250
|
jsonrpc: "2.0",
|
|
13221
13251
|
...notification
|
|
13222
13252
|
});
|
|
13223
|
-
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params &&
|
|
13253
|
+
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && options?.relatedRequestId === void 0) {
|
|
13224
13254
|
if (this._pendingDebouncedNotifications.has(notification.method)) return;
|
|
13225
13255
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
13226
13256
|
Promise.resolve().then(() => {
|
|
@@ -13253,6 +13283,8 @@ var Protocol = class {
|
|
|
13253
13283
|
return maybeHandler(parsed.data, ctx);
|
|
13254
13284
|
};
|
|
13255
13285
|
else throw new TypeError("setRequestHandler: handler is required");
|
|
13286
|
+
if (typeof schemasOrHandler === "function") this._customSchemaRequestMethods.delete(method);
|
|
13287
|
+
else this._customSchemaRequestMethods.add(method);
|
|
13256
13288
|
this._requestHandlers.set(method, this._wrapHandler(method, stored));
|
|
13257
13289
|
}
|
|
13258
13290
|
/**
|
|
@@ -13281,6 +13313,7 @@ var Protocol = class {
|
|
|
13281
13313
|
*/
|
|
13282
13314
|
removeRequestHandler(method) {
|
|
13283
13315
|
this._requestHandlers.delete(method);
|
|
13316
|
+
this._customSchemaRequestMethods.delete(method);
|
|
13284
13317
|
}
|
|
13285
13318
|
/**
|
|
13286
13319
|
* Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.
|
|
@@ -13371,7 +13404,8 @@ function manualInputRequiredValue(decoded) {
|
|
|
13371
13404
|
return {
|
|
13372
13405
|
resultType: "input_required",
|
|
13373
13406
|
inputRequests: decoded.inputRequests,
|
|
13374
|
-
...decoded.requestState !== void 0 && { requestState: decoded.requestState }
|
|
13407
|
+
...decoded.requestState !== void 0 && { requestState: decoded.requestState },
|
|
13408
|
+
...decoded._meta !== void 0 && { _meta: decoded._meta }
|
|
13375
13409
|
};
|
|
13376
13410
|
}
|
|
13377
13411
|
/*!
|
|
@@ -13623,7 +13657,7 @@ function normalizeRawShapeSchema(schema) {
|
|
|
13623
13657
|
return schema;
|
|
13624
13658
|
}
|
|
13625
13659
|
//#endregion
|
|
13626
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.
|
|
13660
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.3.1/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs
|
|
13627
13661
|
var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
13628
13662
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13629
13663
|
exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
|
|
@@ -20758,7 +20792,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
20758
20792
|
};
|
|
20759
20793
|
import_ajv.Ajv;
|
|
20760
20794
|
//#endregion
|
|
20761
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.
|
|
20795
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+server@2.3.1/node_modules/@modelcontextprotocol/server/dist/mcp-DIH4cS6P.mjs
|
|
20762
20796
|
const COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
|
|
20763
20797
|
/**
|
|
20764
20798
|
* Checks if a schema is completable (has completion metadata).
|
|
@@ -20772,6 +20806,10 @@ function isCompletable(schema) {
|
|
|
20772
20806
|
function getCompleter(schema) {
|
|
20773
20807
|
return schema[COMPLETABLE_SYMBOL]?.complete;
|
|
20774
20808
|
}
|
|
20809
|
+
/** @internal */
|
|
20810
|
+
function supportsScopeChallengeResolver(transport) {
|
|
20811
|
+
return typeof transport === "object" && transport !== null && "setScopeChallengeResolver" in transport && typeof transport.setScopeChallengeResolver === "function";
|
|
20812
|
+
}
|
|
20775
20813
|
/**
|
|
20776
20814
|
* Default handler re-entries per originating request — tighter than the
|
|
20777
20815
|
* client driver's 10 because the shim holds a live wire request open.
|
|
@@ -20980,6 +21018,11 @@ var Server = class extends Protocol {
|
|
|
20980
21018
|
if (modernProtocolVersions(this._supportedProtocolVersions).length > 0) this.setRequestHandler("server/discover", () => this._ondiscover());
|
|
20981
21019
|
if (this._capabilities.logging) this._registerLoggingHandler();
|
|
20982
21020
|
}
|
|
21021
|
+
/** Attaches to the given transport; rejects while this instance is connected to another one. */
|
|
21022
|
+
async connect(transport) {
|
|
21023
|
+
if (this.transport !== void 0) throw new SdkError(SdkErrorCode.AlreadyConnected, "Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");
|
|
21024
|
+
await super.connect(transport);
|
|
21025
|
+
}
|
|
20983
21026
|
/**
|
|
20984
21027
|
* Registers the built-in `logging/setLevel` request handler.
|
|
20985
21028
|
*
|
|
@@ -21525,6 +21568,30 @@ var Server = class extends Protocol {
|
|
|
21525
21568
|
function discoverAdvertisedCapabilities(capabilities) {
|
|
21526
21569
|
return { ...capabilities };
|
|
21527
21570
|
}
|
|
21571
|
+
function toolInputElementCount(value, max) {
|
|
21572
|
+
let count = 0;
|
|
21573
|
+
const stack = [value];
|
|
21574
|
+
while (stack.length > 0) {
|
|
21575
|
+
const node = stack.pop();
|
|
21576
|
+
if (node === null || typeof node !== "object") continue;
|
|
21577
|
+
if (Array.isArray(node)) for (const child of node) {
|
|
21578
|
+
if (++count > max) return count;
|
|
21579
|
+
if (child !== null && typeof child === "object") stack.push(child);
|
|
21580
|
+
}
|
|
21581
|
+
else for (const key in node) {
|
|
21582
|
+
if (!Object.prototype.hasOwnProperty.call(node, key)) continue;
|
|
21583
|
+
if (++count > max) return count;
|
|
21584
|
+
const child = node[key];
|
|
21585
|
+
if (child !== null && typeof child === "object") stack.push(child);
|
|
21586
|
+
}
|
|
21587
|
+
}
|
|
21588
|
+
return count;
|
|
21589
|
+
}
|
|
21590
|
+
function resolveMaxToolInputElements(value) {
|
|
21591
|
+
if (value === void 0 || value === Infinity) return void 0;
|
|
21592
|
+
if (typeof value !== "number" || Number.isNaN(value) || value < 1) throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
|
|
21593
|
+
return value;
|
|
21594
|
+
}
|
|
21528
21595
|
/**
|
|
21529
21596
|
* High-level MCP server that provides a simpler API for working with resources, tools, and prompts.
|
|
21530
21597
|
* For advanced usage (like sending notifications or setting custom request handlers), use the underlying
|
|
@@ -21543,16 +21610,12 @@ var McpServer = class {
|
|
|
21543
21610
|
* The underlying {@linkcode Server} instance, useful for advanced operations like sending notifications.
|
|
21544
21611
|
*/
|
|
21545
21612
|
server;
|
|
21613
|
+
_maxToolInputElements;
|
|
21546
21614
|
_registeredResources = {};
|
|
21547
21615
|
_registeredResourceTemplates = {};
|
|
21548
21616
|
_registeredTools = {};
|
|
21549
21617
|
_registeredPrompts = {};
|
|
21550
|
-
/**
|
|
21551
|
-
* Per-tool JSON-converted `inputSchema`, memoized so the SEP-2243
|
|
21552
|
-
* registration-time scan and the pre-dispatch validation step share one
|
|
21553
|
-
* conversion instead of paying it twice per request under the
|
|
21554
|
-
* per-request-factory `createMcpHandler` model.
|
|
21555
|
-
*/
|
|
21618
|
+
/** Per-tool JSON-converted `inputSchema`, filled on first use by `toolInputSchemaJson()`. */
|
|
21556
21619
|
_toolInputSchemaJson = {};
|
|
21557
21620
|
/**
|
|
21558
21621
|
* The JSON-serialized `inputSchema` of a registered tool, or `undefined`
|
|
@@ -21577,6 +21640,7 @@ var McpServer = class {
|
|
|
21577
21640
|
}
|
|
21578
21641
|
constructor(serverInfo, options) {
|
|
21579
21642
|
this.server = new Server(serverInfo, options);
|
|
21643
|
+
this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
|
|
21580
21644
|
if (options?.capabilities?.tools) this.setToolRequestHandlers();
|
|
21581
21645
|
if (options?.capabilities?.resources) this.setResourceRequestHandlers();
|
|
21582
21646
|
if (options?.capabilities?.prompts) this.setPromptRequestHandlers();
|
|
@@ -21594,6 +21658,7 @@ var McpServer = class {
|
|
|
21594
21658
|
* ```
|
|
21595
21659
|
*/
|
|
21596
21660
|
async connect(transport) {
|
|
21661
|
+
if (supportsScopeChallengeResolver(transport)) transport.setScopeChallengeResolver((context) => this.resolveScopeChallenge(context));
|
|
21597
21662
|
return await this.server.connect(transport);
|
|
21598
21663
|
}
|
|
21599
21664
|
/**
|
|
@@ -21602,6 +21667,40 @@ var McpServer = class {
|
|
|
21602
21667
|
async close() {
|
|
21603
21668
|
await this.server.close();
|
|
21604
21669
|
}
|
|
21670
|
+
/** @internal */
|
|
21671
|
+
resolveScopeChallenge = (context) => {
|
|
21672
|
+
switch (context.request.method) {
|
|
21673
|
+
case "tools/call": {
|
|
21674
|
+
const toolName = context.request.params?.name;
|
|
21675
|
+
if (typeof toolName !== "string") return;
|
|
21676
|
+
const tool = this._registeredTools[toolName];
|
|
21677
|
+
if (tool === void 0 || !tool.enabled) return;
|
|
21678
|
+
return tool.scopeChallenge?.(context);
|
|
21679
|
+
}
|
|
21680
|
+
case "resources/read": {
|
|
21681
|
+
const resourceUri = context.request.params?.uri;
|
|
21682
|
+
if (typeof resourceUri !== "string") return;
|
|
21683
|
+
let uri;
|
|
21684
|
+
try {
|
|
21685
|
+
uri = new URL(resourceUri);
|
|
21686
|
+
} catch {
|
|
21687
|
+
return;
|
|
21688
|
+
}
|
|
21689
|
+
const resource = this._registeredResources[uri.toString()];
|
|
21690
|
+
if (resource !== void 0) return resource.enabled ? resource.scopeChallenge?.(context) : void 0;
|
|
21691
|
+
for (const template of Object.values(this._registeredResourceTemplates)) if (template.resourceTemplate.uriTemplate.match(uri.toString())) return template.enabled ? template.scopeChallenge?.(context) : void 0;
|
|
21692
|
+
return;
|
|
21693
|
+
}
|
|
21694
|
+
case "prompts/get": {
|
|
21695
|
+
const promptName = context.request.params?.name;
|
|
21696
|
+
if (typeof promptName !== "string") return;
|
|
21697
|
+
const prompt = this._registeredPrompts[promptName];
|
|
21698
|
+
if (prompt === void 0 || !prompt.enabled) return;
|
|
21699
|
+
return prompt.scopeChallenge?.(context);
|
|
21700
|
+
}
|
|
21701
|
+
default: return;
|
|
21702
|
+
}
|
|
21703
|
+
};
|
|
21605
21704
|
_toolHandlersInitialized = false;
|
|
21606
21705
|
setToolRequestHandlers() {
|
|
21607
21706
|
if (this._toolHandlersInitialized) return;
|
|
@@ -21613,7 +21712,7 @@ var McpServer = class {
|
|
|
21613
21712
|
name,
|
|
21614
21713
|
title: tool.title,
|
|
21615
21714
|
description: tool.description,
|
|
21616
|
-
inputSchema: tool.inputSchema ?
|
|
21715
|
+
inputSchema: tool.inputSchema ? convertListedInputSchema(name, tool.inputSchema) : EMPTY_OBJECT_JSON_SCHEMA,
|
|
21617
21716
|
annotations: tool.annotations,
|
|
21618
21717
|
icons: tool.icons,
|
|
21619
21718
|
execution: tool.execution,
|
|
@@ -21658,6 +21757,7 @@ var McpServer = class {
|
|
|
21658
21757
|
* Validates tool input arguments against the tool's input schema.
|
|
21659
21758
|
*/
|
|
21660
21759
|
async validateToolInput(tool, args, toolName) {
|
|
21760
|
+
if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
|
|
21661
21761
|
if (!tool.inputSchema) return;
|
|
21662
21762
|
const parseResult = await validateStandardSchema(tool.inputSchema, args ?? {});
|
|
21663
21763
|
if (!parseResult.success) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${parseResult.error}`);
|
|
@@ -21767,7 +21867,10 @@ var McpServer = class {
|
|
|
21767
21867
|
}
|
|
21768
21868
|
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
21769
21869
|
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
21770
|
-
if (variables)
|
|
21870
|
+
if (variables) {
|
|
21871
|
+
if (!template.enabled) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Resource template ${template.resourceTemplate.uriTemplate} disabled`);
|
|
21872
|
+
return attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
|
|
21873
|
+
}
|
|
21771
21874
|
}
|
|
21772
21875
|
throw new ResourceNotFoundError(request.params.uri);
|
|
21773
21876
|
});
|
|
@@ -21798,36 +21901,32 @@ var McpServer = class {
|
|
|
21798
21901
|
this._promptHandlersInitialized = true;
|
|
21799
21902
|
}
|
|
21800
21903
|
registerResource(name, uriOrTemplate, config, readCallback) {
|
|
21801
|
-
const cacheHint = config
|
|
21802
|
-
|
|
21803
|
-
if (cacheHint !== void 0) {
|
|
21804
|
-
assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
21805
|
-
const rest = { ...config };
|
|
21806
|
-
delete rest.cacheHint;
|
|
21807
|
-
metadata = rest;
|
|
21808
|
-
}
|
|
21904
|
+
const { cacheHint, scopeChallenge, ...resourceMetadata } = config;
|
|
21905
|
+
const metadata = resourceMetadata;
|
|
21906
|
+
if (cacheHint !== void 0) assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
21809
21907
|
if (typeof uriOrTemplate === "string") {
|
|
21810
21908
|
if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
21811
|
-
const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, metadata, readCallback);
|
|
21909
|
+
const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
21812
21910
|
if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
|
|
21813
21911
|
this.setResourceRequestHandlers();
|
|
21814
21912
|
this.sendResourceListChanged();
|
|
21815
21913
|
return registeredResource;
|
|
21816
21914
|
} else {
|
|
21817
21915
|
if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
|
|
21818
|
-
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, metadata, readCallback);
|
|
21916
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
21819
21917
|
if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
|
|
21820
21918
|
this.setResourceRequestHandlers();
|
|
21821
21919
|
this.sendResourceListChanged();
|
|
21822
21920
|
return registeredResourceTemplate;
|
|
21823
21921
|
}
|
|
21824
21922
|
}
|
|
21825
|
-
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
21923
|
+
_createRegisteredResource(name, title, uri, metadata, scopeChallenge, readCallback) {
|
|
21826
21924
|
const registeredResource = {
|
|
21827
21925
|
name,
|
|
21828
21926
|
title,
|
|
21829
21927
|
metadata,
|
|
21830
21928
|
readCallback,
|
|
21929
|
+
scopeChallenge,
|
|
21831
21930
|
enabled: true,
|
|
21832
21931
|
disable: () => registeredResource.update({ enabled: false }),
|
|
21833
21932
|
enable: () => registeredResource.update({ enabled: true }),
|
|
@@ -21841,6 +21940,7 @@ var McpServer = class {
|
|
|
21841
21940
|
if (updates.title !== void 0) registeredResource.title = updates.title;
|
|
21842
21941
|
if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
|
|
21843
21942
|
if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
|
|
21943
|
+
if (updates.scopeChallenge !== void 0) registeredResource.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
21844
21944
|
if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
|
|
21845
21945
|
this.sendResourceListChanged();
|
|
21846
21946
|
}
|
|
@@ -21848,12 +21948,13 @@ var McpServer = class {
|
|
|
21848
21948
|
this._registeredResources[uri] = registeredResource;
|
|
21849
21949
|
return registeredResource;
|
|
21850
21950
|
}
|
|
21851
|
-
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
21951
|
+
_createRegisteredResourceTemplate(name, title, template, metadata, scopeChallenge, readCallback) {
|
|
21852
21952
|
const registeredResourceTemplate = {
|
|
21853
21953
|
resourceTemplate: template,
|
|
21854
21954
|
title,
|
|
21855
21955
|
metadata,
|
|
21856
21956
|
readCallback,
|
|
21957
|
+
scopeChallenge,
|
|
21857
21958
|
enabled: true,
|
|
21858
21959
|
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
21859
21960
|
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
@@ -21867,6 +21968,7 @@ var McpServer = class {
|
|
|
21867
21968
|
if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
|
|
21868
21969
|
if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
|
|
21869
21970
|
if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
|
|
21971
|
+
if (updates.scopeChallenge !== void 0) registeredResourceTemplate.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
21870
21972
|
if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
|
|
21871
21973
|
this.sendResourceListChanged();
|
|
21872
21974
|
}
|
|
@@ -21876,7 +21978,7 @@ var McpServer = class {
|
|
|
21876
21978
|
if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
|
|
21877
21979
|
return registeredResourceTemplate;
|
|
21878
21980
|
}
|
|
21879
|
-
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, _meta) {
|
|
21981
|
+
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, scopeChallenge, _meta) {
|
|
21880
21982
|
let currentArgsSchema = argsSchema;
|
|
21881
21983
|
let currentCallback = callback;
|
|
21882
21984
|
const registeredPrompt = {
|
|
@@ -21884,6 +21986,7 @@ var McpServer = class {
|
|
|
21884
21986
|
description,
|
|
21885
21987
|
argsSchema,
|
|
21886
21988
|
icons,
|
|
21989
|
+
scopeChallenge,
|
|
21887
21990
|
_meta,
|
|
21888
21991
|
handler: createPromptHandler(name, argsSchema, callback),
|
|
21889
21992
|
enabled: true,
|
|
@@ -21898,6 +22001,7 @@ var McpServer = class {
|
|
|
21898
22001
|
if (updates.title !== void 0) registeredPrompt.title = updates.title;
|
|
21899
22002
|
if (updates.description !== void 0) registeredPrompt.description = updates.description;
|
|
21900
22003
|
if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
|
|
22004
|
+
if (updates.scopeChallenge !== void 0) registeredPrompt.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
21901
22005
|
if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
|
|
21902
22006
|
let needsHandlerRegen = false;
|
|
21903
22007
|
if (updates.argsSchema !== void 0) {
|
|
@@ -21925,24 +22029,25 @@ var McpServer = class {
|
|
|
21925
22029
|
}
|
|
21926
22030
|
return registeredPrompt;
|
|
21927
22031
|
}
|
|
21928
|
-
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, _meta, handler) {
|
|
22032
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, scopeChallenge, _meta, handler) {
|
|
21929
22033
|
validateAndWarnToolName(name);
|
|
21930
|
-
if (inputSchema !== void 0) try {
|
|
21931
|
-
const json = standardSchemaToJsonSchema(inputSchema, "input");
|
|
21932
|
-
this._toolInputSchemaJson[name] = json;
|
|
21933
|
-
const scan = scanXMcpHeaderDeclarations(json);
|
|
21934
|
-
if (!scan.valid) console.warn(`[mcp-sdk] tool '${name}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${scan.reason}`);
|
|
21935
|
-
} catch {}
|
|
21936
22034
|
let currentHandler = handler;
|
|
22035
|
+
let outputSchemaJson;
|
|
21937
22036
|
const registeredTool = {
|
|
21938
22037
|
title,
|
|
21939
22038
|
description,
|
|
21940
22039
|
inputSchema,
|
|
21941
22040
|
outputSchema,
|
|
21942
|
-
outputSchemaJson
|
|
22041
|
+
get outputSchemaJson() {
|
|
22042
|
+
return outputSchemaJson ??= convertOutputSchemaJson(registeredTool.outputSchema);
|
|
22043
|
+
},
|
|
22044
|
+
set outputSchemaJson(value) {
|
|
22045
|
+
outputSchemaJson = value;
|
|
22046
|
+
},
|
|
21943
22047
|
annotations,
|
|
21944
22048
|
icons,
|
|
21945
22049
|
execution,
|
|
22050
|
+
scopeChallenge,
|
|
21946
22051
|
_meta,
|
|
21947
22052
|
handler,
|
|
21948
22053
|
executor: createToolExecutor(inputSchema, handler),
|
|
@@ -21981,6 +22086,7 @@ var McpServer = class {
|
|
|
21981
22086
|
}
|
|
21982
22087
|
if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
|
|
21983
22088
|
if (updates.icons !== void 0) registeredTool.icons = updates.icons;
|
|
22089
|
+
if (updates.scopeChallenge !== void 0) registeredTool.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
21984
22090
|
if (updates._meta !== void 0) registeredTool._meta = updates._meta;
|
|
21985
22091
|
if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
|
|
21986
22092
|
this.sendToolListChanged();
|
|
@@ -21993,13 +22099,13 @@ var McpServer = class {
|
|
|
21993
22099
|
}
|
|
21994
22100
|
registerTool(name, config, cb) {
|
|
21995
22101
|
if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
|
|
21996
|
-
const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config;
|
|
21997
|
-
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, _meta, cb);
|
|
22102
|
+
const { title, description, inputSchema, outputSchema, annotations, icons, scopeChallenge, _meta } = config;
|
|
22103
|
+
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, scopeChallenge, _meta, cb);
|
|
21998
22104
|
}
|
|
21999
22105
|
registerPrompt(name, config, cb) {
|
|
22000
22106
|
if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
|
|
22001
|
-
const { title, description, argsSchema, icons, _meta } = config;
|
|
22002
|
-
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, _meta);
|
|
22107
|
+
const { title, description, argsSchema, icons, scopeChallenge, _meta } = config;
|
|
22108
|
+
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, scopeChallenge, _meta);
|
|
22003
22109
|
this.setPromptRequestHandlers();
|
|
22004
22110
|
this.sendPromptListChanged();
|
|
22005
22111
|
return registeredPrompt;
|
|
@@ -22069,6 +22175,13 @@ const EMPTY_OBJECT_JSON_SCHEMA = {
|
|
|
22069
22175
|
type: "object",
|
|
22070
22176
|
properties: {}
|
|
22071
22177
|
};
|
|
22178
|
+
/** Converts a tool's `inputSchema` for `tools/list` and warns on an invalid SEP-2243 `x-mcp-header` declaration. */
|
|
22179
|
+
function convertListedInputSchema(name, inputSchema) {
|
|
22180
|
+
const json = standardSchemaToJsonSchema(inputSchema, "input");
|
|
22181
|
+
const scan = scanXMcpHeaderDeclarations(json);
|
|
22182
|
+
if (!scan.valid) console.warn(`[mcp-sdk] tool '${name}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${scan.reason}`);
|
|
22183
|
+
return json;
|
|
22184
|
+
}
|
|
22072
22185
|
/**
|
|
22073
22186
|
* Convert a registered `outputSchema` to JSON Schema, memoised on {@link RegisteredTool.outputSchemaJson}
|
|
22074
22187
|
* so `tools/call` passes the SAME advertised schema to the wire codec's `projectCallToolResult` that
|
|
@@ -22091,7 +22204,7 @@ function createPromptHandler(name, argsSchema, callback) {
|
|
|
22091
22204
|
if (argsSchema) {
|
|
22092
22205
|
const typedCallback = callback;
|
|
22093
22206
|
return async (args, ctx) => {
|
|
22094
|
-
const parseResult = await validateStandardSchema(argsSchema, args);
|
|
22207
|
+
const parseResult = await validateStandardSchema(argsSchema, args ?? {});
|
|
22095
22208
|
if (!parseResult.success) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Invalid arguments for prompt ${name}: ${parseResult.error}`);
|
|
22096
22209
|
return typedCallback(parseResult.data, ctx);
|
|
22097
22210
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as canonicalSecretWebhookUrl } from "./webhook-target-
|
|
1
|
+
import { t as canonicalSecretWebhookUrl } from "./webhook-target-DyDTwWhV.mjs";
|
|
2
2
|
import { createCipheriv, createDecipheriv, hkdfSync, randomBytes } from "node:crypto";
|
|
3
3
|
import "node:fs/promises";
|
|
4
4
|
import { FileSecretStore, KeychainSecretStore, canonicalJson, keychainNamespace, loadKeyringModule, sha256Hex, withFileLock } from "@agentcomms/core";
|
|
@@ -354,7 +354,7 @@ var EventSecretStore = class {
|
|
|
354
354
|
this.assertSelectedBackend();
|
|
355
355
|
const row = this.#database.prepare("SELECT secret_ref, retired_at FROM event_secret_masters WHERE key_id = ?").get(input.keyId);
|
|
356
356
|
if (row === void 0 || row.retired_at === null) throw new EventSecretError("EVENT_MASTER_UNKNOWN", "only a known retired event master may be destroyed");
|
|
357
|
-
const { RECORD_LAYOUTS } = await import("./records-
|
|
357
|
+
const { RECORD_LAYOUTS } = await import("./records-DjE5a4_H.mjs");
|
|
358
358
|
for (const layout of RECORD_LAYOUTS) {
|
|
359
359
|
const records = this.#database.prepare(`SELECT ${layout.sqlColumn} AS record FROM ${layout.table} WHERE ${layout.sqlColumn} IS NOT NULL`).all();
|
|
360
360
|
for (const record of records) {
|