canvas-parent-mcp 2.1.3 → 2.1.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +9 -3
- package/dist/auth.js +3 -3
- package/dist/bundle.js +775 -188
- package/dist/client.js +44 -5
- package/dist/index.js +1 -1
- package/dist/tools/conversations.js +5 -1
- package/package.json +4 -4
- package/server.json +2 -2
- package/skills/canvas-parent/SKILL.md +2 -2
package/dist/bundle.js
CHANGED
|
@@ -5007,7 +5007,7 @@ var require_memoizer = __commonJS({
|
|
|
5007
5007
|
return bucket;
|
|
5008
5008
|
}
|
|
5009
5009
|
var handoff2;
|
|
5010
|
-
var
|
|
5010
|
+
var open3 = [];
|
|
5011
5011
|
var memo3 = {
|
|
5012
5012
|
alloc(_inst, payload, empty) {
|
|
5013
5013
|
const bucket = handoff2;
|
|
@@ -5016,7 +5016,7 @@ var require_memoizer = __commonJS({
|
|
|
5016
5016
|
handoff2 = void 0;
|
|
5017
5017
|
const entry = { value: empty, issues: null };
|
|
5018
5018
|
bucket.set(payload.value, entry);
|
|
5019
|
-
|
|
5019
|
+
open3.push(entry);
|
|
5020
5020
|
return empty;
|
|
5021
5021
|
},
|
|
5022
5022
|
guard(inst) {
|
|
@@ -5087,10 +5087,10 @@ var require_memoizer = __commonJS({
|
|
|
5087
5087
|
return payload;
|
|
5088
5088
|
}
|
|
5089
5089
|
handoff2 = bucket;
|
|
5090
|
-
const depth =
|
|
5090
|
+
const depth = open3.length;
|
|
5091
5091
|
const result = base(payload, ctx);
|
|
5092
5092
|
handoff2 = void 0;
|
|
5093
|
-
const entry =
|
|
5093
|
+
const entry = open3.length > depth ? open3.pop() : void 0;
|
|
5094
5094
|
if (result instanceof Promise) {
|
|
5095
5095
|
return result.then((r) => {
|
|
5096
5096
|
if (entry)
|
|
@@ -26497,7 +26497,7 @@ var require_stream = __commonJS({
|
|
|
26497
26497
|
};
|
|
26498
26498
|
duplex._final = function(callback) {
|
|
26499
26499
|
if (ws.readyState === ws.CONNECTING) {
|
|
26500
|
-
ws.once("open", function
|
|
26500
|
+
ws.once("open", function open3() {
|
|
26501
26501
|
duplex._final(callback);
|
|
26502
26502
|
});
|
|
26503
26503
|
return;
|
|
@@ -26518,7 +26518,7 @@ var require_stream = __commonJS({
|
|
|
26518
26518
|
};
|
|
26519
26519
|
duplex._write = function(chunk2, encoding, callback) {
|
|
26520
26520
|
if (ws.readyState === ws.CONNECTING) {
|
|
26521
|
-
ws.once("open", function
|
|
26521
|
+
ws.once("open", function open3() {
|
|
26522
26522
|
duplex._write(chunk2, encoding, callback);
|
|
26523
26523
|
});
|
|
26524
26524
|
return;
|
|
@@ -26980,7 +26980,7 @@ var require_websocket_server = __commonJS({
|
|
|
26980
26980
|
});
|
|
26981
26981
|
|
|
26982
26982
|
// src/index.ts
|
|
26983
|
-
import { dirname as dirname4, join as
|
|
26983
|
+
import { dirname as dirname4, join as join7 } from "path";
|
|
26984
26984
|
import { fileURLToPath } from "url";
|
|
26985
26985
|
|
|
26986
26986
|
// node_modules/@chrischall/mcp-utils/dist/cancel/index.js
|
|
@@ -27054,7 +27054,7 @@ function declaredDialect(schema, remedy) {
|
|
|
27054
27054
|
throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${schema.$schema.slice(0, 200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${remedy}`);
|
|
27055
27055
|
}
|
|
27056
27056
|
|
|
27057
|
-
// node_modules/@modelcontextprotocol/core/dist/auth-
|
|
27057
|
+
// node_modules/@modelcontextprotocol/core/dist/auth-CGP0BDVq.mjs
|
|
27058
27058
|
var z = __toESM(require_v4(), 1);
|
|
27059
27059
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
27060
27060
|
var SUPPORTED_PROTOCOL_VERSIONS = [
|
|
@@ -27892,7 +27892,8 @@ var OAuthMetadataSchema = z.looseObject({
|
|
|
27892
27892
|
introspection_endpoint_auth_signing_alg_values_supported: z.array(z.string()).optional(),
|
|
27893
27893
|
code_challenge_methods_supported: z.array(z.string()).optional(),
|
|
27894
27894
|
client_id_metadata_document_supported: z.boolean().optional(),
|
|
27895
|
-
authorization_response_iss_parameter_supported: z.boolean().optional().catch(void 0)
|
|
27895
|
+
authorization_response_iss_parameter_supported: z.boolean().optional().catch(void 0),
|
|
27896
|
+
dpop_signing_alg_values_supported: z.array(z.string()).optional()
|
|
27896
27897
|
});
|
|
27897
27898
|
var OpenIdProviderMetadataSchema = z.looseObject({
|
|
27898
27899
|
issuer: z.string(),
|
|
@@ -27993,7 +27994,7 @@ var OAuthTokenRevocationRequestSchema = z.object({
|
|
|
27993
27994
|
token_type_hint: z.string().optional()
|
|
27994
27995
|
}).strip();
|
|
27995
27996
|
|
|
27996
|
-
// node_modules/@modelcontextprotocol/server/dist/src-
|
|
27997
|
+
// node_modules/@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs
|
|
27997
27998
|
var z2 = __toESM(require_v4(), 1);
|
|
27998
27999
|
var BRANDS = /* @__PURE__ */ Symbol.for("mcp.sdk.errorBrands");
|
|
27999
28000
|
function stampErrorBrands(instance, ctor) {
|
|
@@ -28108,8 +28109,18 @@ var SdkError = class extends Error {
|
|
|
28108
28109
|
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)`");
|
|
28109
28110
|
return brandedHasInstance(this, value);
|
|
28110
28111
|
}
|
|
28111
|
-
|
|
28112
|
-
|
|
28112
|
+
/**
|
|
28113
|
+
* @param code - Stable string code identifying the failure ({@linkcode SdkErrorCode}).
|
|
28114
|
+
* @param message - Human-readable description.
|
|
28115
|
+
* @param data - Optional structured payload (for example the HTTP status carried by
|
|
28116
|
+
* {@linkcode SdkHttpError}). Opaque to the SDK: a `cause` key inside `data` is not
|
|
28117
|
+
* promoted to `Error.cause`.
|
|
28118
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error`. Pass the underlying
|
|
28119
|
+
* failure as `{ cause }` so it is reachable through the `Error.cause` chain that
|
|
28120
|
+
* loggers and error trackers walk.
|
|
28121
|
+
*/
|
|
28122
|
+
constructor(code, message, data, options) {
|
|
28123
|
+
super(message, options);
|
|
28113
28124
|
this.code = code;
|
|
28114
28125
|
this.data = data;
|
|
28115
28126
|
this.name = "SdkError";
|
|
@@ -28120,8 +28131,11 @@ var SdkHttpError = class extends SdkError {
|
|
|
28120
28131
|
static {
|
|
28121
28132
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
|
|
28122
28133
|
}
|
|
28123
|
-
|
|
28124
|
-
|
|
28134
|
+
/**
|
|
28135
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error` (see {@linkcode SdkError}).
|
|
28136
|
+
*/
|
|
28137
|
+
constructor(code, message, data, options) {
|
|
28138
|
+
super(code, message, data, options);
|
|
28125
28139
|
this.name = "SdkHttpError";
|
|
28126
28140
|
}
|
|
28127
28141
|
get status() {
|
|
@@ -31072,7 +31086,7 @@ var INBOUND_VALIDATION_LADDER = [
|
|
|
31072
31086
|
evaluatedAt: "pre-dispatch",
|
|
31073
31087
|
codes: [HEADER_MISMATCH_ERROR_CODE],
|
|
31074
31088
|
conformance: ["http-header-validation"],
|
|
31075
|
-
rationale: "SEP-2243 standard `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
|
|
31089
|
+
rationale: "SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
|
|
31076
31090
|
},
|
|
31077
31091
|
{
|
|
31078
31092
|
rung: "client-capabilities",
|
|
@@ -31842,7 +31856,7 @@ var Protocol = class {
|
|
|
31842
31856
|
return this._requestHandlers.get(method);
|
|
31843
31857
|
}
|
|
31844
31858
|
async _oncancel(notification) {
|
|
31845
|
-
if (
|
|
31859
|
+
if (notification.params.requestId === void 0) return;
|
|
31846
31860
|
this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
|
|
31847
31861
|
}
|
|
31848
31862
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
@@ -32241,19 +32255,20 @@ var Protocol = class {
|
|
|
32241
32255
|
const cancel = (reason) => {
|
|
32242
32256
|
if (responseReceived) return;
|
|
32243
32257
|
this._progressHandlers.delete(messageId);
|
|
32244
|
-
if (requestAbort === void 0)
|
|
32245
|
-
|
|
32246
|
-
|
|
32247
|
-
|
|
32248
|
-
|
|
32249
|
-
|
|
32250
|
-
|
|
32251
|
-
|
|
32252
|
-
|
|
32253
|
-
|
|
32254
|
-
|
|
32255
|
-
|
|
32256
|
-
|
|
32258
|
+
if (requestAbort === void 0) {
|
|
32259
|
+
if (request.method !== "initialize") this._transport?.send(this._envelopeOutbound({
|
|
32260
|
+
jsonrpc: "2.0",
|
|
32261
|
+
method: "notifications/cancelled",
|
|
32262
|
+
params: {
|
|
32263
|
+
requestId: messageId,
|
|
32264
|
+
reason: String(reason)
|
|
32265
|
+
}
|
|
32266
|
+
}), {
|
|
32267
|
+
relatedRequestId,
|
|
32268
|
+
resumptionToken,
|
|
32269
|
+
onresumptiontoken
|
|
32270
|
+
}).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error62}`)));
|
|
32271
|
+
} else requestAbort.abort();
|
|
32257
32272
|
reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
|
|
32258
32273
|
};
|
|
32259
32274
|
this._responseHandlers.set(messageId, (response) => {
|
|
@@ -32333,7 +32348,7 @@ var Protocol = class {
|
|
|
32333
32348
|
jsonrpc: "2.0",
|
|
32334
32349
|
...notification
|
|
32335
32350
|
});
|
|
32336
|
-
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params &&
|
|
32351
|
+
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && options?.relatedRequestId === void 0) {
|
|
32337
32352
|
if (this._pendingDebouncedNotifications.has(notification.method)) return;
|
|
32338
32353
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
32339
32354
|
Promise.resolve().then(() => {
|
|
@@ -39636,7 +39651,7 @@ var Ajv = import_ajv.Ajv;
|
|
|
39636
39651
|
// node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
|
|
39637
39652
|
import process2 from "node:process";
|
|
39638
39653
|
|
|
39639
|
-
// node_modules/@modelcontextprotocol/server/dist/mcp-
|
|
39654
|
+
// node_modules/@modelcontextprotocol/server/dist/mcp-Dw2OlZ1f.mjs
|
|
39640
39655
|
var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
|
|
39641
39656
|
function isCompletable(schema) {
|
|
39642
39657
|
return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
|
|
@@ -39829,6 +39844,9 @@ function notificationToServerEvent(method, uri) {
|
|
|
39829
39844
|
};
|
|
39830
39845
|
}
|
|
39831
39846
|
}
|
|
39847
|
+
function supportsScopeChallengeResolver(transport) {
|
|
39848
|
+
return typeof transport === "object" && transport !== null && "setScopeChallengeResolver" in transport && typeof transport.setScopeChallengeResolver === "function";
|
|
39849
|
+
}
|
|
39832
39850
|
var DEFAULT_LEGACY_SHIM_MAX_ROUNDS = 8;
|
|
39833
39851
|
var DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS = 6e5;
|
|
39834
39852
|
function resolveLegacyShimOptions(options) {
|
|
@@ -40639,6 +40657,7 @@ var McpServer = class {
|
|
|
40639
40657
|
* ```
|
|
40640
40658
|
*/
|
|
40641
40659
|
async connect(transport) {
|
|
40660
|
+
if (supportsScopeChallengeResolver(transport)) transport.setScopeChallengeResolver((context) => this.resolveScopeChallenge(context));
|
|
40642
40661
|
return await this.server.connect(transport);
|
|
40643
40662
|
}
|
|
40644
40663
|
/**
|
|
@@ -40647,6 +40666,41 @@ var McpServer = class {
|
|
|
40647
40666
|
async close() {
|
|
40648
40667
|
await this.server.close();
|
|
40649
40668
|
}
|
|
40669
|
+
/** @internal */
|
|
40670
|
+
resolveScopeChallenge = (context) => {
|
|
40671
|
+
switch (context.request.method) {
|
|
40672
|
+
case "tools/call": {
|
|
40673
|
+
const toolName = context.request.params?.name;
|
|
40674
|
+
if (typeof toolName !== "string") return;
|
|
40675
|
+
const tool = this._registeredTools[toolName];
|
|
40676
|
+
if (tool === void 0 || !tool.enabled) return;
|
|
40677
|
+
return tool.scopeChallenge?.(context);
|
|
40678
|
+
}
|
|
40679
|
+
case "resources/read": {
|
|
40680
|
+
const resourceUri = context.request.params?.uri;
|
|
40681
|
+
if (typeof resourceUri !== "string") return;
|
|
40682
|
+
let uri;
|
|
40683
|
+
try {
|
|
40684
|
+
uri = new URL(resourceUri);
|
|
40685
|
+
} catch {
|
|
40686
|
+
return;
|
|
40687
|
+
}
|
|
40688
|
+
const resource = this._registeredResources[uri.toString()];
|
|
40689
|
+
if (resource !== void 0) return resource.enabled ? resource.scopeChallenge?.(context) : void 0;
|
|
40690
|
+
for (const template of Object.values(this._registeredResourceTemplates)) if (template.resourceTemplate.uriTemplate.match(uri.toString())) return template.enabled ? template.scopeChallenge?.(context) : void 0;
|
|
40691
|
+
return;
|
|
40692
|
+
}
|
|
40693
|
+
case "prompts/get": {
|
|
40694
|
+
const promptName = context.request.params?.name;
|
|
40695
|
+
if (typeof promptName !== "string") return;
|
|
40696
|
+
const prompt = this._registeredPrompts[promptName];
|
|
40697
|
+
if (prompt === void 0 || !prompt.enabled) return;
|
|
40698
|
+
return prompt.scopeChallenge?.(context);
|
|
40699
|
+
}
|
|
40700
|
+
default:
|
|
40701
|
+
return;
|
|
40702
|
+
}
|
|
40703
|
+
};
|
|
40650
40704
|
_toolHandlersInitialized = false;
|
|
40651
40705
|
setToolRequestHandlers() {
|
|
40652
40706
|
if (this._toolHandlersInitialized) return;
|
|
@@ -40813,7 +40867,10 @@ var McpServer = class {
|
|
|
40813
40867
|
}
|
|
40814
40868
|
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
40815
40869
|
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
40816
|
-
if (variables)
|
|
40870
|
+
if (variables) {
|
|
40871
|
+
if (!template.enabled) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Resource template ${template.resourceTemplate.uriTemplate} disabled`);
|
|
40872
|
+
return attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
|
|
40873
|
+
}
|
|
40817
40874
|
}
|
|
40818
40875
|
throw new ResourceNotFoundError(request.params.uri);
|
|
40819
40876
|
});
|
|
@@ -40844,36 +40901,32 @@ var McpServer = class {
|
|
|
40844
40901
|
this._promptHandlersInitialized = true;
|
|
40845
40902
|
}
|
|
40846
40903
|
registerResource(name, uriOrTemplate, config2, readCallback) {
|
|
40847
|
-
const cacheHint = config2
|
|
40848
|
-
|
|
40849
|
-
if (cacheHint !== void 0) {
|
|
40850
|
-
assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
40851
|
-
const rest = { ...config2 };
|
|
40852
|
-
delete rest.cacheHint;
|
|
40853
|
-
metadata = rest;
|
|
40854
|
-
}
|
|
40904
|
+
const { cacheHint, scopeChallenge, ...resourceMetadata } = config2;
|
|
40905
|
+
const metadata = resourceMetadata;
|
|
40906
|
+
if (cacheHint !== void 0) assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
40855
40907
|
if (typeof uriOrTemplate === "string") {
|
|
40856
40908
|
if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
40857
|
-
const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, readCallback);
|
|
40909
|
+
const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
40858
40910
|
if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
|
|
40859
40911
|
this.setResourceRequestHandlers();
|
|
40860
40912
|
this.sendResourceListChanged();
|
|
40861
40913
|
return registeredResource;
|
|
40862
40914
|
} else {
|
|
40863
40915
|
if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
|
|
40864
|
-
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, readCallback);
|
|
40916
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
40865
40917
|
if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
|
|
40866
40918
|
this.setResourceRequestHandlers();
|
|
40867
40919
|
this.sendResourceListChanged();
|
|
40868
40920
|
return registeredResourceTemplate;
|
|
40869
40921
|
}
|
|
40870
40922
|
}
|
|
40871
|
-
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
40923
|
+
_createRegisteredResource(name, title, uri, metadata, scopeChallenge, readCallback) {
|
|
40872
40924
|
const registeredResource = {
|
|
40873
40925
|
name,
|
|
40874
40926
|
title,
|
|
40875
40927
|
metadata,
|
|
40876
40928
|
readCallback,
|
|
40929
|
+
scopeChallenge,
|
|
40877
40930
|
enabled: true,
|
|
40878
40931
|
disable: () => registeredResource.update({ enabled: false }),
|
|
40879
40932
|
enable: () => registeredResource.update({ enabled: true }),
|
|
@@ -40887,6 +40940,7 @@ var McpServer = class {
|
|
|
40887
40940
|
if (updates.title !== void 0) registeredResource.title = updates.title;
|
|
40888
40941
|
if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
|
|
40889
40942
|
if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
|
|
40943
|
+
if (updates.scopeChallenge !== void 0) registeredResource.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
40890
40944
|
if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
|
|
40891
40945
|
this.sendResourceListChanged();
|
|
40892
40946
|
}
|
|
@@ -40894,12 +40948,13 @@ var McpServer = class {
|
|
|
40894
40948
|
this._registeredResources[uri] = registeredResource;
|
|
40895
40949
|
return registeredResource;
|
|
40896
40950
|
}
|
|
40897
|
-
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
40951
|
+
_createRegisteredResourceTemplate(name, title, template, metadata, scopeChallenge, readCallback) {
|
|
40898
40952
|
const registeredResourceTemplate = {
|
|
40899
40953
|
resourceTemplate: template,
|
|
40900
40954
|
title,
|
|
40901
40955
|
metadata,
|
|
40902
40956
|
readCallback,
|
|
40957
|
+
scopeChallenge,
|
|
40903
40958
|
enabled: true,
|
|
40904
40959
|
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
40905
40960
|
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
@@ -40913,6 +40968,7 @@ var McpServer = class {
|
|
|
40913
40968
|
if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
|
|
40914
40969
|
if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
|
|
40915
40970
|
if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
|
|
40971
|
+
if (updates.scopeChallenge !== void 0) registeredResourceTemplate.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
40916
40972
|
if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
|
|
40917
40973
|
this.sendResourceListChanged();
|
|
40918
40974
|
}
|
|
@@ -40922,7 +40978,7 @@ var McpServer = class {
|
|
|
40922
40978
|
if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
|
|
40923
40979
|
return registeredResourceTemplate;
|
|
40924
40980
|
}
|
|
40925
|
-
_createRegisteredPrompt(name, title, description, argsSchema7, callback, icons, _meta) {
|
|
40981
|
+
_createRegisteredPrompt(name, title, description, argsSchema7, callback, icons, scopeChallenge, _meta) {
|
|
40926
40982
|
let currentArgsSchema = argsSchema7;
|
|
40927
40983
|
let currentCallback = callback;
|
|
40928
40984
|
const registeredPrompt = {
|
|
@@ -40930,6 +40986,7 @@ var McpServer = class {
|
|
|
40930
40986
|
description,
|
|
40931
40987
|
argsSchema: argsSchema7,
|
|
40932
40988
|
icons,
|
|
40989
|
+
scopeChallenge,
|
|
40933
40990
|
_meta,
|
|
40934
40991
|
handler: createPromptHandler(name, argsSchema7, callback),
|
|
40935
40992
|
enabled: true,
|
|
@@ -40944,6 +41001,7 @@ var McpServer = class {
|
|
|
40944
41001
|
if (updates.title !== void 0) registeredPrompt.title = updates.title;
|
|
40945
41002
|
if (updates.description !== void 0) registeredPrompt.description = updates.description;
|
|
40946
41003
|
if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
|
|
41004
|
+
if (updates.scopeChallenge !== void 0) registeredPrompt.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
40947
41005
|
if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
|
|
40948
41006
|
let needsHandlerRegen = false;
|
|
40949
41007
|
if (updates.argsSchema !== void 0) {
|
|
@@ -40971,7 +41029,7 @@ var McpServer = class {
|
|
|
40971
41029
|
}
|
|
40972
41030
|
return registeredPrompt;
|
|
40973
41031
|
}
|
|
40974
|
-
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, _meta, handler) {
|
|
41032
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, scopeChallenge, _meta, handler) {
|
|
40975
41033
|
validateAndWarnToolName(name);
|
|
40976
41034
|
if (inputSchema !== void 0) try {
|
|
40977
41035
|
const json2 = standardSchemaToJsonSchema(inputSchema, "input");
|
|
@@ -40990,6 +41048,7 @@ var McpServer = class {
|
|
|
40990
41048
|
annotations,
|
|
40991
41049
|
icons,
|
|
40992
41050
|
execution,
|
|
41051
|
+
scopeChallenge,
|
|
40993
41052
|
_meta,
|
|
40994
41053
|
handler,
|
|
40995
41054
|
executor: createToolExecutor(inputSchema, handler),
|
|
@@ -41028,6 +41087,7 @@ var McpServer = class {
|
|
|
41028
41087
|
}
|
|
41029
41088
|
if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
|
|
41030
41089
|
if (updates.icons !== void 0) registeredTool.icons = updates.icons;
|
|
41090
|
+
if (updates.scopeChallenge !== void 0) registeredTool.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
41031
41091
|
if (updates._meta !== void 0) registeredTool._meta = updates._meta;
|
|
41032
41092
|
if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
|
|
41033
41093
|
this.sendToolListChanged();
|
|
@@ -41040,13 +41100,13 @@ var McpServer = class {
|
|
|
41040
41100
|
}
|
|
41041
41101
|
registerTool(name, config2, cb) {
|
|
41042
41102
|
if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
|
|
41043
|
-
const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config2;
|
|
41044
|
-
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, _meta, cb);
|
|
41103
|
+
const { title, description, inputSchema, outputSchema, annotations, icons, scopeChallenge, _meta } = config2;
|
|
41104
|
+
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, scopeChallenge, _meta, cb);
|
|
41045
41105
|
}
|
|
41046
41106
|
registerPrompt(name, config2, cb) {
|
|
41047
41107
|
if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
|
|
41048
|
-
const { title, description, argsSchema: argsSchema7, icons, _meta } = config2;
|
|
41049
|
-
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema7), cb, icons, _meta);
|
|
41108
|
+
const { title, description, argsSchema: argsSchema7, icons, scopeChallenge, _meta } = config2;
|
|
41109
|
+
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema7), cb, icons, scopeChallenge, _meta);
|
|
41050
41110
|
this.setPromptRequestHandlers();
|
|
41051
41111
|
this.sendPromptListChanged();
|
|
41052
41112
|
return registeredPrompt;
|
|
@@ -41158,6 +41218,7 @@ function unwrapOptionalSchema(schema) {
|
|
|
41158
41218
|
}
|
|
41159
41219
|
|
|
41160
41220
|
// node_modules/@modelcontextprotocol/server/dist/stdio.mjs
|
|
41221
|
+
var swallowsErrorsAfterClose = /* @__PURE__ */ Symbol("swallowsErrorsAfterClose");
|
|
41161
41222
|
var StdioServerTransport = class {
|
|
41162
41223
|
_readBuffer;
|
|
41163
41224
|
_started = false;
|
|
@@ -41184,18 +41245,27 @@ var StdioServerTransport = class {
|
|
|
41184
41245
|
this.onerror?.(error62);
|
|
41185
41246
|
};
|
|
41186
41247
|
_onstdouterror = (error62) => {
|
|
41248
|
+
if (this._closed) return;
|
|
41187
41249
|
this.onerror?.(error62);
|
|
41188
41250
|
this.close().catch(() => {
|
|
41189
41251
|
});
|
|
41190
41252
|
};
|
|
41253
|
+
_onstdinclose = () => {
|
|
41254
|
+
this.close().catch(() => {
|
|
41255
|
+
});
|
|
41256
|
+
};
|
|
41191
41257
|
/**
|
|
41192
41258
|
* Starts listening for messages on `stdin`.
|
|
41193
41259
|
*/
|
|
41194
41260
|
async start() {
|
|
41195
41261
|
if (this._started) throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
41196
41262
|
this._started = true;
|
|
41263
|
+
for (const listener of this._stdout.listeners("error")) if (listener[swallowsErrorsAfterClose]) this._stdout.off("error", listener);
|
|
41264
|
+
if (this._stdin.readableEnded || this._stdin.destroyed) setImmediate(this._onstdinclose);
|
|
41197
41265
|
this._stdin.on("data", this._ondata);
|
|
41198
41266
|
this._stdin.on("error", this._onerror);
|
|
41267
|
+
this._stdin.on("end", this._onstdinclose);
|
|
41268
|
+
this._stdin.on("close", this._onstdinclose);
|
|
41199
41269
|
this._stdout.on("error", this._onstdouterror);
|
|
41200
41270
|
}
|
|
41201
41271
|
processReadBuffer() {
|
|
@@ -41212,7 +41282,9 @@ var StdioServerTransport = class {
|
|
|
41212
41282
|
this._closed = true;
|
|
41213
41283
|
this._stdin.off("data", this._ondata);
|
|
41214
41284
|
this._stdin.off("error", this._onerror);
|
|
41215
|
-
this.
|
|
41285
|
+
this._stdin.off("end", this._onstdinclose);
|
|
41286
|
+
this._stdin.off("close", this._onstdinclose);
|
|
41287
|
+
this._onstdouterror[swallowsErrorsAfterClose] = true;
|
|
41216
41288
|
if (this._stdin.listenerCount("data") === 0) this._stdin.pause();
|
|
41217
41289
|
this._readBuffer.clear();
|
|
41218
41290
|
this.onclose?.();
|
|
@@ -41489,6 +41561,7 @@ function serveStdio(factory, options = {}) {
|
|
|
41489
41561
|
return;
|
|
41490
41562
|
}
|
|
41491
41563
|
if (state.era === "modern" && await tryServeListen(message)) return;
|
|
41564
|
+
if (isTornDown()) return;
|
|
41492
41565
|
state.instance.channel.deliver(message);
|
|
41493
41566
|
return;
|
|
41494
41567
|
}
|
|
@@ -41555,6 +41628,7 @@ function serveStdio(factory, options = {}) {
|
|
|
41555
41628
|
};
|
|
41556
41629
|
}
|
|
41557
41630
|
if (await tryServeListen(message)) return;
|
|
41631
|
+
if (isTornDown()) return;
|
|
41558
41632
|
state.instance.channel.deliver(message, { classification: opening.classification });
|
|
41559
41633
|
return;
|
|
41560
41634
|
case "legacy": {
|
|
@@ -41641,6 +41715,9 @@ function toError(value) {
|
|
|
41641
41715
|
return value instanceof Error ? value : new Error(String(value));
|
|
41642
41716
|
}
|
|
41643
41717
|
|
|
41718
|
+
// node_modules/@modelcontextprotocol/server/dist/index.mjs
|
|
41719
|
+
var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
|
|
41720
|
+
|
|
41644
41721
|
// node_modules/@chrischall/mcp-utils/dist/errors/index.js
|
|
41645
41722
|
var DEFAULT_ERROR_MESSAGE_MAX = 500;
|
|
41646
41723
|
var McpToolError = class extends Error {
|
|
@@ -41657,11 +41734,12 @@ var McpToolError = class extends Error {
|
|
|
41657
41734
|
function createHelpfulError(message, opts) {
|
|
41658
41735
|
return new McpToolError(message, opts);
|
|
41659
41736
|
}
|
|
41737
|
+
var HEADER_NAME_RUN = "[a-z0-9_-]{0,40}";
|
|
41660
41738
|
var BEARER_RE = /(bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi;
|
|
41661
|
-
var JWT_RE =
|
|
41739
|
+
var JWT_RE = /(?<![A-Za-z0-9_-])[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{8,}(?![A-Za-z0-9_-])/g;
|
|
41662
41740
|
var BASIC_AUTH_RE = /(authorization\s*:\s*basic\s+)[A-Za-z0-9+/=_-]{6,}/gi;
|
|
41663
|
-
var SET_COOKIE_RE = /(\bset-cookie\s*:\s*)([
|
|
41664
|
-
var COOKIE_HEADER_RE = /((?<!set-)\bcookie\s*:\s*)((?:[
|
|
41741
|
+
var SET_COOKIE_RE = /(\bset-cookie\s*:\s*)([^=;,:\s]+)=[^;,\s]*/gi;
|
|
41742
|
+
var COOKIE_HEADER_RE = /((?<!set-)\bcookie\s*:\s*)((?:[^=;,:\s]+=[^;,\s]*)(?:;\s*[^=;,:\s]+=[^;,\s]*)*)/gi;
|
|
41665
41743
|
var API_KEY_RE = new RegExp([
|
|
41666
41744
|
"sk-[A-Za-z0-9_-]{20,}(?![A-Za-z0-9_-])",
|
|
41667
41745
|
// OpenAI / Anthropic (incl. sk-ant-…)
|
|
@@ -41676,10 +41754,10 @@ var API_KEY_RE = new RegExp([
|
|
|
41676
41754
|
"whsec_[A-Za-z0-9]{16,}\\b"
|
|
41677
41755
|
// webhook signing secret (Stripe-style)
|
|
41678
41756
|
].map((p) => `\\b${p}`).join("|"), "g");
|
|
41679
|
-
var QUERY_SECRET_RE =
|
|
41757
|
+
var QUERY_SECRET_RE = new RegExp(`([?&](?:(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|token|key|sig|(?:php|j)?sess(?:ion)?[_-]?id|sid|x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN})=)[^&#\\s"'<>\`]+`, "gi");
|
|
41680
41758
|
var OAUTH_CODE_RE = /([?&]code=)(?=[^&#\s"'<>`]{16,})[^&#\s"'<>`]+/gi;
|
|
41681
41759
|
var FORM_PASSWORD_RE = /((?:^|[\s,;:"'(\[{])(?:password|passwd)=)[^&#\s"'<>`]+/gim;
|
|
41682
|
-
var HEADER_SECRET_RE =
|
|
41760
|
+
var HEADER_SECRET_RE = new RegExp(`(\\b(?:x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN}|api[-_]?key)\\s*:\\s*)[^\\s,;"'<>\`]+`, "gi");
|
|
41683
41761
|
var AWS_SIGV4_RE = /([?&]X-Amz-(?:Signature|Security-Token|Credential)=)[^&#\s"'<>`]+/gi;
|
|
41684
41762
|
var JSON_SECRET_KEYS = [
|
|
41685
41763
|
"(?:access|refresh|id|auth|session|bearer|csrf|xsrf)[_-]?token",
|
|
@@ -41687,7 +41765,8 @@ var JSON_SECRET_KEYS = [
|
|
|
41687
41765
|
"api[_-]?secret",
|
|
41688
41766
|
"(?:x[_-])?api[_-]?key",
|
|
41689
41767
|
"private[_-]?key",
|
|
41690
|
-
|
|
41768
|
+
`x[_-]${HEADER_NAME_RUN}?(?:api[_-]?key|token|secret|auth)${HEADER_NAME_RUN}`,
|
|
41769
|
+
// bounded like HEADER_SECRET_RE
|
|
41691
41770
|
"(?:proxy-)?authorization",
|
|
41692
41771
|
"password",
|
|
41693
41772
|
"passwd",
|
|
@@ -41696,12 +41775,30 @@ var JSON_SECRET_KEYS = [
|
|
|
41696
41775
|
].join("|");
|
|
41697
41776
|
var JSON_SECRET_DQ_RE = new RegExp(`("(?:${JSON_SECRET_KEYS})"\\s*:\\s*")(?:[^"\\\\]|\\\\.)*(")`, "gi");
|
|
41698
41777
|
var JSON_SECRET_SQ_RE = new RegExp(`('(?:${JSON_SECRET_KEYS})'\\s*:\\s*')(?:[^'\\\\]|\\\\.)*(')`, "gi");
|
|
41778
|
+
var JSON_SECRET_NUM_RE = new RegExp(`(["'](?:${JSON_SECRET_KEYS})["']\\s*:\\s*)-?\\d+(?:\\.\\d+)?(?![\\d.])`, "gi");
|
|
41779
|
+
var JSON_COOKIE_DQ_RE = /("((?:set-)?cookie)"\s*:\s*)("(?:[^"\\]|\\.)*"|\[\s*"(?:[^"\\]|\\.)*"(?:\s*,\s*"(?:[^"\\]|\\.)*")*)/gi;
|
|
41780
|
+
var JSON_COOKIE_SQ_RE = /('((?:set-)?cookie)'\s*:\s*)('(?:[^'\\]|\\.)*'|\[\s*'(?:[^'\\]|\\.)*'(?:\s*,\s*'(?:[^'\\]|\\.)*')*)/gi;
|
|
41781
|
+
var DQ_STRING_RE = /"((?:[^"\\]|\\.)*)"/g;
|
|
41782
|
+
var SQ_STRING_RE = /'((?:[^'\\]|\\.)*)'/g;
|
|
41783
|
+
function redactJsonCookie(quote) {
|
|
41784
|
+
const stringRe = quote === '"' ? DQ_STRING_RE : SQ_STRING_RE;
|
|
41785
|
+
return (_m, prefix, key, value) => {
|
|
41786
|
+
const setCookie = key.toLowerCase() === "set-cookie";
|
|
41787
|
+
const redacted = value.replace(stringRe, (_s, body) => {
|
|
41788
|
+
const out = setCookie ? body.replace(/^(\s*[^=;]+)=[^;]*/, "$1=[REDACTED]") : body.replace(/=[^;]*/g, "=[REDACTED]");
|
|
41789
|
+
return `${quote}${out}${quote}`;
|
|
41790
|
+
});
|
|
41791
|
+
return `${prefix}${redacted}`;
|
|
41792
|
+
};
|
|
41793
|
+
}
|
|
41699
41794
|
function redactSecrets(text) {
|
|
41700
|
-
return text.replace(BEARER_RE, "$1[REDACTED]").replace(BASIC_AUTH_RE, "$1[REDACTED]").replace(SET_COOKIE_RE, "$1$2=[REDACTED]").replace(COOKIE_HEADER_RE, (_m, prefix, pairs) => `${prefix}${pairs.replace(/=[^;,\s]*/g, "=[REDACTED]")}`).replace(API_KEY_RE, "[REDACTED]").replace(HEADER_SECRET_RE, "$1[REDACTED]").replace(QUERY_SECRET_RE, "$1[REDACTED]").replace(OAUTH_CODE_RE, "$1[REDACTED]").replace(FORM_PASSWORD_RE, "$1[REDACTED]").replace(AWS_SIGV4_RE, "$1[REDACTED]").replace(JSON_SECRET_DQ_RE, "$1[REDACTED]$2").replace(JSON_SECRET_SQ_RE, "$1[REDACTED]$2").replace(JWT_RE, "[REDACTED]");
|
|
41795
|
+
return text.replace(BEARER_RE, "$1[REDACTED]").replace(BASIC_AUTH_RE, "$1[REDACTED]").replace(SET_COOKIE_RE, "$1$2=[REDACTED]").replace(COOKIE_HEADER_RE, (_m, prefix, pairs) => `${prefix}${pairs.replace(/=[^;,\s]*/g, "=[REDACTED]")}`).replace(API_KEY_RE, "[REDACTED]").replace(HEADER_SECRET_RE, "$1[REDACTED]").replace(QUERY_SECRET_RE, "$1[REDACTED]").replace(OAUTH_CODE_RE, "$1[REDACTED]").replace(FORM_PASSWORD_RE, "$1[REDACTED]").replace(AWS_SIGV4_RE, "$1[REDACTED]").replace(JSON_COOKIE_DQ_RE, redactJsonCookie('"')).replace(JSON_COOKIE_SQ_RE, redactJsonCookie("'")).replace(JSON_SECRET_DQ_RE, "$1[REDACTED]$2").replace(JSON_SECRET_SQ_RE, "$1[REDACTED]$2").replace(JSON_SECRET_NUM_RE, "$1[REDACTED]").replace(JWT_RE, "[REDACTED]");
|
|
41701
41796
|
}
|
|
41797
|
+
var ERROR_REDACTION_INPUT_MAX = 64 * 1024;
|
|
41702
41798
|
function truncateErrorMessage(text, max = DEFAULT_ERROR_MESSAGE_MAX) {
|
|
41703
41799
|
const str = text === null || text === void 0 ? "" : String(text);
|
|
41704
|
-
const
|
|
41800
|
+
const cap = Math.max(ERROR_REDACTION_INPUT_MAX, max);
|
|
41801
|
+
const redacted = redactSecrets(str.length > cap ? str.slice(0, cap) : str);
|
|
41705
41802
|
if (redacted.length <= max)
|
|
41706
41803
|
return redacted;
|
|
41707
41804
|
return `${redacted.slice(0, max)}\u2026 [truncated]`;
|
|
@@ -61463,6 +61560,83 @@ function errorResult(message) {
|
|
|
61463
61560
|
};
|
|
61464
61561
|
}
|
|
61465
61562
|
|
|
61563
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
|
|
61564
|
+
function createSpentTokenStore() {
|
|
61565
|
+
const spent = /* @__PURE__ */ new Map();
|
|
61566
|
+
return {
|
|
61567
|
+
has: (nonce) => spent.has(nonce),
|
|
61568
|
+
add: (nonce, exp) => {
|
|
61569
|
+
spent.set(nonce, exp);
|
|
61570
|
+
},
|
|
61571
|
+
prune: (now) => {
|
|
61572
|
+
for (const [nonce, exp] of spent)
|
|
61573
|
+
if (exp < now)
|
|
61574
|
+
spent.delete(nonce);
|
|
61575
|
+
},
|
|
61576
|
+
clear: () => spent.clear(),
|
|
61577
|
+
get size() {
|
|
61578
|
+
return spent.size;
|
|
61579
|
+
}
|
|
61580
|
+
};
|
|
61581
|
+
}
|
|
61582
|
+
var PROCESS_SPENT = createSpentTokenStore();
|
|
61583
|
+
var confirmTokenParam = external_exports.string().optional().describe(`ONLY for the two-step confirmation fallback (a client without MCP elicitation). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`);
|
|
61584
|
+
|
|
61585
|
+
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
61586
|
+
import { homedir } from "node:os";
|
|
61587
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
61588
|
+
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
61589
|
+
function readEnvVar(key, opts = {}) {
|
|
61590
|
+
const env = opts.env ?? process.env;
|
|
61591
|
+
const raw = env[key];
|
|
61592
|
+
if (typeof raw === "string") {
|
|
61593
|
+
const trimmed = raw.trim();
|
|
61594
|
+
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
61595
|
+
return trimmed;
|
|
61596
|
+
}
|
|
61597
|
+
}
|
|
61598
|
+
return opts.default;
|
|
61599
|
+
}
|
|
61600
|
+
var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
61601
|
+
var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
61602
|
+
function parseBoolEnv(key, opts = {}) {
|
|
61603
|
+
const fallback = opts.default ?? false;
|
|
61604
|
+
const raw = readEnvVar(key, { env: opts.env });
|
|
61605
|
+
if (raw === void 0)
|
|
61606
|
+
return fallback;
|
|
61607
|
+
const token = raw.toLowerCase();
|
|
61608
|
+
if (TRUE_TOKENS.has(token))
|
|
61609
|
+
return true;
|
|
61610
|
+
if (FALSE_TOKENS.has(token))
|
|
61611
|
+
return false;
|
|
61612
|
+
return fallback;
|
|
61613
|
+
}
|
|
61614
|
+
function expandPath(p) {
|
|
61615
|
+
let expanded = p;
|
|
61616
|
+
if (p === "~") {
|
|
61617
|
+
expanded = homedir();
|
|
61618
|
+
} else if (p.startsWith("~/")) {
|
|
61619
|
+
expanded = join(homedir(), p.slice(2));
|
|
61620
|
+
}
|
|
61621
|
+
return isAbsolute(expanded) ? expanded : resolve(expanded);
|
|
61622
|
+
}
|
|
61623
|
+
async function loadDotenvSafely(opts = {}) {
|
|
61624
|
+
try {
|
|
61625
|
+
const mod = await import(
|
|
61626
|
+
/* @vite-ignore */
|
|
61627
|
+
"dotenv"
|
|
61628
|
+
);
|
|
61629
|
+
const result = mod.config({
|
|
61630
|
+
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
61631
|
+
override: opts.override ?? false,
|
|
61632
|
+
quiet: true
|
|
61633
|
+
});
|
|
61634
|
+
return result.error === void 0;
|
|
61635
|
+
} catch {
|
|
61636
|
+
return false;
|
|
61637
|
+
}
|
|
61638
|
+
}
|
|
61639
|
+
|
|
61466
61640
|
// node_modules/@chrischall/mcp-utils/dist/server/index.js
|
|
61467
61641
|
var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
61468
61642
|
"2026-07-28",
|
|
@@ -61580,6 +61754,8 @@ function withGracefulShutdown(target, opts = {}) {
|
|
|
61580
61754
|
};
|
|
61581
61755
|
const handler = (signal) => {
|
|
61582
61756
|
if (shuttingDown) {
|
|
61757
|
+
if (signal === "stdin-eof")
|
|
61758
|
+
return;
|
|
61583
61759
|
if (Date.now() - firstSignalAt < repeatGraceMs)
|
|
61584
61760
|
return;
|
|
61585
61761
|
if (shouldExit) {
|
|
@@ -61615,6 +61791,10 @@ function withGracefulShutdown(target, opts = {}) {
|
|
|
61615
61791
|
};
|
|
61616
61792
|
process.on("SIGINT", () => handler("SIGINT"));
|
|
61617
61793
|
process.on("SIGTERM", () => handler("SIGTERM"));
|
|
61794
|
+
if (opts.stdin) {
|
|
61795
|
+
opts.stdin.once("end", () => handler("stdin-eof"));
|
|
61796
|
+
opts.stdin.once("close", () => handler("stdin-eof"));
|
|
61797
|
+
}
|
|
61618
61798
|
}
|
|
61619
61799
|
function runMcp(opts) {
|
|
61620
61800
|
if (opts.banner !== void 0) {
|
|
@@ -61633,66 +61813,12 @@ function runMcp(opts) {
|
|
|
61633
61813
|
});
|
|
61634
61814
|
const shutdown = opts.shutdown ?? true;
|
|
61635
61815
|
if (shutdown !== false) {
|
|
61636
|
-
|
|
61816
|
+
const stdinDefault = spec === "stdio" ? { stdin: process.stdin } : {};
|
|
61817
|
+
withGracefulShutdown(handle, { ...stdinDefault, ...shutdown === true ? {} : shutdown });
|
|
61637
61818
|
}
|
|
61638
61819
|
return handle;
|
|
61639
61820
|
}
|
|
61640
61821
|
|
|
61641
|
-
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
61642
|
-
import { homedir } from "node:os";
|
|
61643
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
61644
|
-
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
61645
|
-
function readEnvVar(key, opts = {}) {
|
|
61646
|
-
const env = opts.env ?? process.env;
|
|
61647
|
-
const raw = env[key];
|
|
61648
|
-
if (typeof raw === "string") {
|
|
61649
|
-
const trimmed = raw.trim();
|
|
61650
|
-
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
61651
|
-
return trimmed;
|
|
61652
|
-
}
|
|
61653
|
-
}
|
|
61654
|
-
return opts.default;
|
|
61655
|
-
}
|
|
61656
|
-
var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
61657
|
-
var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
61658
|
-
function parseBoolEnv(key, opts = {}) {
|
|
61659
|
-
const fallback = opts.default ?? false;
|
|
61660
|
-
const raw = readEnvVar(key, { env: opts.env });
|
|
61661
|
-
if (raw === void 0)
|
|
61662
|
-
return fallback;
|
|
61663
|
-
const token = raw.toLowerCase();
|
|
61664
|
-
if (TRUE_TOKENS.has(token))
|
|
61665
|
-
return true;
|
|
61666
|
-
if (FALSE_TOKENS.has(token))
|
|
61667
|
-
return false;
|
|
61668
|
-
return fallback;
|
|
61669
|
-
}
|
|
61670
|
-
function expandPath(p) {
|
|
61671
|
-
let expanded = p;
|
|
61672
|
-
if (p === "~") {
|
|
61673
|
-
expanded = homedir();
|
|
61674
|
-
} else if (p.startsWith("~/")) {
|
|
61675
|
-
expanded = join(homedir(), p.slice(2));
|
|
61676
|
-
}
|
|
61677
|
-
return isAbsolute(expanded) ? expanded : resolve(expanded);
|
|
61678
|
-
}
|
|
61679
|
-
async function loadDotenvSafely(opts = {}) {
|
|
61680
|
-
try {
|
|
61681
|
-
const mod = await import(
|
|
61682
|
-
/* @vite-ignore */
|
|
61683
|
-
"dotenv"
|
|
61684
|
-
);
|
|
61685
|
-
const result = mod.config({
|
|
61686
|
-
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
61687
|
-
override: opts.override ?? false,
|
|
61688
|
-
quiet: true
|
|
61689
|
-
});
|
|
61690
|
-
return result.error === void 0;
|
|
61691
|
-
} catch {
|
|
61692
|
-
return false;
|
|
61693
|
-
}
|
|
61694
|
-
}
|
|
61695
|
-
|
|
61696
61822
|
// node_modules/@chrischall/mcp-utils/dist/fs/confine.js
|
|
61697
61823
|
import { existsSync, realpathSync } from "node:fs";
|
|
61698
61824
|
import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
|
|
@@ -62186,6 +62312,30 @@ var KNOWN_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
|
62186
62312
|
"write_cookies"
|
|
62187
62313
|
]);
|
|
62188
62314
|
|
|
62315
|
+
// node_modules/@fetchproxy/protocol/dist/capability-availability.js
|
|
62316
|
+
var CAPABILITY_UNAVAILABLE_CODE = "capability_unavailable";
|
|
62317
|
+
var MAX_UNAVAILABLE_CAPABILITIES = 32;
|
|
62318
|
+
var MAX_CAPABILITY_NAME_LENGTH = 64;
|
|
62319
|
+
var UNSUPPORTED_CAPABILITY_REASON_PREFIX = "unsupported-capability:";
|
|
62320
|
+
function capabilityUnavailableMessage(capability, platform) {
|
|
62321
|
+
return `capability ${JSON.stringify(capability)} is not available in this browser (${platform})`;
|
|
62322
|
+
}
|
|
62323
|
+
var UNAVAILABLE_RE = /^capability "([^"]{1,64})" is not available in this browser(?: \(([^)]{1,32})\))?/;
|
|
62324
|
+
function parseCapabilityUnavailable(error62) {
|
|
62325
|
+
const m = UNAVAILABLE_RE.exec(error62);
|
|
62326
|
+
if (!m)
|
|
62327
|
+
return null;
|
|
62328
|
+
return { capability: m[1], platform: m[2] ?? null };
|
|
62329
|
+
}
|
|
62330
|
+
function parseUnsupportedCapabilityReason(reason) {
|
|
62331
|
+
if (!reason.startsWith(UNSUPPORTED_CAPABILITY_REASON_PREFIX))
|
|
62332
|
+
return null;
|
|
62333
|
+
const rest = reason.slice(UNSUPPORTED_CAPABILITY_REASON_PREFIX.length).replace(/\s*\(not available in this browser\)\s*$/, "").trim();
|
|
62334
|
+
if (rest === "")
|
|
62335
|
+
return [];
|
|
62336
|
+
return rest.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
62337
|
+
}
|
|
62338
|
+
|
|
62189
62339
|
// node_modules/@fetchproxy/protocol/dist/mcp-id.js
|
|
62190
62340
|
var ID_RE = /^([^:]+):([^:]+):([0-9a-f]{16})$/;
|
|
62191
62341
|
function generateMcpId(serverName, version2) {
|
|
@@ -62900,6 +63050,9 @@ function validateHello(raw) {
|
|
|
62900
63050
|
assertBase64(raw.sessionNonce, "hello.sessionNonce");
|
|
62901
63051
|
if (raw.accepts !== void 0)
|
|
62902
63052
|
assertAcceptsList(raw.accepts);
|
|
63053
|
+
if (raw.unavailableCapabilities !== void 0) {
|
|
63054
|
+
assertUnavailableCapabilities(raw.unavailableCapabilities);
|
|
63055
|
+
}
|
|
62903
63056
|
return raw;
|
|
62904
63057
|
}
|
|
62905
63058
|
throw new ProtocolError3(`hello.role: must be 'server' or 'extension', got ${String(role)}`);
|
|
@@ -62965,6 +63118,22 @@ function assertAcceptsList(accepts) {
|
|
|
62965
63118
|
}
|
|
62966
63119
|
}
|
|
62967
63120
|
}
|
|
63121
|
+
function assertUnavailableCapabilities(list) {
|
|
63122
|
+
const label = "hello.unavailableCapabilities";
|
|
63123
|
+
if (!Array.isArray(list))
|
|
63124
|
+
throw new ProtocolError3(`${label}: expected array`);
|
|
63125
|
+
if (list.length > MAX_UNAVAILABLE_CAPABILITIES) {
|
|
63126
|
+
throw new ProtocolError3(`${label}: at most ${MAX_UNAVAILABLE_CAPABILITIES} entries, got ${list.length}`);
|
|
63127
|
+
}
|
|
63128
|
+
for (const c of list) {
|
|
63129
|
+
if (typeof c !== "string") {
|
|
63130
|
+
throw new ProtocolError3(`${label}: entry must be string, got ${typeof c}`);
|
|
63131
|
+
}
|
|
63132
|
+
if (c.length < 1 || c.length > MAX_CAPABILITY_NAME_LENGTH) {
|
|
63133
|
+
throw new ProtocolError3(`${label}: entry must be 1-${MAX_CAPABILITY_NAME_LENGTH} characters, got ${c.length}`);
|
|
63134
|
+
}
|
|
63135
|
+
}
|
|
63136
|
+
}
|
|
62968
63137
|
function validatePeerGone(raw) {
|
|
62969
63138
|
assertString(raw.mcpId, "peer-gone.mcpId");
|
|
62970
63139
|
if (!isValidMcpId(raw.mcpId))
|
|
@@ -63440,6 +63609,8 @@ function validateInnerResponse(raw) {
|
|
|
63440
63609
|
}
|
|
63441
63610
|
if (raw.ok === false) {
|
|
63442
63611
|
assertString(raw.error, "inner.error");
|
|
63612
|
+
if (raw.code !== void 0)
|
|
63613
|
+
assertString(raw.code, "inner.code");
|
|
63443
63614
|
if (raw.op !== void 0) {
|
|
63444
63615
|
if (typeof raw.op !== "string" || !KNOWN_RESPONSE_OPS.has(raw.op)) {
|
|
63445
63616
|
throw new ProtocolError3(`inner.op: unknown response op ${JSON.stringify(raw.op)}`);
|
|
@@ -63535,6 +63706,38 @@ async function openEncryptedFrameDetailed(sessionKey, frame, direction) {
|
|
|
63535
63706
|
}
|
|
63536
63707
|
}
|
|
63537
63708
|
|
|
63709
|
+
// node_modules/@fetchproxy/server/dist/session-info.js
|
|
63710
|
+
function sessionInfoFromHello(hello) {
|
|
63711
|
+
const raw = hello.unavailableCapabilities;
|
|
63712
|
+
const known = /* @__PURE__ */ new Set();
|
|
63713
|
+
if (Array.isArray(raw)) {
|
|
63714
|
+
for (const c of raw) {
|
|
63715
|
+
if (typeof c === "string" && KNOWN_CAPABILITIES.has(c))
|
|
63716
|
+
known.add(c);
|
|
63717
|
+
}
|
|
63718
|
+
}
|
|
63719
|
+
return { platform: hello.platform, unavailableCapabilities: [...known].sort() };
|
|
63720
|
+
}
|
|
63721
|
+
function capabilitiesForRequest(inner) {
|
|
63722
|
+
if (inner.type !== "request")
|
|
63723
|
+
return [];
|
|
63724
|
+
if (inner.op === "graphql_query")
|
|
63725
|
+
return ["graphql"];
|
|
63726
|
+
if (inner.op === "fetch") {
|
|
63727
|
+
return inner.init.inPage === true ? ["fetch", "fetch_in_page"] : ["fetch"];
|
|
63728
|
+
}
|
|
63729
|
+
return [inner.op];
|
|
63730
|
+
}
|
|
63731
|
+
function unavailableCapabilityFor(inner, info) {
|
|
63732
|
+
if (!info || info.unavailableCapabilities.length === 0)
|
|
63733
|
+
return null;
|
|
63734
|
+
for (const c of capabilitiesForRequest(inner)) {
|
|
63735
|
+
if (info.unavailableCapabilities.includes(c))
|
|
63736
|
+
return c;
|
|
63737
|
+
}
|
|
63738
|
+
return null;
|
|
63739
|
+
}
|
|
63740
|
+
|
|
63538
63741
|
// node_modules/@fetchproxy/server/dist/election.js
|
|
63539
63742
|
import { createServer, Server as HttpServer } from "node:http";
|
|
63540
63743
|
var DEFAULT_BIND_TIMEOUT_MS = 5e3;
|
|
@@ -63780,7 +63983,7 @@ var FetchproxySessionNotReadyError = class extends Error {
|
|
|
63780
63983
|
hint;
|
|
63781
63984
|
constructor(info) {
|
|
63782
63985
|
const pairing = info.pairCode !== null && info.pairCode !== "";
|
|
63783
|
-
const hint = pairing ? `Open the
|
|
63986
|
+
const hint = pairing ? `Open the ContextMint Bridge extension popup and approve pair code ${info.pairCode} for "${info.mcpId}", then retry.` : `The extension is connected but hasn't confirmed a session for "${info.mcpId}" \u2014 sign in to the target site in that browser (and approve the requested scope if it changed), then retry.`;
|
|
63784
63987
|
super(`fetchproxy: ${pairing ? "pairing not yet approved" : "no confirmed browser session"} for "${info.mcpId}". ${hint}`);
|
|
63785
63988
|
this.name = "FetchproxySessionNotReadyError";
|
|
63786
63989
|
this.reason = pairing ? "pair-required" : "not-ready";
|
|
@@ -63793,15 +63996,35 @@ var FetchproxySessionNotReadyError = class extends Error {
|
|
|
63793
63996
|
var FetchproxyHelloRejectedError = class extends Error {
|
|
63794
63997
|
mcpId;
|
|
63795
63998
|
reason;
|
|
63999
|
+
/**
|
|
64000
|
+
* #418: when the reason is `unsupported-capability: a, b (not available in
|
|
64001
|
+
* this browser)` — every capability this MCP declared is one the browser
|
|
64002
|
+
* cannot serve — those capabilities, parsed out of it. Empty otherwise.
|
|
64003
|
+
*/
|
|
64004
|
+
unavailableCapabilities;
|
|
64005
|
+
/** #418: the refusing browser's platform, when this bridge knew it. */
|
|
64006
|
+
platform;
|
|
64007
|
+
/**
|
|
64008
|
+
* #418: the remedy, when the reason is one this package knows how to
|
|
64009
|
+
* explain — today only `unsupported-capability`, which blames the browser
|
|
64010
|
+
* rather than the MCP. `null` otherwise.
|
|
64011
|
+
*/
|
|
64012
|
+
hint;
|
|
63796
64013
|
constructor(info) {
|
|
63797
|
-
|
|
64014
|
+
const unavailable = parseUnsupportedCapabilityReason(info.reason);
|
|
64015
|
+
const platform = info.platform ?? null;
|
|
64016
|
+
const hint = unavailable !== null ? `${platform ? `this browser (${platform})` : "this browser"} cannot serve any of the capabilities this MCP needs (${unavailable.join(", ")}) \u2014 ContextMint Bridge checked for the browser APIs and they are missing. Nothing is wrong with the MCP or your pairing, and updating will not change it: use this MCP from a browser that provides them (for example Chrome).` : null;
|
|
64017
|
+
super(`fetchproxy: the extension refused the connection for "${info.mcpId}": ${info.reason}. ` + (hint !== null ? hint : `This is the extension's own reason \u2014 it is not a timeout, and retrying unchanged will be refused the same way.`));
|
|
63798
64018
|
this.name = "FetchproxyHelloRejectedError";
|
|
63799
64019
|
this.mcpId = info.mcpId;
|
|
63800
64020
|
this.reason = info.reason;
|
|
64021
|
+
this.unavailableCapabilities = unavailable ?? [];
|
|
64022
|
+
this.platform = platform;
|
|
64023
|
+
this.hint = hint;
|
|
63801
64024
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
63802
64025
|
}
|
|
63803
64026
|
};
|
|
63804
|
-
var
|
|
64027
|
+
var MIN_SERVER_VERSION = "3.0.0";
|
|
63805
64028
|
var FetchproxyProtocolVersionError = class extends Error {
|
|
63806
64029
|
/** The protocol version this process speaks. */
|
|
63807
64030
|
ourVersion;
|
|
@@ -63809,7 +64032,7 @@ var FetchproxyProtocolVersionError = class extends Error {
|
|
|
63809
64032
|
theirVersion;
|
|
63810
64033
|
peer;
|
|
63811
64034
|
constructor(info) {
|
|
63812
|
-
const far = info.peer === "extension" ? `the attached browser extension speaks ${info.theirVersion} \u2014 update
|
|
64035
|
+
const far = info.peer === "extension" ? `the attached browser extension speaks ${info.theirVersion} \u2014 update ContextMint Bridge to a release that speaks fetchproxy protocol ${info.ourVersion}` : `the MCP holding the bridge port speaks ${info.theirVersion} \u2014 upgrade @fetchproxy/server to ${MIN_SERVER_VERSION} or later in that MCP`;
|
|
63813
64036
|
super(`protocol version mismatch: this MCP speaks fetchproxy protocol ${info.ourVersion}, ${far}`);
|
|
63814
64037
|
this.name = "FetchproxyProtocolVersionError";
|
|
63815
64038
|
this.ourVersion = info.ourVersion;
|
|
@@ -63842,9 +64065,9 @@ async function awaitSessionReady(ready, opts) {
|
|
|
63842
64065
|
}
|
|
63843
64066
|
|
|
63844
64067
|
// node_modules/@fetchproxy/server/dist/extension-trust.js
|
|
63845
|
-
import { readFile as
|
|
64068
|
+
import { readFile as readFile3, writeFile as writeFile2, rename as rename2, unlink as unlink2, mkdir as mkdir2, chmod as chmod2, rm as rm2 } from "node:fs/promises";
|
|
63846
64069
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
63847
|
-
import { isAbsolute as isAbsolute4, join as
|
|
64070
|
+
import { isAbsolute as isAbsolute4, join as join4 } from "node:path";
|
|
63848
64071
|
|
|
63849
64072
|
// node_modules/@fetchproxy/server/dist/identity.js
|
|
63850
64073
|
import { readFile, readdir, writeFile, mkdir, chmod, rename, rm, unlink, link, lstat } from "node:fs/promises";
|
|
@@ -63945,6 +64168,7 @@ async function loadOrCreateIdentity(serverName, dir = defaultIdentityDir()) {
|
|
|
63945
64168
|
throw e;
|
|
63946
64169
|
}
|
|
63947
64170
|
let unreadable = null;
|
|
64171
|
+
let recovered = false;
|
|
63948
64172
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
63949
64173
|
const id = await generateIdentity();
|
|
63950
64174
|
if (await publishIdentityIfAbsent(dir, serverName, id))
|
|
@@ -63958,6 +64182,11 @@ async function loadOrCreateIdentity(serverName, dir = defaultIdentityDir()) {
|
|
|
63958
64182
|
if (!(e instanceof SyntaxError))
|
|
63959
64183
|
throw e;
|
|
63960
64184
|
unreadable = e;
|
|
64185
|
+
if (!recovered && await removeAbandonedIdentity(path)) {
|
|
64186
|
+
recovered = true;
|
|
64187
|
+
attempt--;
|
|
64188
|
+
continue;
|
|
64189
|
+
}
|
|
63961
64190
|
await new Promise((r) => setTimeout(r, 20 * (attempt + 1)));
|
|
63962
64191
|
}
|
|
63963
64192
|
}
|
|
@@ -63999,6 +64228,192 @@ async function publishIdentityIfAbsent(dir, serverName, id) {
|
|
|
63999
64228
|
await rm(tmp, { force: true });
|
|
64000
64229
|
}
|
|
64001
64230
|
}
|
|
64231
|
+
var ABANDONED_IDENTITY_MS = 5e3;
|
|
64232
|
+
var RECOVERY_LOCK_STALE_MS = 3e4;
|
|
64233
|
+
function looksAbandoned(text) {
|
|
64234
|
+
const t = text.trim();
|
|
64235
|
+
return t === "" || t.startsWith("{") && !t.endsWith("}");
|
|
64236
|
+
}
|
|
64237
|
+
function sameFile(a, b) {
|
|
64238
|
+
return a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs;
|
|
64239
|
+
}
|
|
64240
|
+
async function takeRecoveryLock(lock) {
|
|
64241
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
64242
|
+
try {
|
|
64243
|
+
await writeFile(lock, `${process.pid}
|
|
64244
|
+
`, { mode: 384, flag: "wx" });
|
|
64245
|
+
return await lstat(lock);
|
|
64246
|
+
} catch (e) {
|
|
64247
|
+
if (e.code !== "EEXIST")
|
|
64248
|
+
return null;
|
|
64249
|
+
const st = await lstat(lock).catch(() => null);
|
|
64250
|
+
if (st === null)
|
|
64251
|
+
continue;
|
|
64252
|
+
if (Date.now() - st.mtimeMs < RECOVERY_LOCK_STALE_MS)
|
|
64253
|
+
return null;
|
|
64254
|
+
const again = await lstat(lock).catch(() => null);
|
|
64255
|
+
if (again === null || !sameFile(st, again))
|
|
64256
|
+
continue;
|
|
64257
|
+
await unlink(lock).catch(() => void 0);
|
|
64258
|
+
}
|
|
64259
|
+
}
|
|
64260
|
+
return null;
|
|
64261
|
+
}
|
|
64262
|
+
async function removeAbandonedIdentity(path) {
|
|
64263
|
+
const lock = `${path}.recover.lock`;
|
|
64264
|
+
const held = await takeRecoveryLock(lock);
|
|
64265
|
+
if (held === null)
|
|
64266
|
+
return false;
|
|
64267
|
+
try {
|
|
64268
|
+
const before = await lstat(path);
|
|
64269
|
+
if (!before.isFile() || Date.now() - before.mtimeMs < ABANDONED_IDENTITY_MS)
|
|
64270
|
+
return false;
|
|
64271
|
+
if (!looksAbandoned(await readFile(path, "utf8")))
|
|
64272
|
+
return false;
|
|
64273
|
+
const now = await lstat(path);
|
|
64274
|
+
if (!sameFile(before, now))
|
|
64275
|
+
return false;
|
|
64276
|
+
await unlink(path);
|
|
64277
|
+
return true;
|
|
64278
|
+
} catch {
|
|
64279
|
+
return false;
|
|
64280
|
+
} finally {
|
|
64281
|
+
const st = await lstat(lock).catch(() => null);
|
|
64282
|
+
if (st !== null && sameFile(held, st))
|
|
64283
|
+
await unlink(lock).catch(() => void 0);
|
|
64284
|
+
}
|
|
64285
|
+
}
|
|
64286
|
+
|
|
64287
|
+
// node_modules/@fetchproxy/server/dist/extension-pins.js
|
|
64288
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
64289
|
+
import { join as join3 } from "node:path";
|
|
64290
|
+
var EXTENSION_PINS_FILE_VERSION = 1;
|
|
64291
|
+
var EXTENSION_PINS_ENV = "FETCHPROXY_EXTENSION_PINS";
|
|
64292
|
+
var ExtensionPinsError = class extends Error {
|
|
64293
|
+
code;
|
|
64294
|
+
constructor(code, message) {
|
|
64295
|
+
super(message);
|
|
64296
|
+
this.name = "ExtensionPinsError";
|
|
64297
|
+
this.code = code;
|
|
64298
|
+
}
|
|
64299
|
+
};
|
|
64300
|
+
function malformed(why) {
|
|
64301
|
+
return new ExtensionPinsError("EXTENSION_PINS_MALFORMED", `malformed extension pin set: ${why}`);
|
|
64302
|
+
}
|
|
64303
|
+
function isKey(x) {
|
|
64304
|
+
if (typeof x !== "string" || x === "")
|
|
64305
|
+
return false;
|
|
64306
|
+
let raw;
|
|
64307
|
+
try {
|
|
64308
|
+
raw = fromB64(x);
|
|
64309
|
+
} catch {
|
|
64310
|
+
return false;
|
|
64311
|
+
}
|
|
64312
|
+
return raw.length === 32 && toB64(raw) === x;
|
|
64313
|
+
}
|
|
64314
|
+
function parseExtensionPins(text) {
|
|
64315
|
+
let parsed;
|
|
64316
|
+
try {
|
|
64317
|
+
parsed = JSON.parse(text);
|
|
64318
|
+
} catch {
|
|
64319
|
+
throw malformed("not JSON");
|
|
64320
|
+
}
|
|
64321
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
64322
|
+
throw malformed("not an object");
|
|
64323
|
+
}
|
|
64324
|
+
const r = parsed;
|
|
64325
|
+
if (r.v !== EXTENSION_PINS_FILE_VERSION) {
|
|
64326
|
+
throw malformed(`"v" is not ${EXTENSION_PINS_FILE_VERSION}`);
|
|
64327
|
+
}
|
|
64328
|
+
if (r.managed !== true)
|
|
64329
|
+
throw malformed('"managed" is not true');
|
|
64330
|
+
if (r.managedBy !== void 0 && typeof r.managedBy !== "string") {
|
|
64331
|
+
throw malformed('"managedBy" is not a string');
|
|
64332
|
+
}
|
|
64333
|
+
if (!Array.isArray(r.extensions))
|
|
64334
|
+
throw malformed('"extensions" is not an array');
|
|
64335
|
+
const extensions = r.extensions.map((e, i) => {
|
|
64336
|
+
if (!e || typeof e !== "object" || Array.isArray(e)) {
|
|
64337
|
+
throw malformed(`extensions[${i}] is not an object`);
|
|
64338
|
+
}
|
|
64339
|
+
const x = e;
|
|
64340
|
+
if (!isKey(x.x25519Pub)) {
|
|
64341
|
+
throw malformed(`extensions[${i}].x25519Pub is not canonical base64 of 32 bytes`);
|
|
64342
|
+
}
|
|
64343
|
+
if (!isKey(x.ed25519Pub)) {
|
|
64344
|
+
throw malformed(`extensions[${i}].ed25519Pub is not canonical base64 of 32 bytes`);
|
|
64345
|
+
}
|
|
64346
|
+
if (x.label !== void 0 && typeof x.label !== "string") {
|
|
64347
|
+
throw malformed(`extensions[${i}].label is not a string`);
|
|
64348
|
+
}
|
|
64349
|
+
return {
|
|
64350
|
+
x25519Pub: x.x25519Pub,
|
|
64351
|
+
ed25519Pub: x.ed25519Pub,
|
|
64352
|
+
...x.label !== void 0 ? { label: x.label } : {}
|
|
64353
|
+
};
|
|
64354
|
+
});
|
|
64355
|
+
return {
|
|
64356
|
+
v: EXTENSION_PINS_FILE_VERSION,
|
|
64357
|
+
managed: true,
|
|
64358
|
+
...r.managedBy !== void 0 ? { managedBy: r.managedBy } : {},
|
|
64359
|
+
extensions
|
|
64360
|
+
};
|
|
64361
|
+
}
|
|
64362
|
+
function extensionPinsPath(serverName, trustDir) {
|
|
64363
|
+
return join3(trustDir, `${safeIdentityFileBase(serverName)}.extension-pins.json`);
|
|
64364
|
+
}
|
|
64365
|
+
async function readExtensionPinsAt(path) {
|
|
64366
|
+
let text;
|
|
64367
|
+
try {
|
|
64368
|
+
text = await readFile2(path, "utf8");
|
|
64369
|
+
} catch (e) {
|
|
64370
|
+
const code = e.code ?? "read failed";
|
|
64371
|
+
throw new ExtensionPinsError("EXTENSION_PINS_MISSING", `no managed extension pin set at ${path} (${code})`);
|
|
64372
|
+
}
|
|
64373
|
+
try {
|
|
64374
|
+
return parseExtensionPins(text);
|
|
64375
|
+
} catch (e) {
|
|
64376
|
+
const why = e instanceof ExtensionPinsError ? e.message : "malformed extension pin set";
|
|
64377
|
+
throw new ExtensionPinsError("EXTENSION_PINS_MALFORMED", `${why} at ${path}`);
|
|
64378
|
+
}
|
|
64379
|
+
}
|
|
64380
|
+
function decideManagedExtensionTrust(args) {
|
|
64381
|
+
const { set: set2, hello, serverName } = args;
|
|
64382
|
+
const listed = set2.extensions.some((e) => e.x25519Pub === hello.identityX25519Pub && e.ed25519Pub === hello.identityEd25519Pub);
|
|
64383
|
+
if (listed)
|
|
64384
|
+
return { decision: "pinned" };
|
|
64385
|
+
return {
|
|
64386
|
+
decision: "refused",
|
|
64387
|
+
code: "EXTENSION_NOT_PINNED",
|
|
64388
|
+
message: `[fetchproxy] ${serverName}: refusing an extension that is not in the host-managed pin set${args.location ? ` (${args.location})` : ""}. The host that runs this MCP decides which browsers it accepts; confirm this browser there.`
|
|
64389
|
+
};
|
|
64390
|
+
}
|
|
64391
|
+
async function evaluateManagedExtensionTrust(port, hello, serverName) {
|
|
64392
|
+
let set2;
|
|
64393
|
+
try {
|
|
64394
|
+
set2 = await port.read();
|
|
64395
|
+
} catch (e) {
|
|
64396
|
+
const code = e instanceof ExtensionPinsError ? e.code : "EXTENSION_PINS_MISSING";
|
|
64397
|
+
const detail = e instanceof ExtensionPinsError ? e.message : `could not read ${port.location}`;
|
|
64398
|
+
return {
|
|
64399
|
+
decision: "refused",
|
|
64400
|
+
code,
|
|
64401
|
+
message: `[fetchproxy] ${serverName}: ${code}: ${detail} \u2014 refusing every extension until the host that manages this MCP's pins writes a valid set.`
|
|
64402
|
+
};
|
|
64403
|
+
}
|
|
64404
|
+
return decideManagedExtensionTrust({ set: set2, hello, serverName, location: port.location });
|
|
64405
|
+
}
|
|
64406
|
+
function resolveExtensionPinsMode(explicit, env = process.env) {
|
|
64407
|
+
if (explicit === "managed")
|
|
64408
|
+
return "managed";
|
|
64409
|
+
const raw = env[EXTENSION_PINS_ENV];
|
|
64410
|
+
if (raw === void 0 || raw.trim() === "")
|
|
64411
|
+
return "first-use";
|
|
64412
|
+
if (raw === "managed")
|
|
64413
|
+
return "managed";
|
|
64414
|
+
console.warn(`[fetchproxy] ${EXTENSION_PINS_ENV}=${JSON.stringify(raw)} is not "managed" \u2014 treating it as managed anyway, because a set variable means a host manages this MCP's extension pins. Unset it for trust on first use.`);
|
|
64415
|
+
return "managed";
|
|
64416
|
+
}
|
|
64002
64417
|
|
|
64003
64418
|
// node_modules/@fetchproxy/server/dist/extension-trust.js
|
|
64004
64419
|
var TRUST_DIR_ENV = "FETCHPROXY_TRUST_DIR";
|
|
@@ -64022,6 +64437,22 @@ function defaultTrustDir() {
|
|
|
64022
64437
|
}
|
|
64023
64438
|
function fileExtensionTrust(args) {
|
|
64024
64439
|
const dir = resolveTrustDir(args.trustDir, args.dir);
|
|
64440
|
+
if (args.extensionPins === "managed") {
|
|
64441
|
+
const location = extensionPinsPath(args.serverName, dir);
|
|
64442
|
+
return {
|
|
64443
|
+
// Managed mode has no first-use pin: nothing to read, nothing to write,
|
|
64444
|
+
// and no operator override. `write` REJECTS rather than no-ops, so a
|
|
64445
|
+
// path that ever reached it would log the attempt instead of silently
|
|
64446
|
+
// pretending to have pinned.
|
|
64447
|
+
allowNew: false,
|
|
64448
|
+
location,
|
|
64449
|
+
read: async () => null,
|
|
64450
|
+
write: async () => {
|
|
64451
|
+
throw new Error(`refusing to write an extension pin: ${location} is host-managed and this MCP never pins on first use`);
|
|
64452
|
+
},
|
|
64453
|
+
managed: { location, read: () => readExtensionPinsAt(location) }
|
|
64454
|
+
};
|
|
64455
|
+
}
|
|
64025
64456
|
return {
|
|
64026
64457
|
allowNew: args.allowNew,
|
|
64027
64458
|
location: extensionTrustPath(args.serverName, dir),
|
|
@@ -64055,13 +64486,13 @@ function decideExtensionTrust(args) {
|
|
|
64055
64486
|
};
|
|
64056
64487
|
}
|
|
64057
64488
|
function extensionTrustPath(serverName, dir = defaultTrustDir()) {
|
|
64058
|
-
return
|
|
64489
|
+
return join4(dir, `${safeIdentityFileBase(serverName)}.extension-trust.json`);
|
|
64059
64490
|
}
|
|
64060
64491
|
function extensionTrustPathHint(serverName) {
|
|
64061
64492
|
try {
|
|
64062
64493
|
return extensionTrustPath(serverName);
|
|
64063
64494
|
} catch {
|
|
64064
|
-
return
|
|
64495
|
+
return join4(defaultTrustDir(), "<server-name>.extension-trust.json");
|
|
64065
64496
|
}
|
|
64066
64497
|
}
|
|
64067
64498
|
function isPin(x) {
|
|
@@ -64074,7 +64505,7 @@ async function readExtensionPin(serverName, dir = defaultTrustDir()) {
|
|
|
64074
64505
|
const path = extensionTrustPath(serverName, dir);
|
|
64075
64506
|
let raw;
|
|
64076
64507
|
try {
|
|
64077
|
-
raw = await
|
|
64508
|
+
raw = await readFile3(path, "utf8");
|
|
64078
64509
|
} catch (e) {
|
|
64079
64510
|
if (e.code === "ENOENT")
|
|
64080
64511
|
return null;
|
|
@@ -64247,6 +64678,7 @@ async function startHost(opts) {
|
|
|
64247
64678
|
return true;
|
|
64248
64679
|
}
|
|
64249
64680
|
let extensionHello = null;
|
|
64681
|
+
let ownSessionInfo = null;
|
|
64250
64682
|
let extensionClaim = null;
|
|
64251
64683
|
const pairCodeFor = async (hello, mint) => {
|
|
64252
64684
|
if (!mint)
|
|
@@ -64265,6 +64697,7 @@ async function startHost(opts) {
|
|
|
64265
64697
|
return;
|
|
64266
64698
|
console.warn(`[fetchproxy] ${opts.ownServerName}: ${OWN_DECRYPT_FAILURES_BEFORE_REHANDSHAKE} frames in a row from the extension failed authentication under this MCP's session key \u2014 re-handshaking this MCP's session (the extension stays connected).`);
|
|
64267
64699
|
ownSession = dropOwnSessionAndEphemeral();
|
|
64700
|
+
ownSessionInfo = null;
|
|
64268
64701
|
resetSessionPromise();
|
|
64269
64702
|
const mintedKeypair = await generateSessionKeypair();
|
|
64270
64703
|
const mintedHello = await buildServerHello({
|
|
@@ -64323,28 +64756,39 @@ async function startHost(opts) {
|
|
|
64323
64756
|
return;
|
|
64324
64757
|
}
|
|
64325
64758
|
extensionClaim = ws;
|
|
64326
|
-
|
|
64327
|
-
|
|
64328
|
-
|
|
64329
|
-
|
|
64330
|
-
|
|
64331
|
-
|
|
64332
|
-
|
|
64333
|
-
|
|
64334
|
-
|
|
64759
|
+
const managed = opts.extensionTrust.managed;
|
|
64760
|
+
let outcome;
|
|
64761
|
+
let refusalReason = "extension identity is not the pinned one";
|
|
64762
|
+
if (managed) {
|
|
64763
|
+
const decided = await evaluateManagedExtensionTrust(managed, frame, opts.ownServerName);
|
|
64764
|
+
outcome = decided;
|
|
64765
|
+
if (decided.decision === "refused") {
|
|
64766
|
+
refusalReason = decided.code === "EXTENSION_NOT_PINNED" ? "extension identity is not in the managed pin set" : "extension pin set unavailable";
|
|
64767
|
+
}
|
|
64768
|
+
} else {
|
|
64769
|
+
let pin;
|
|
64770
|
+
try {
|
|
64771
|
+
pin = await opts.extensionTrust.read();
|
|
64772
|
+
} catch (e) {
|
|
64773
|
+
console.error(`[fetchproxy] ${String(e)}`);
|
|
64774
|
+
if (extensionClaim === ws)
|
|
64775
|
+
extensionClaim = null;
|
|
64776
|
+
ws.close(1008, "extension pin unreadable");
|
|
64777
|
+
return;
|
|
64778
|
+
}
|
|
64779
|
+
outcome = decideExtensionTrust({
|
|
64780
|
+
pin,
|
|
64781
|
+
hello: frame,
|
|
64782
|
+
allowNew: opts.extensionTrust.allowNew,
|
|
64783
|
+
serverName: opts.ownServerName,
|
|
64784
|
+
location: opts.extensionTrust.location
|
|
64785
|
+
});
|
|
64335
64786
|
}
|
|
64336
|
-
const outcome = decideExtensionTrust({
|
|
64337
|
-
pin,
|
|
64338
|
-
hello: frame,
|
|
64339
|
-
allowNew: opts.extensionTrust.allowNew,
|
|
64340
|
-
serverName: opts.ownServerName,
|
|
64341
|
-
location: opts.extensionTrust.location
|
|
64342
|
-
});
|
|
64343
64787
|
if (outcome.decision === "refused") {
|
|
64344
64788
|
console.warn(outcome.message);
|
|
64345
64789
|
if (extensionClaim === ws)
|
|
64346
64790
|
extensionClaim = null;
|
|
64347
|
-
ws.close(1008,
|
|
64791
|
+
ws.close(1008, refusalReason);
|
|
64348
64792
|
return;
|
|
64349
64793
|
}
|
|
64350
64794
|
if (outcome.decision === "replace")
|
|
@@ -64439,8 +64883,9 @@ async function startHost(opts) {
|
|
|
64439
64883
|
console.warn("[fetchproxy] discarding a ready for a session ephemeral this host no longer holds (the extension reconnected while a hello was in flight)");
|
|
64440
64884
|
return;
|
|
64441
64885
|
}
|
|
64442
|
-
const
|
|
64443
|
-
const
|
|
64886
|
+
const verifiedHello = extensionHello;
|
|
64887
|
+
const extEdPub = fromB64(verifiedHello.identityEd25519Pub);
|
|
64888
|
+
const extNonce = fromB64(verifiedHello.sessionNonce);
|
|
64444
64889
|
const msg = readySignaturePayload(held.nonce, extNonce, fromB64(frame.extensionSessionPub), held.pub);
|
|
64445
64890
|
const sig = fromB64(frame.sessionSig);
|
|
64446
64891
|
let sigOk = false;
|
|
@@ -64473,6 +64918,7 @@ async function startHost(opts) {
|
|
|
64473
64918
|
if (extensionWs !== ws)
|
|
64474
64919
|
return;
|
|
64475
64920
|
ownSession = new SessionState(key);
|
|
64921
|
+
ownSessionInfo = sessionInfoFromHello(verifiedHello);
|
|
64476
64922
|
ownDecryptFailures = 0;
|
|
64477
64923
|
ownPendingPairCode = null;
|
|
64478
64924
|
resolveOwnSession(ownSession);
|
|
@@ -64543,7 +64989,11 @@ async function startHost(opts) {
|
|
|
64543
64989
|
}
|
|
64544
64990
|
if (frame.type === "hello-rejected" && identified === "extension") {
|
|
64545
64991
|
if (frame.mcpId === opts.ownMcpId) {
|
|
64546
|
-
rejectOwnSession(new FetchproxyHelloRejectedError({
|
|
64992
|
+
rejectOwnSession(new FetchproxyHelloRejectedError({
|
|
64993
|
+
mcpId: frame.mcpId,
|
|
64994
|
+
reason: frame.reason,
|
|
64995
|
+
platform: extensionHello?.platform ?? null
|
|
64996
|
+
}));
|
|
64547
64997
|
} else {
|
|
64548
64998
|
const slot = peers.get(frame.mcpId);
|
|
64549
64999
|
if (slot?.helloFrame.accepts?.includes("hello-rejected")) {
|
|
@@ -64589,6 +65039,7 @@ async function startHost(opts) {
|
|
|
64589
65039
|
rejectOwnSession(new Error("extension disconnected before ready"));
|
|
64590
65040
|
}
|
|
64591
65041
|
ownSession = dropOwnSessionAndEphemeral();
|
|
65042
|
+
ownSessionInfo = null;
|
|
64592
65043
|
ownDecryptFailures = 0;
|
|
64593
65044
|
ownPendingPairCode = null;
|
|
64594
65045
|
resetSessionPromise();
|
|
@@ -64635,6 +65086,7 @@ async function startHost(opts) {
|
|
|
64635
65086
|
});
|
|
64636
65087
|
if (!extensionWs)
|
|
64637
65088
|
throw new Error("host: no extension connected");
|
|
65089
|
+
opts.refuseOutbound?.(inner, ownSessionInfo);
|
|
64638
65090
|
const plaintext = encodeOutboundInnerFrame(opts.ownMcpId, inner);
|
|
64639
65091
|
const sealed = await sealInnerFrame(session.sessionKey, opts.ownMcpId, session.nextOutboundSeq(), plaintext, "s2e");
|
|
64640
65092
|
extensionWs.send(JSON.stringify(sealed));
|
|
@@ -64650,7 +65102,8 @@ async function startHost(opts) {
|
|
|
64650
65102
|
},
|
|
64651
65103
|
pendingPairCode: () => ownPendingPairCode,
|
|
64652
65104
|
extensionConnected: () => extensionWs !== null,
|
|
64653
|
-
sessionLinked: () => ownSession !== null
|
|
65105
|
+
sessionLinked: () => ownSession !== null,
|
|
65106
|
+
sessionInfo: () => ownSession !== null ? ownSessionInfo : null
|
|
64654
65107
|
};
|
|
64655
65108
|
}
|
|
64656
65109
|
|
|
@@ -64735,6 +65188,7 @@ async function startPeer(opts) {
|
|
|
64735
65188
|
const closeListeners = [];
|
|
64736
65189
|
const extensionDisconnectListeners = [];
|
|
64737
65190
|
let session = null;
|
|
65191
|
+
let sessionInfo = null;
|
|
64738
65192
|
let sessionEphemeral = null;
|
|
64739
65193
|
function dropSessionEphemeral() {
|
|
64740
65194
|
if (sessionEphemeral)
|
|
@@ -64800,6 +65254,15 @@ async function startPeer(opts) {
|
|
|
64800
65254
|
console.warn(`[fetchproxy] ${opts.serverName}: extension session signature invalid \u2014 refusing (the concentrator may be answering in the browser's place)`);
|
|
64801
65255
|
return null;
|
|
64802
65256
|
}
|
|
65257
|
+
const managed = opts.extensionTrust.managed;
|
|
65258
|
+
if (managed) {
|
|
65259
|
+
const decided = await evaluateManagedExtensionTrust(managed, hello2, opts.serverName);
|
|
65260
|
+
if (decided.decision === "refused") {
|
|
65261
|
+
console.warn(decided.message);
|
|
65262
|
+
return null;
|
|
65263
|
+
}
|
|
65264
|
+
return hello2;
|
|
65265
|
+
}
|
|
64803
65266
|
if (cachedPin === void 0) {
|
|
64804
65267
|
try {
|
|
64805
65268
|
cachedPin = await opts.extensionTrust.read();
|
|
@@ -64867,6 +65330,7 @@ async function startPeer(opts) {
|
|
|
64867
65330
|
extensionGone = true;
|
|
64868
65331
|
dropSessionEphemeral();
|
|
64869
65332
|
pendingPairCode = null;
|
|
65333
|
+
sessionInfo = null;
|
|
64870
65334
|
if (session !== null) {
|
|
64871
65335
|
session = null;
|
|
64872
65336
|
if (sessionPromiseSettled)
|
|
@@ -64899,6 +65363,7 @@ async function startPeer(opts) {
|
|
|
64899
65363
|
}
|
|
64900
65364
|
const isRenegotiation = session !== null;
|
|
64901
65365
|
session = new SessionState(sessionKey);
|
|
65366
|
+
sessionInfo = sessionInfoFromHello(authenticated);
|
|
64902
65367
|
extensionGone = false;
|
|
64903
65368
|
pendingPairCode = null;
|
|
64904
65369
|
if (isRenegotiation) {
|
|
@@ -64909,7 +65374,11 @@ async function startPeer(opts) {
|
|
|
64909
65374
|
return;
|
|
64910
65375
|
}
|
|
64911
65376
|
if (frame.type === "hello-rejected" && frame.mcpId === opts.mcpId) {
|
|
64912
|
-
rejectFirstReady(new FetchproxyHelloRejectedError({
|
|
65377
|
+
rejectFirstReady(new FetchproxyHelloRejectedError({
|
|
65378
|
+
mcpId: frame.mcpId,
|
|
65379
|
+
reason: frame.reason,
|
|
65380
|
+
platform: extensionHello?.platform ?? null
|
|
65381
|
+
}));
|
|
64913
65382
|
}
|
|
64914
65383
|
if (frame.type === "pair-pending" && frame.mcpId === opts.mcpId) {
|
|
64915
65384
|
const hello2 = extensionHello;
|
|
@@ -65009,6 +65478,7 @@ async function startPeer(opts) {
|
|
|
65009
65478
|
const s = session;
|
|
65010
65479
|
if (s === null)
|
|
65011
65480
|
throw new Error("peer: extension disconnected");
|
|
65481
|
+
opts.refuseOutbound?.(inner, sessionInfo);
|
|
65012
65482
|
const plaintext = encodeOutboundInnerFrame(opts.mcpId, inner);
|
|
65013
65483
|
const sealed = await sealInnerFrame(s.sessionKey, opts.mcpId, s.nextOutboundSeq(), plaintext, "s2e");
|
|
65014
65484
|
if (ws.readyState !== import_websocket.default.OPEN)
|
|
@@ -65027,6 +65497,7 @@ async function startPeer(opts) {
|
|
|
65027
65497
|
pendingPairCode: () => pendingPairCode,
|
|
65028
65498
|
extensionConnected: () => extensionHello !== null,
|
|
65029
65499
|
sessionLinked: () => session !== null && !extensionGone,
|
|
65500
|
+
sessionInfo: () => session !== null && !extensionGone ? sessionInfo : null,
|
|
65030
65501
|
onClose: (cb) => {
|
|
65031
65502
|
closeListeners.push(cb);
|
|
65032
65503
|
},
|
|
@@ -65039,7 +65510,9 @@ async function startPeer(opts) {
|
|
|
65039
65510
|
}
|
|
65040
65511
|
|
|
65041
65512
|
// node_modules/@fetchproxy/server/dist/error-kind.js
|
|
65042
|
-
function classifyFetchError(error62) {
|
|
65513
|
+
function classifyFetchError(error62, code) {
|
|
65514
|
+
if (code === CAPABILITY_UNAVAILABLE_CODE)
|
|
65515
|
+
return "capability_unavailable";
|
|
65043
65516
|
if (/^(in-page )?fetch threw:/.test(error62)) {
|
|
65044
65517
|
return "tab_fetch_failed";
|
|
65045
65518
|
}
|
|
@@ -65055,6 +65528,9 @@ function classifyFetchError(error62) {
|
|
|
65055
65528
|
if (/not in domains \[/.test(error62)) {
|
|
65056
65529
|
return "domain_denied";
|
|
65057
65530
|
}
|
|
65531
|
+
if (parseCapabilityUnavailable(error62) !== null) {
|
|
65532
|
+
return "capability_unavailable";
|
|
65533
|
+
}
|
|
65058
65534
|
if (/^capability .+ not granted/.test(error62)) {
|
|
65059
65535
|
return "capability_denied";
|
|
65060
65536
|
}
|
|
@@ -65133,7 +65609,7 @@ var FetchproxyBridgeDownError = class extends FetchproxyProtocolError {
|
|
|
65133
65609
|
const retryAttempted = args.retryAttempted ?? false;
|
|
65134
65610
|
const op = args.op ?? "fetch";
|
|
65135
65611
|
const retryClause = retryAttempted ? `Server already burned a one-shot lazy-revive retry; SW is still down. ` : `Server lazy-revive retry was disabled (bridgeReviveDelayMs unset/0). `;
|
|
65136
|
-
const hint = `
|
|
65612
|
+
const hint = `ContextMint Bridge's service worker is not responding ("${args.originalError}"). Chrome evicts extension service workers after ~30s idle by default. ${retryClause}Make sure a tab for this domain is open, fully loaded, and signed in (the bridge fetches through that tab) \u2014 then retry. If it keeps happening, reload the extension from chrome://extensions and reload the tab.`;
|
|
65137
65613
|
super(`fetchproxy bridge down during ${op}${args.url ? ` (${args.url})` : ""}. ${hint}`);
|
|
65138
65614
|
this.name = "FetchproxyBridgeDownError";
|
|
65139
65615
|
this.originalError = args.originalError;
|
|
@@ -65160,7 +65636,7 @@ var FetchproxyHintedError = class extends FetchproxyProtocolError {
|
|
|
65160
65636
|
};
|
|
65161
65637
|
var FetchproxyScopeError = class extends FetchproxyHintedError {
|
|
65162
65638
|
constructor(originalError) {
|
|
65163
|
-
super(originalError, "the declared scope changed since you paired, so the extension is refusing the request. Revoke this MCP in the
|
|
65639
|
+
super(originalError, "the declared scope changed since you paired, so the extension is refusing the request. Revoke this MCP in the ContextMint Bridge extension popup, then re-run \u2014 you will be asked to approve the new scope. This is not a version problem and does not need an update.");
|
|
65164
65640
|
this.name = "FetchproxyScopeError";
|
|
65165
65641
|
}
|
|
65166
65642
|
};
|
|
@@ -65182,6 +65658,19 @@ var FetchproxyWaitedError = class extends FetchproxyHintedError {
|
|
|
65182
65658
|
this.name = "FetchproxyWaitedError";
|
|
65183
65659
|
}
|
|
65184
65660
|
};
|
|
65661
|
+
var FetchproxyCapabilityUnavailableError = class extends FetchproxyHintedError {
|
|
65662
|
+
/** The capability the browser cannot serve (`graphql` for a `graphql_query`). */
|
|
65663
|
+
capability;
|
|
65664
|
+
/** The browser, when known (`'safari'`); `null` when the extension did not say. */
|
|
65665
|
+
platform;
|
|
65666
|
+
constructor(originalError, info) {
|
|
65667
|
+
const where = info.platform ? `this browser (${info.platform})` : "this browser";
|
|
65668
|
+
super(originalError, `${where} cannot serve the "${info.capability}" capability \u2014 ContextMint Bridge checked for the browser API it needs and it is missing. The rest of this MCP still works here. Nothing is wrong with the MCP's code or your pairing, and neither updating nor re-approving will change it: use this tool from a browser that provides the API (for example Chrome).`);
|
|
65669
|
+
this.name = "FetchproxyCapabilityUnavailableError";
|
|
65670
|
+
this.capability = info.capability;
|
|
65671
|
+
this.platform = info.platform;
|
|
65672
|
+
}
|
|
65673
|
+
};
|
|
65185
65674
|
function waitedHint(op) {
|
|
65186
65675
|
const tail = " This is not a version problem and does not need an update.";
|
|
65187
65676
|
if (op === "capture" || op === "capture_redirect") {
|
|
@@ -65195,7 +65684,15 @@ function waitedHint(op) {
|
|
|
65195
65684
|
var SCOPE_REJECTION = /not in declared/;
|
|
65196
65685
|
var NO_TAB_REJECTION = /no tab matching (?!.*(content script loaded|one is still opening))/;
|
|
65197
65686
|
var TAB_OPENING_REJECTION = /no tab matching .*one is still opening/;
|
|
65198
|
-
function protocolErrorFrom(error62, op) {
|
|
65687
|
+
function protocolErrorFrom(error62, op, response) {
|
|
65688
|
+
const unavailable = parseCapabilityUnavailable(error62);
|
|
65689
|
+
if (unavailable !== null || response?.code === CAPABILITY_UNAVAILABLE_CODE) {
|
|
65690
|
+
const fromOp = response?.op === "graphql_query" ? "graphql" : response?.op ?? "unknown";
|
|
65691
|
+
return new FetchproxyCapabilityUnavailableError(error62, {
|
|
65692
|
+
capability: unavailable?.capability ?? fromOp,
|
|
65693
|
+
platform: unavailable?.platform ?? null
|
|
65694
|
+
});
|
|
65695
|
+
}
|
|
65199
65696
|
if (error62 === "timeout")
|
|
65200
65697
|
return new FetchproxyWaitedError(error62, op);
|
|
65201
65698
|
if (SCOPE_REJECTION.test(error62))
|
|
@@ -65254,7 +65751,8 @@ var FetchproxyTimeoutError = class extends FetchproxyProtocolError {
|
|
|
65254
65751
|
constructor(args) {
|
|
65255
65752
|
const graceMs = args.graceMs ?? VERB_DEADLINE_GRACE_MS;
|
|
65256
65753
|
const callerChose = args.requestedTimeoutMs !== void 0 && args.timeoutMs === args.requestedTimeoutMs + graceMs;
|
|
65257
|
-
|
|
65754
|
+
const base = `fetchproxy: ${args.url} did not respond within ${args.timeoutMs}ms` + (callerChose ? ` \u2014 the ${args.requestedTimeoutMs}ms this call asked for, plus ${graceMs}ms for the reply to reach this server. The extension runs its own timer on the value you passed, so a window that is genuinely too short reports what did not happen rather than this.` : "");
|
|
65755
|
+
super(args.retrySafe === false ? withNotResentNote(base) : base);
|
|
65258
65756
|
this.name = "FetchproxyTimeoutError";
|
|
65259
65757
|
this.url = args.url;
|
|
65260
65758
|
this.timeoutMs = args.timeoutMs;
|
|
@@ -65266,6 +65764,10 @@ var FetchproxyTimeoutError = class extends FetchproxyProtocolError {
|
|
|
65266
65764
|
this.retrySafe = args.retrySafe ?? true;
|
|
65267
65765
|
}
|
|
65268
65766
|
};
|
|
65767
|
+
var TIMEOUT_NOT_RESENT_NOTE = "It was not re-sent because it may already have run in the browser \u2014 check before retrying.";
|
|
65768
|
+
function withNotResentNote(message) {
|
|
65769
|
+
return `${message}${message.endsWith(".") ? " " : ". "}${TIMEOUT_NOT_RESENT_NOTE}`;
|
|
65770
|
+
}
|
|
65269
65771
|
var SUBDOMAIN_LABEL_RE = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
|
|
65270
65772
|
function normalizeCookiePath(path) {
|
|
65271
65773
|
if (path === void 0 || path === "")
|
|
@@ -65525,6 +66027,7 @@ var FetchproxyServer = class {
|
|
|
65525
66027
|
identityDir: opts.identityDir,
|
|
65526
66028
|
trustDir: opts.trustDir,
|
|
65527
66029
|
allowNewExtensionIdentity: opts.allowNewExtensionIdentity,
|
|
66030
|
+
extensionPins: opts.extensionPins,
|
|
65528
66031
|
requireExtensionIdentity: opts.requireExtensionIdentity,
|
|
65529
66032
|
onPairCode: opts.onPairCode
|
|
65530
66033
|
};
|
|
@@ -65610,6 +66113,7 @@ var FetchproxyServer = class {
|
|
|
65610
66113
|
this.role = "host";
|
|
65611
66114
|
this.hostHandle = await startHost({
|
|
65612
66115
|
httpServer: el.server,
|
|
66116
|
+
refuseOutbound: (inner, info) => this.refuseIfUnavailable(inner, info),
|
|
65613
66117
|
ownIdentity: identity,
|
|
65614
66118
|
ownMcpId: mcpId,
|
|
65615
66119
|
ownServerName: this.opts.serverName,
|
|
@@ -65640,6 +66144,7 @@ var FetchproxyServer = class {
|
|
|
65640
66144
|
} else {
|
|
65641
66145
|
this.role = "peer";
|
|
65642
66146
|
this.peerHandle = await startPeer({
|
|
66147
|
+
refuseOutbound: (inner, info) => this.refuseIfUnavailable(inner, info),
|
|
65643
66148
|
host: this.opts.host,
|
|
65644
66149
|
port: this.opts.port,
|
|
65645
66150
|
identity,
|
|
@@ -65688,7 +66193,7 @@ var FetchproxyServer = class {
|
|
|
65688
66193
|
}
|
|
65689
66194
|
}
|
|
65690
66195
|
pairingErrorMessage(code) {
|
|
65691
|
-
return `fetchproxy transport error: pairing required for ${this.opts.serverName}. Tell the user to open the
|
|
66196
|
+
return `fetchproxy transport error: pairing required for ${this.opts.serverName}. Tell the user to open the ContextMint Bridge browser extension popup and approve the pair request. The pair code is: ${code} \u2014 display this code to the user so they can verify it matches.`;
|
|
65692
66197
|
}
|
|
65693
66198
|
/**
|
|
65694
66199
|
* Raw single-shot fetch through the bridge. Most callers should prefer
|
|
@@ -65818,13 +66323,28 @@ var FetchproxyServer = class {
|
|
|
65818
66323
|
* every one of them.
|
|
65819
66324
|
*/
|
|
65820
66325
|
extensionTrust() {
|
|
66326
|
+
const allowNew = allowNewExtensionIdentity(this.opts.allowNewExtensionIdentity);
|
|
66327
|
+
if (resolveExtensionPinsMode(this.opts.extensionPins) === "managed") {
|
|
66328
|
+
if (allowNew && !this.warnedAllowNewIgnored) {
|
|
66329
|
+
this.warnedAllowNewIgnored = true;
|
|
66330
|
+
console.warn(`[fetchproxy] ${this.opts.serverName}: ignoring ${TRUST_NEW_EXTENSION_ENV} / allowNewExtensionIdentity \u2014 this MCP's extension pins are host-managed (${EXTENSION_PINS_ENV}=managed), so only the host's pin set decides which browsers it accepts.`);
|
|
66331
|
+
}
|
|
66332
|
+
return fileExtensionTrust({
|
|
66333
|
+
serverName: this.opts.serverName,
|
|
66334
|
+
dir: this.opts.identityDir,
|
|
66335
|
+
trustDir: this.opts.trustDir,
|
|
66336
|
+
allowNew: false,
|
|
66337
|
+
extensionPins: "managed"
|
|
66338
|
+
});
|
|
66339
|
+
}
|
|
65821
66340
|
return fileExtensionTrust({
|
|
65822
66341
|
serverName: this.opts.serverName,
|
|
65823
66342
|
dir: this.opts.identityDir,
|
|
65824
66343
|
trustDir: this.opts.trustDir,
|
|
65825
|
-
allowNew
|
|
66344
|
+
allowNew
|
|
65826
66345
|
});
|
|
65827
66346
|
}
|
|
66347
|
+
warnedAllowNewIgnored = false;
|
|
65828
66348
|
noteActivityForKeepalive() {
|
|
65829
66349
|
const intervalMs = this.opts.keepAliveIntervalMs;
|
|
65830
66350
|
if (intervalMs <= 0)
|
|
@@ -65918,6 +66438,15 @@ var FetchproxyServer = class {
|
|
|
65918
66438
|
resendable: isRetrySafeOnTimeout(init.method, fetchOpts.retryOnTimeout)
|
|
65919
66439
|
});
|
|
65920
66440
|
} catch (err) {
|
|
66441
|
+
if (err instanceof FetchproxyCapabilityUnavailableError) {
|
|
66442
|
+
return {
|
|
66443
|
+
ok: false,
|
|
66444
|
+
error: err.originalError,
|
|
66445
|
+
kind: "capability_unavailable",
|
|
66446
|
+
retryAttempted: false,
|
|
66447
|
+
cause: err
|
|
66448
|
+
};
|
|
66449
|
+
}
|
|
65921
66450
|
return {
|
|
65922
66451
|
ok: false,
|
|
65923
66452
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -65938,7 +66467,8 @@ var FetchproxyServer = class {
|
|
|
65938
66467
|
timer = setTimeout(() => {
|
|
65939
66468
|
this.pending.delete(id);
|
|
65940
66469
|
const elapsedMs = Date.now() - start;
|
|
65941
|
-
const
|
|
66470
|
+
const base = `fetchproxy: ${init.url} did not respond within ${timeoutMs}ms`;
|
|
66471
|
+
const error62 = isRetrySafeOnTimeout(init.method, fetchOpts.retryOnTimeout) ? base : withNotResentNote(base);
|
|
65942
66472
|
resolve5({
|
|
65943
66473
|
ok: false,
|
|
65944
66474
|
error: error62,
|
|
@@ -66060,6 +66590,9 @@ var FetchproxyServer = class {
|
|
|
66060
66590
|
port: this.opts.port
|
|
66061
66591
|
});
|
|
66062
66592
|
}
|
|
66593
|
+
if (result.kind === "capability_unavailable") {
|
|
66594
|
+
return protocolErrorFrom(result.error, void 0, { code: CAPABILITY_UNAVAILABLE_CODE, op });
|
|
66595
|
+
}
|
|
66063
66596
|
return protocolErrorFrom(result.error);
|
|
66064
66597
|
}
|
|
66065
66598
|
/**
|
|
@@ -66126,6 +66659,9 @@ var FetchproxyServer = class {
|
|
|
66126
66659
|
if (result.kind === "session_not_ready" && result.cause instanceof Error) {
|
|
66127
66660
|
throw result.cause;
|
|
66128
66661
|
}
|
|
66662
|
+
if (result.kind === "capability_unavailable" && result.cause instanceof FetchproxyCapabilityUnavailableError) {
|
|
66663
|
+
throw result.cause;
|
|
66664
|
+
}
|
|
66129
66665
|
throw this._typedErrorFor(result, init.url, "fetch", result.retryAttempted ?? false, isRetrySafeOnTimeout(method, opts.retryOnTimeout));
|
|
66130
66666
|
}
|
|
66131
66667
|
const response = {
|
|
@@ -66308,7 +66844,9 @@ var FetchproxyServer = class {
|
|
|
66308
66844
|
session_state: health.session.state,
|
|
66309
66845
|
pending_pair_code: health.session.pairCode,
|
|
66310
66846
|
extension_connected: health.session.extensionConnected,
|
|
66311
|
-
last_extension_message_at: health.lastExtensionMessageAt
|
|
66847
|
+
last_extension_message_at: health.lastExtensionMessageAt,
|
|
66848
|
+
unavailable_capabilities: health.session.unavailableCapabilities,
|
|
66849
|
+
platform: health.session.platform
|
|
66312
66850
|
},
|
|
66313
66851
|
...error62 ? { error: error62 } : {}
|
|
66314
66852
|
};
|
|
@@ -66954,7 +67492,7 @@ var FetchproxyServer = class {
|
|
|
66954
67492
|
fetchCb({
|
|
66955
67493
|
ok: false,
|
|
66956
67494
|
error: inner.error,
|
|
66957
|
-
kind: classifyFetchError(inner.error),
|
|
67495
|
+
kind: classifyFetchError(inner.error, inner.code),
|
|
66958
67496
|
retryAttempted: false
|
|
66959
67497
|
});
|
|
66960
67498
|
}
|
|
@@ -66970,7 +67508,7 @@ var FetchproxyServer = class {
|
|
|
66970
67508
|
storageCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on storage awaiter`));
|
|
66971
67509
|
}
|
|
66972
67510
|
} else {
|
|
66973
|
-
storageCb.reject(protocolErrorFrom(inner.error));
|
|
67511
|
+
storageCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
66974
67512
|
}
|
|
66975
67513
|
return;
|
|
66976
67514
|
}
|
|
@@ -66984,7 +67522,7 @@ var FetchproxyServer = class {
|
|
|
66984
67522
|
captureCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on capture awaiter`));
|
|
66985
67523
|
}
|
|
66986
67524
|
} else {
|
|
66987
|
-
captureCb.reject(protocolErrorFrom(inner.error, "capture"));
|
|
67525
|
+
captureCb.reject(protocolErrorFrom(inner.error, "capture", inner));
|
|
66988
67526
|
}
|
|
66989
67527
|
return;
|
|
66990
67528
|
}
|
|
@@ -66998,7 +67536,7 @@ var FetchproxyServer = class {
|
|
|
66998
67536
|
redirectCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on capture_redirect awaiter`));
|
|
66999
67537
|
}
|
|
67000
67538
|
} else {
|
|
67001
|
-
redirectCb.reject(protocolErrorFrom(inner.error, "capture_redirect"));
|
|
67539
|
+
redirectCb.reject(protocolErrorFrom(inner.error, "capture_redirect", inner));
|
|
67002
67540
|
}
|
|
67003
67541
|
return;
|
|
67004
67542
|
}
|
|
@@ -67012,7 +67550,7 @@ var FetchproxyServer = class {
|
|
|
67012
67550
|
idbCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on read_indexed_db awaiter`));
|
|
67013
67551
|
}
|
|
67014
67552
|
} else {
|
|
67015
|
-
idbCb.reject(protocolErrorFrom(inner.error));
|
|
67553
|
+
idbCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
67016
67554
|
}
|
|
67017
67555
|
return;
|
|
67018
67556
|
}
|
|
@@ -67026,7 +67564,7 @@ var FetchproxyServer = class {
|
|
|
67026
67564
|
domListCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on read_dom_list awaiter`));
|
|
67027
67565
|
}
|
|
67028
67566
|
} else {
|
|
67029
|
-
domListCb.reject(protocolErrorFrom(inner.error));
|
|
67567
|
+
domListCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
67030
67568
|
}
|
|
67031
67569
|
return;
|
|
67032
67570
|
}
|
|
@@ -67040,7 +67578,7 @@ var FetchproxyServer = class {
|
|
|
67040
67578
|
downloadCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on download awaiter`));
|
|
67041
67579
|
}
|
|
67042
67580
|
} else {
|
|
67043
|
-
downloadCb.reject(protocolErrorFrom(inner.error, "download"));
|
|
67581
|
+
downloadCb.reject(protocolErrorFrom(inner.error, "download", inner));
|
|
67044
67582
|
}
|
|
67045
67583
|
return;
|
|
67046
67584
|
}
|
|
@@ -67054,7 +67592,7 @@ var FetchproxyServer = class {
|
|
|
67054
67592
|
graphqlCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on graphql_query awaiter`));
|
|
67055
67593
|
}
|
|
67056
67594
|
} else {
|
|
67057
|
-
graphqlCb.reject(protocolErrorFrom(inner.error));
|
|
67595
|
+
graphqlCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
67058
67596
|
}
|
|
67059
67597
|
return;
|
|
67060
67598
|
}
|
|
@@ -67064,7 +67602,7 @@ var FetchproxyServer = class {
|
|
|
67064
67602
|
if (inner.ok && inner.op === "write_cookies") {
|
|
67065
67603
|
writeCookiesCb.resolve([...inner.written]);
|
|
67066
67604
|
} else {
|
|
67067
|
-
writeCookiesCb.reject(
|
|
67605
|
+
writeCookiesCb.reject(inner.ok ? protocolErrorFrom("write_cookies response had the wrong op") : protocolErrorFrom(inner.error, void 0, inner));
|
|
67068
67606
|
}
|
|
67069
67607
|
return;
|
|
67070
67608
|
}
|
|
@@ -67254,11 +67792,38 @@ var FetchproxyServer = class {
|
|
|
67254
67792
|
const handle = this.hostHandle ?? this.peerHandle;
|
|
67255
67793
|
const pairCode = this.currentPendingPairCode();
|
|
67256
67794
|
if (!handle || this.role === null) {
|
|
67257
|
-
return {
|
|
67795
|
+
return {
|
|
67796
|
+
state: "not_listening",
|
|
67797
|
+
pairCode,
|
|
67798
|
+
extensionConnected: false,
|
|
67799
|
+
unavailableCapabilities: [],
|
|
67800
|
+
platform: null
|
|
67801
|
+
};
|
|
67258
67802
|
}
|
|
67803
|
+
const info = handle.sessionInfo?.() ?? null;
|
|
67259
67804
|
const extensionConnected = handle.extensionConnected();
|
|
67260
67805
|
const state = handle.sessionLinked() ? "linked" : pairCode !== null ? "pair_pending" : !extensionConnected ? "extension_disconnected" : "no_session";
|
|
67261
|
-
return {
|
|
67806
|
+
return {
|
|
67807
|
+
state,
|
|
67808
|
+
pairCode,
|
|
67809
|
+
extensionConnected,
|
|
67810
|
+
unavailableCapabilities: info ? [...info.unavailableCapabilities] : [],
|
|
67811
|
+
platform: info?.platform ?? null
|
|
67812
|
+
};
|
|
67813
|
+
}
|
|
67814
|
+
/**
|
|
67815
|
+
* #418: refuse, before a seq is claimed, a request whose capability the
|
|
67816
|
+
* extension said this browser cannot serve. Called by the host / peer
|
|
67817
|
+
* handle once the session is ready, so it judges against the list from the
|
|
67818
|
+
* hello that session was verified against. Advisory: the list is unsigned,
|
|
67819
|
+
* so it may only ever make this MCP refuse MORE — the extension still
|
|
67820
|
+
* enforces from its own runtime check for anything that gets through.
|
|
67821
|
+
*/
|
|
67822
|
+
refuseIfUnavailable(inner, info) {
|
|
67823
|
+
const cap = unavailableCapabilityFor(inner, info);
|
|
67824
|
+
if (cap === null || info === null)
|
|
67825
|
+
return;
|
|
67826
|
+
throw new FetchproxyCapabilityUnavailableError(capabilityUnavailableMessage(cap, info.platform), { capability: cap, platform: info.platform });
|
|
67262
67827
|
}
|
|
67263
67828
|
/**
|
|
67264
67829
|
* 0.5.2+: throw `FetchproxyProtocolError` with the actionable pair-code
|
|
@@ -67581,7 +68146,7 @@ function loadAccount(env = process.env) {
|
|
|
67581
68146
|
// package.json
|
|
67582
68147
|
var package_default = {
|
|
67583
68148
|
name: "canvas-parent-mcp",
|
|
67584
|
-
version: "2.1.
|
|
68149
|
+
version: "2.1.5",
|
|
67585
68150
|
mcpName: "io.github.chrischall/canvas-parent-mcp",
|
|
67586
68151
|
description: "Canvas LMS (Instructure) MCP server \u2014 student/observer read access with optional file download",
|
|
67587
68152
|
author: "Claude Code (AI) <https://www.anthropic.com/claude>",
|
|
@@ -67628,9 +68193,9 @@ var package_default = {
|
|
|
67628
68193
|
typecheck: "tsc -p tsconfig.json --noEmit"
|
|
67629
68194
|
},
|
|
67630
68195
|
dependencies: {
|
|
67631
|
-
"@chrischall/mcp-utils": "^2.
|
|
67632
|
-
"@fetchproxy/bootstrap": "^3.
|
|
67633
|
-
"@fetchproxy/server": "^3.
|
|
68196
|
+
"@chrischall/mcp-utils": "^2.8.0",
|
|
68197
|
+
"@fetchproxy/bootstrap": "^3.4.1",
|
|
68198
|
+
"@fetchproxy/server": "^3.4.1",
|
|
67634
68199
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
67635
68200
|
dotenv: "^18.0.0",
|
|
67636
68201
|
zod: "^4.6.5"
|
|
@@ -67684,7 +68249,7 @@ async function resolveAuth() {
|
|
|
67684
68249
|
};
|
|
67685
68250
|
}
|
|
67686
68251
|
throw new Error(
|
|
67687
|
-
"Missing Canvas auth config. Set one of: CANVAS_TOKEN (personal access token), CANVAS_USERNAME+CANVAS_PASSWORD (auto-login), all three of CANVAS_CLIENT_ID, CANVAS_CLIENT_SECRET, CANVAS_REFRESH_TOKEN (OAuth), or install the
|
|
68252
|
+
"Missing Canvas auth config. Set one of: CANVAS_TOKEN (personal access token), CANVAS_USERNAME+CANVAS_PASSWORD (auto-login), all three of CANVAS_CLIENT_ID, CANVAS_CLIENT_SECRET, CANVAS_REFRESH_TOKEN (OAuth), or install the ContextMint Bridge browser extension and sign into your Canvas instance (unset CANVAS_DISABLE_FETCHPROXY if it is set)."
|
|
67688
68253
|
);
|
|
67689
68254
|
}
|
|
67690
68255
|
var liftersByHost = /* @__PURE__ */ new Map();
|
|
@@ -67719,7 +68284,7 @@ async function liftBrowserCookie(declaredDomain, baseHost) {
|
|
|
67719
68284
|
const pseudoCreds = session.cookies["pseudonym_credentials"];
|
|
67720
68285
|
if (!canvasSession || !pseudoCreds) {
|
|
67721
68286
|
throw new Error(
|
|
67722
|
-
`required cookies not found on ${baseHost}. Sign into your Canvas instance in the browser (with the
|
|
68287
|
+
`required cookies not found on ${baseHost}. Sign into your Canvas instance in the browser (with the ContextMint Bridge extension installed) and retry.`
|
|
67723
68288
|
);
|
|
67724
68289
|
}
|
|
67725
68290
|
return `canvas_session=${canvasSession}; pseudonym_credentials=${pseudoCreds}`;
|
|
@@ -67727,7 +68292,7 @@ async function liftBrowserCookie(declaredDomain, baseHost) {
|
|
|
67727
68292
|
if (classifyBridgeError(e) === "bridge_down") {
|
|
67728
68293
|
const downErr = e;
|
|
67729
68294
|
throw new Error(
|
|
67730
|
-
`Canvas auth:
|
|
68295
|
+
`Canvas auth: ContextMint Bridge is down (extension service worker unreachable after retry). ${downErr.hint}`
|
|
67731
68296
|
);
|
|
67732
68297
|
}
|
|
67733
68298
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -67887,11 +68452,12 @@ function registerCredentialHealthcheckTool(args) {
|
|
|
67887
68452
|
}
|
|
67888
68453
|
|
|
67889
68454
|
// src/client.ts
|
|
67890
|
-
import {
|
|
68455
|
+
import { constants as fsConstants } from "fs";
|
|
68456
|
+
import { lstat as lstat2, open as open2, stat } from "fs/promises";
|
|
67891
68457
|
|
|
67892
68458
|
// node_modules/@chrischall/mcp-utils/dist/session/index.js
|
|
67893
68459
|
import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync, chmodSync, renameSync, unlinkSync } from "node:fs";
|
|
67894
|
-
import { dirname as dirname2, join as
|
|
68460
|
+
import { dirname as dirname2, join as join5, resolve as resolve3 } from "node:path";
|
|
67895
68461
|
import { homedir as homedir3 } from "node:os";
|
|
67896
68462
|
import { randomBytes as randomBytes3, createHmac } from "node:crypto";
|
|
67897
68463
|
function bindingDigest(secret, salt) {
|
|
@@ -67984,7 +68550,7 @@ function homeOf(env) {
|
|
|
67984
68550
|
}
|
|
67985
68551
|
function resolveStateDir(opts = {}) {
|
|
67986
68552
|
const env = opts.env;
|
|
67987
|
-
return
|
|
68553
|
+
return join5(readEnvVar("MCP_DATA_DIR", { env }) ?? homeOf(env), opts.subdir ?? "");
|
|
67988
68554
|
}
|
|
67989
68555
|
function resolveStateFile(opts) {
|
|
67990
68556
|
const override = opts.envVar !== void 0 ? readEnvVar(opts.envVar, { env: opts.env }) : void 0;
|
|
@@ -67992,13 +68558,13 @@ function resolveStateFile(opts) {
|
|
|
67992
68558
|
if (override === "~")
|
|
67993
68559
|
return homeOf(opts.env);
|
|
67994
68560
|
if (override.startsWith("~/"))
|
|
67995
|
-
return
|
|
68561
|
+
return join5(homeOf(opts.env), override.slice(2));
|
|
67996
68562
|
return resolve3(override);
|
|
67997
68563
|
}
|
|
67998
68564
|
const dirOpts = { env: opts.env };
|
|
67999
68565
|
if (opts.subdir !== void 0)
|
|
68000
68566
|
dirOpts.subdir = opts.subdir;
|
|
68001
|
-
return
|
|
68567
|
+
return join5(resolveStateDir(dirOpts), opts.fileName);
|
|
68002
68568
|
}
|
|
68003
68569
|
var TOKEN_REFRESH_SKEW_MS = 5 * 60 * 1e3;
|
|
68004
68570
|
function isPersistedCookieSession(raw) {
|
|
@@ -68288,7 +68854,7 @@ function reportCacheWriteFailure(err) {
|
|
|
68288
68854
|
}
|
|
68289
68855
|
|
|
68290
68856
|
// src/client.ts
|
|
68291
|
-
import { dirname as dirname3, isAbsolute as isAbsolute5, join as
|
|
68857
|
+
import { dirname as dirname3, isAbsolute as isAbsolute5, join as join6, resolve as resolve4 } from "path";
|
|
68292
68858
|
import { homedir as homedir4 } from "os";
|
|
68293
68859
|
|
|
68294
68860
|
// src/session-login.ts
|
|
@@ -68466,9 +69032,10 @@ var CanvasClient = class {
|
|
|
68466
69032
|
const dest = this.confineDestination(destinationPath);
|
|
68467
69033
|
let destStat = null;
|
|
68468
69034
|
try {
|
|
68469
|
-
destStat = await
|
|
69035
|
+
destStat = await lstat2(dest);
|
|
68470
69036
|
} catch {
|
|
68471
69037
|
}
|
|
69038
|
+
if (destStat?.isSymbolicLink()) throw new InvalidPathError(destinationPath, "is a symlink");
|
|
68472
69039
|
if (destStat?.isDirectory()) throw new InvalidPathError(destinationPath);
|
|
68473
69040
|
if (destStat && !opts.overwrite) throw new FileExistsError(destinationPath);
|
|
68474
69041
|
const parent = dirname3(dest);
|
|
@@ -68482,7 +69049,7 @@ var CanvasClient = class {
|
|
|
68482
69049
|
if (res.status === 404) throw new Error(`Canvas download 404 for ${path}`);
|
|
68483
69050
|
if (!res.ok) throw new Error(`Canvas download ${res.status} for ${path}`);
|
|
68484
69051
|
const buf = new Uint8Array(await res.arrayBuffer());
|
|
68485
|
-
await
|
|
69052
|
+
await writeConfined(dest, destinationPath, buf, opts.overwrite === true);
|
|
68486
69053
|
return {
|
|
68487
69054
|
path: dest,
|
|
68488
69055
|
bytes: buf.byteLength,
|
|
@@ -68495,7 +69062,7 @@ var CanvasClient = class {
|
|
|
68495
69062
|
* change needs no client rebuild.
|
|
68496
69063
|
*/
|
|
68497
69064
|
downloadRoot() {
|
|
68498
|
-
return expandPath(this.outputDir ?? readEnvVar("CANVAS_OUTPUT_DIR") ??
|
|
69065
|
+
return expandPath(this.outputDir ?? readEnvVar("CANVAS_OUTPUT_DIR") ?? join6(homedir4(), "Downloads"));
|
|
68499
69066
|
}
|
|
68500
69067
|
confineDestination(destinationPath) {
|
|
68501
69068
|
const root = this.downloadRoot();
|
|
@@ -68678,9 +69245,28 @@ var DownloadDestinationRejectedError = class extends Error {
|
|
|
68678
69245
|
path;
|
|
68679
69246
|
root;
|
|
68680
69247
|
};
|
|
69248
|
+
async function writeConfined(dest, requested, buf, overwrite) {
|
|
69249
|
+
const { O_WRONLY, O_CREAT, O_TRUNC, O_EXCL, O_NOFOLLOW } = fsConstants;
|
|
69250
|
+
const flags = O_WRONLY | O_CREAT | O_NOFOLLOW | (overwrite ? O_TRUNC : O_EXCL);
|
|
69251
|
+
let handle;
|
|
69252
|
+
try {
|
|
69253
|
+
handle = await open2(dest, flags, 384);
|
|
69254
|
+
} catch (e) {
|
|
69255
|
+
const code = e.code;
|
|
69256
|
+
if (code === "ELOOP") throw new InvalidPathError(requested, "is a symlink");
|
|
69257
|
+
if (code === "EEXIST") throw new FileExistsError(requested);
|
|
69258
|
+
if (code === "EISDIR") throw new InvalidPathError(requested);
|
|
69259
|
+
throw e;
|
|
69260
|
+
}
|
|
69261
|
+
try {
|
|
69262
|
+
await handle.writeFile(buf);
|
|
69263
|
+
} finally {
|
|
69264
|
+
await handle.close();
|
|
69265
|
+
}
|
|
69266
|
+
}
|
|
68681
69267
|
var InvalidPathError = class extends Error {
|
|
68682
|
-
constructor(path) {
|
|
68683
|
-
super(`InvalidPath: destinationPath
|
|
69268
|
+
constructor(path, reason = "must be a filename, not a directory") {
|
|
69269
|
+
super(`InvalidPath: destinationPath ${reason}: ${path}`);
|
|
68684
69270
|
this.path = path;
|
|
68685
69271
|
this.name = "InvalidPathError";
|
|
68686
69272
|
}
|
|
@@ -69041,12 +69627,13 @@ function registerConversationTools(server, client) {
|
|
|
69041
69627
|
return viewResponse(args.view, data);
|
|
69042
69628
|
});
|
|
69043
69629
|
server.registerTool("canvas_get_conversation", {
|
|
69044
|
-
description: "Get a full Canvas conversation thread with all messages.",
|
|
69630
|
+
description: "Get a full Canvas conversation thread with all messages. Read-only: does not mark the conversation as read.",
|
|
69045
69631
|
annotations: { readOnlyHint: true },
|
|
69046
69632
|
inputSchema: getArgs3
|
|
69047
69633
|
}, async (rawArgs) => {
|
|
69048
69634
|
const args = getArgs3.parse(rawArgs);
|
|
69049
69635
|
const path = buildPath(`/api/v1/conversations/${encodeURIComponent(args.id)}`, {
|
|
69636
|
+
auto_mark_as_read: false,
|
|
69050
69637
|
"include[]": ["participant_avatars"]
|
|
69051
69638
|
});
|
|
69052
69639
|
const data = await client.request(path);
|
|
@@ -69117,7 +69704,7 @@ function registerFileTools(server, client) {
|
|
|
69117
69704
|
|
|
69118
69705
|
// src/index.ts
|
|
69119
69706
|
var __dirname = dirname4(fileURLToPath(import.meta.url));
|
|
69120
|
-
await loadDotenvSafely({ path:
|
|
69707
|
+
await loadDotenvSafely({ path: join7(__dirname, "..", ".env"), override: false });
|
|
69121
69708
|
var resolved = null;
|
|
69122
69709
|
var configError = null;
|
|
69123
69710
|
try {
|
|
@@ -69127,7 +69714,7 @@ try {
|
|
|
69127
69714
|
}
|
|
69128
69715
|
await runMcp({
|
|
69129
69716
|
name: "canvas",
|
|
69130
|
-
version: "2.1.
|
|
69717
|
+
version: "2.1.5",
|
|
69131
69718
|
// x-release-please-version
|
|
69132
69719
|
tools: [
|
|
69133
69720
|
// Outside the `if (resolved)` on purpose: an unconfigured server must
|
|
@@ -69163,7 +69750,7 @@ await runMcp({
|
|
|
69163
69750
|
});
|
|
69164
69751
|
/*! Bundled license information:
|
|
69165
69752
|
|
|
69166
|
-
@modelcontextprotocol/server/dist/src-
|
|
69753
|
+
@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs:
|
|
69167
69754
|
(*!
|
|
69168
69755
|
* content-type
|
|
69169
69756
|
* Copyright(c) 2015 Douglas Christopher Wilson
|