@chrischall/microsoft-teams-mcp 0.2.2 → 0.2.4
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 +18 -6
- package/dist/bundle.js +812 -163
- package/dist/client.js +2 -2
- package/dist/tools/errors.js +11 -1
- package/dist/version.js +1 -1
- package/mint.yaml +1 -1
- package/package.json +4 -4
- package/server.json +2 -2
- package/skills/teams-fpx/SKILL.md +9 -5
package/dist/bundle.js
CHANGED
|
@@ -23449,7 +23449,7 @@ function date4(params) {
|
|
|
23449
23449
|
return _coercedDate(ZodDate, params);
|
|
23450
23450
|
}
|
|
23451
23451
|
|
|
23452
|
-
// node_modules/@modelcontextprotocol/core/dist/auth-
|
|
23452
|
+
// node_modules/@modelcontextprotocol/server/node_modules/@modelcontextprotocol/core/dist/auth-CGP0BDVq.mjs
|
|
23453
23453
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
23454
23454
|
var SUPPORTED_PROTOCOL_VERSIONS = [
|
|
23455
23455
|
LATEST_PROTOCOL_VERSION,
|
|
@@ -24286,7 +24286,8 @@ var OAuthMetadataSchema = looseObject({
|
|
|
24286
24286
|
introspection_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
|
|
24287
24287
|
code_challenge_methods_supported: array(string2()).optional(),
|
|
24288
24288
|
client_id_metadata_document_supported: boolean2().optional(),
|
|
24289
|
-
authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0)
|
|
24289
|
+
authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0),
|
|
24290
|
+
dpop_signing_alg_values_supported: array(string2()).optional()
|
|
24290
24291
|
});
|
|
24291
24292
|
var OpenIdProviderMetadataSchema = looseObject({
|
|
24292
24293
|
issuer: string2(),
|
|
@@ -24387,7 +24388,7 @@ var OAuthTokenRevocationRequestSchema = object({
|
|
|
24387
24388
|
token_type_hint: string2().optional()
|
|
24388
24389
|
}).strip();
|
|
24389
24390
|
|
|
24390
|
-
// node_modules/@modelcontextprotocol/server/dist/src-
|
|
24391
|
+
// node_modules/@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs
|
|
24391
24392
|
var BRANDS = /* @__PURE__ */ Symbol.for("mcp.sdk.errorBrands");
|
|
24392
24393
|
function stampErrorBrands(instance, ctor) {
|
|
24393
24394
|
const brands = /* @__PURE__ */ new Set();
|
|
@@ -24501,8 +24502,18 @@ var SdkError = class extends Error {
|
|
|
24501
24502
|
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)`");
|
|
24502
24503
|
return brandedHasInstance(this, value);
|
|
24503
24504
|
}
|
|
24504
|
-
|
|
24505
|
-
|
|
24505
|
+
/**
|
|
24506
|
+
* @param code - Stable string code identifying the failure ({@linkcode SdkErrorCode}).
|
|
24507
|
+
* @param message - Human-readable description.
|
|
24508
|
+
* @param data - Optional structured payload (for example the HTTP status carried by
|
|
24509
|
+
* {@linkcode SdkHttpError}). Opaque to the SDK: a `cause` key inside `data` is not
|
|
24510
|
+
* promoted to `Error.cause`.
|
|
24511
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error`. Pass the underlying
|
|
24512
|
+
* failure as `{ cause }` so it is reachable through the `Error.cause` chain that
|
|
24513
|
+
* loggers and error trackers walk.
|
|
24514
|
+
*/
|
|
24515
|
+
constructor(code, message, data, options) {
|
|
24516
|
+
super(message, options);
|
|
24506
24517
|
this.code = code;
|
|
24507
24518
|
this.data = data;
|
|
24508
24519
|
this.name = "SdkError";
|
|
@@ -24513,8 +24524,11 @@ var SdkHttpError = class extends SdkError {
|
|
|
24513
24524
|
static {
|
|
24514
24525
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
|
|
24515
24526
|
}
|
|
24516
|
-
|
|
24517
|
-
|
|
24527
|
+
/**
|
|
24528
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error` (see {@linkcode SdkError}).
|
|
24529
|
+
*/
|
|
24530
|
+
constructor(code, message, data, options) {
|
|
24531
|
+
super(code, message, data, options);
|
|
24518
24532
|
this.name = "SdkHttpError";
|
|
24519
24533
|
}
|
|
24520
24534
|
get status() {
|
|
@@ -27465,7 +27479,7 @@ var INBOUND_VALIDATION_LADDER = [
|
|
|
27465
27479
|
evaluatedAt: "pre-dispatch",
|
|
27466
27480
|
codes: [HEADER_MISMATCH_ERROR_CODE],
|
|
27467
27481
|
conformance: ["http-header-validation"],
|
|
27468
|
-
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."
|
|
27482
|
+
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."
|
|
27469
27483
|
},
|
|
27470
27484
|
{
|
|
27471
27485
|
rung: "client-capabilities",
|
|
@@ -28235,7 +28249,7 @@ var Protocol = class {
|
|
|
28235
28249
|
return this._requestHandlers.get(method);
|
|
28236
28250
|
}
|
|
28237
28251
|
async _oncancel(notification) {
|
|
28238
|
-
if (
|
|
28252
|
+
if (notification.params.requestId === void 0) return;
|
|
28239
28253
|
this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
|
|
28240
28254
|
}
|
|
28241
28255
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
@@ -28634,19 +28648,20 @@ var Protocol = class {
|
|
|
28634
28648
|
const cancel = (reason) => {
|
|
28635
28649
|
if (responseReceived) return;
|
|
28636
28650
|
this._progressHandlers.delete(messageId);
|
|
28637
|
-
if (requestAbort === void 0)
|
|
28638
|
-
|
|
28639
|
-
|
|
28640
|
-
|
|
28641
|
-
|
|
28642
|
-
|
|
28643
|
-
|
|
28644
|
-
|
|
28645
|
-
|
|
28646
|
-
|
|
28647
|
-
|
|
28648
|
-
|
|
28649
|
-
|
|
28651
|
+
if (requestAbort === void 0) {
|
|
28652
|
+
if (request.method !== "initialize") this._transport?.send(this._envelopeOutbound({
|
|
28653
|
+
jsonrpc: "2.0",
|
|
28654
|
+
method: "notifications/cancelled",
|
|
28655
|
+
params: {
|
|
28656
|
+
requestId: messageId,
|
|
28657
|
+
reason: String(reason)
|
|
28658
|
+
}
|
|
28659
|
+
}), {
|
|
28660
|
+
relatedRequestId,
|
|
28661
|
+
resumptionToken,
|
|
28662
|
+
onresumptiontoken
|
|
28663
|
+
}).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error62}`)));
|
|
28664
|
+
} else requestAbort.abort();
|
|
28650
28665
|
reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
|
|
28651
28666
|
};
|
|
28652
28667
|
this._responseHandlers.set(messageId, (response) => {
|
|
@@ -28726,7 +28741,7 @@ var Protocol = class {
|
|
|
28726
28741
|
jsonrpc: "2.0",
|
|
28727
28742
|
...notification
|
|
28728
28743
|
});
|
|
28729
|
-
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params &&
|
|
28744
|
+
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && options?.relatedRequestId === void 0) {
|
|
28730
28745
|
if (this._pendingDebouncedNotifications.has(notification.method)) return;
|
|
28731
28746
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
28732
28747
|
Promise.resolve().then(() => {
|
|
@@ -36029,7 +36044,7 @@ var Ajv = import_ajv.Ajv;
|
|
|
36029
36044
|
// node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
|
|
36030
36045
|
import process2 from "node:process";
|
|
36031
36046
|
|
|
36032
|
-
// node_modules/@modelcontextprotocol/server/dist/mcp-
|
|
36047
|
+
// node_modules/@modelcontextprotocol/server/dist/mcp-Dw2OlZ1f.mjs
|
|
36033
36048
|
var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
|
|
36034
36049
|
function isCompletable(schema) {
|
|
36035
36050
|
return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
|
|
@@ -36222,6 +36237,9 @@ function notificationToServerEvent(method, uri) {
|
|
|
36222
36237
|
};
|
|
36223
36238
|
}
|
|
36224
36239
|
}
|
|
36240
|
+
function supportsScopeChallengeResolver(transport) {
|
|
36241
|
+
return typeof transport === "object" && transport !== null && "setScopeChallengeResolver" in transport && typeof transport.setScopeChallengeResolver === "function";
|
|
36242
|
+
}
|
|
36225
36243
|
var DEFAULT_LEGACY_SHIM_MAX_ROUNDS = 8;
|
|
36226
36244
|
var DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS = 6e5;
|
|
36227
36245
|
function resolveLegacyShimOptions(options) {
|
|
@@ -37032,6 +37050,7 @@ var McpServer = class {
|
|
|
37032
37050
|
* ```
|
|
37033
37051
|
*/
|
|
37034
37052
|
async connect(transport) {
|
|
37053
|
+
if (supportsScopeChallengeResolver(transport)) transport.setScopeChallengeResolver((context) => this.resolveScopeChallenge(context));
|
|
37035
37054
|
return await this.server.connect(transport);
|
|
37036
37055
|
}
|
|
37037
37056
|
/**
|
|
@@ -37040,6 +37059,41 @@ var McpServer = class {
|
|
|
37040
37059
|
async close() {
|
|
37041
37060
|
await this.server.close();
|
|
37042
37061
|
}
|
|
37062
|
+
/** @internal */
|
|
37063
|
+
resolveScopeChallenge = (context) => {
|
|
37064
|
+
switch (context.request.method) {
|
|
37065
|
+
case "tools/call": {
|
|
37066
|
+
const toolName = context.request.params?.name;
|
|
37067
|
+
if (typeof toolName !== "string") return;
|
|
37068
|
+
const tool = this._registeredTools[toolName];
|
|
37069
|
+
if (tool === void 0 || !tool.enabled) return;
|
|
37070
|
+
return tool.scopeChallenge?.(context);
|
|
37071
|
+
}
|
|
37072
|
+
case "resources/read": {
|
|
37073
|
+
const resourceUri = context.request.params?.uri;
|
|
37074
|
+
if (typeof resourceUri !== "string") return;
|
|
37075
|
+
let uri;
|
|
37076
|
+
try {
|
|
37077
|
+
uri = new URL(resourceUri);
|
|
37078
|
+
} catch {
|
|
37079
|
+
return;
|
|
37080
|
+
}
|
|
37081
|
+
const resource = this._registeredResources[uri.toString()];
|
|
37082
|
+
if (resource !== void 0) return resource.enabled ? resource.scopeChallenge?.(context) : void 0;
|
|
37083
|
+
for (const template of Object.values(this._registeredResourceTemplates)) if (template.resourceTemplate.uriTemplate.match(uri.toString())) return template.enabled ? template.scopeChallenge?.(context) : void 0;
|
|
37084
|
+
return;
|
|
37085
|
+
}
|
|
37086
|
+
case "prompts/get": {
|
|
37087
|
+
const promptName = context.request.params?.name;
|
|
37088
|
+
if (typeof promptName !== "string") return;
|
|
37089
|
+
const prompt = this._registeredPrompts[promptName];
|
|
37090
|
+
if (prompt === void 0 || !prompt.enabled) return;
|
|
37091
|
+
return prompt.scopeChallenge?.(context);
|
|
37092
|
+
}
|
|
37093
|
+
default:
|
|
37094
|
+
return;
|
|
37095
|
+
}
|
|
37096
|
+
};
|
|
37043
37097
|
_toolHandlersInitialized = false;
|
|
37044
37098
|
setToolRequestHandlers() {
|
|
37045
37099
|
if (this._toolHandlersInitialized) return;
|
|
@@ -37206,7 +37260,10 @@ var McpServer = class {
|
|
|
37206
37260
|
}
|
|
37207
37261
|
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
37208
37262
|
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
37209
|
-
if (variables)
|
|
37263
|
+
if (variables) {
|
|
37264
|
+
if (!template.enabled) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Resource template ${template.resourceTemplate.uriTemplate} disabled`);
|
|
37265
|
+
return attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
|
|
37266
|
+
}
|
|
37210
37267
|
}
|
|
37211
37268
|
throw new ResourceNotFoundError(request.params.uri);
|
|
37212
37269
|
});
|
|
@@ -37237,36 +37294,32 @@ var McpServer = class {
|
|
|
37237
37294
|
this._promptHandlersInitialized = true;
|
|
37238
37295
|
}
|
|
37239
37296
|
registerResource(name, uriOrTemplate, config2, readCallback) {
|
|
37240
|
-
const cacheHint = config2
|
|
37241
|
-
|
|
37242
|
-
if (cacheHint !== void 0) {
|
|
37243
|
-
assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
37244
|
-
const rest = { ...config2 };
|
|
37245
|
-
delete rest.cacheHint;
|
|
37246
|
-
metadata = rest;
|
|
37247
|
-
}
|
|
37297
|
+
const { cacheHint, scopeChallenge, ...resourceMetadata } = config2;
|
|
37298
|
+
const metadata = resourceMetadata;
|
|
37299
|
+
if (cacheHint !== void 0) assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
37248
37300
|
if (typeof uriOrTemplate === "string") {
|
|
37249
37301
|
if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
37250
|
-
const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, readCallback);
|
|
37302
|
+
const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
37251
37303
|
if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
|
|
37252
37304
|
this.setResourceRequestHandlers();
|
|
37253
37305
|
this.sendResourceListChanged();
|
|
37254
37306
|
return registeredResource;
|
|
37255
37307
|
} else {
|
|
37256
37308
|
if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
|
|
37257
|
-
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, readCallback);
|
|
37309
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
37258
37310
|
if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
|
|
37259
37311
|
this.setResourceRequestHandlers();
|
|
37260
37312
|
this.sendResourceListChanged();
|
|
37261
37313
|
return registeredResourceTemplate;
|
|
37262
37314
|
}
|
|
37263
37315
|
}
|
|
37264
|
-
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
37316
|
+
_createRegisteredResource(name, title, uri, metadata, scopeChallenge, readCallback) {
|
|
37265
37317
|
const registeredResource = {
|
|
37266
37318
|
name,
|
|
37267
37319
|
title,
|
|
37268
37320
|
metadata,
|
|
37269
37321
|
readCallback,
|
|
37322
|
+
scopeChallenge,
|
|
37270
37323
|
enabled: true,
|
|
37271
37324
|
disable: () => registeredResource.update({ enabled: false }),
|
|
37272
37325
|
enable: () => registeredResource.update({ enabled: true }),
|
|
@@ -37280,6 +37333,7 @@ var McpServer = class {
|
|
|
37280
37333
|
if (updates.title !== void 0) registeredResource.title = updates.title;
|
|
37281
37334
|
if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
|
|
37282
37335
|
if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
|
|
37336
|
+
if (updates.scopeChallenge !== void 0) registeredResource.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
37283
37337
|
if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
|
|
37284
37338
|
this.sendResourceListChanged();
|
|
37285
37339
|
}
|
|
@@ -37287,12 +37341,13 @@ var McpServer = class {
|
|
|
37287
37341
|
this._registeredResources[uri] = registeredResource;
|
|
37288
37342
|
return registeredResource;
|
|
37289
37343
|
}
|
|
37290
|
-
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
37344
|
+
_createRegisteredResourceTemplate(name, title, template, metadata, scopeChallenge, readCallback) {
|
|
37291
37345
|
const registeredResourceTemplate = {
|
|
37292
37346
|
resourceTemplate: template,
|
|
37293
37347
|
title,
|
|
37294
37348
|
metadata,
|
|
37295
37349
|
readCallback,
|
|
37350
|
+
scopeChallenge,
|
|
37296
37351
|
enabled: true,
|
|
37297
37352
|
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
37298
37353
|
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
@@ -37306,6 +37361,7 @@ var McpServer = class {
|
|
|
37306
37361
|
if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
|
|
37307
37362
|
if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
|
|
37308
37363
|
if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
|
|
37364
|
+
if (updates.scopeChallenge !== void 0) registeredResourceTemplate.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
37309
37365
|
if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
|
|
37310
37366
|
this.sendResourceListChanged();
|
|
37311
37367
|
}
|
|
@@ -37315,7 +37371,7 @@ var McpServer = class {
|
|
|
37315
37371
|
if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
|
|
37316
37372
|
return registeredResourceTemplate;
|
|
37317
37373
|
}
|
|
37318
|
-
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, _meta) {
|
|
37374
|
+
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, scopeChallenge, _meta) {
|
|
37319
37375
|
let currentArgsSchema = argsSchema;
|
|
37320
37376
|
let currentCallback = callback;
|
|
37321
37377
|
const registeredPrompt = {
|
|
@@ -37323,6 +37379,7 @@ var McpServer = class {
|
|
|
37323
37379
|
description,
|
|
37324
37380
|
argsSchema,
|
|
37325
37381
|
icons,
|
|
37382
|
+
scopeChallenge,
|
|
37326
37383
|
_meta,
|
|
37327
37384
|
handler: createPromptHandler(name, argsSchema, callback),
|
|
37328
37385
|
enabled: true,
|
|
@@ -37337,6 +37394,7 @@ var McpServer = class {
|
|
|
37337
37394
|
if (updates.title !== void 0) registeredPrompt.title = updates.title;
|
|
37338
37395
|
if (updates.description !== void 0) registeredPrompt.description = updates.description;
|
|
37339
37396
|
if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
|
|
37397
|
+
if (updates.scopeChallenge !== void 0) registeredPrompt.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
37340
37398
|
if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
|
|
37341
37399
|
let needsHandlerRegen = false;
|
|
37342
37400
|
if (updates.argsSchema !== void 0) {
|
|
@@ -37364,7 +37422,7 @@ var McpServer = class {
|
|
|
37364
37422
|
}
|
|
37365
37423
|
return registeredPrompt;
|
|
37366
37424
|
}
|
|
37367
|
-
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, _meta, handler) {
|
|
37425
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, scopeChallenge, _meta, handler) {
|
|
37368
37426
|
validateAndWarnToolName(name);
|
|
37369
37427
|
if (inputSchema !== void 0) try {
|
|
37370
37428
|
const json2 = standardSchemaToJsonSchema(inputSchema, "input");
|
|
@@ -37383,6 +37441,7 @@ var McpServer = class {
|
|
|
37383
37441
|
annotations,
|
|
37384
37442
|
icons,
|
|
37385
37443
|
execution,
|
|
37444
|
+
scopeChallenge,
|
|
37386
37445
|
_meta,
|
|
37387
37446
|
handler,
|
|
37388
37447
|
executor: createToolExecutor(inputSchema, handler),
|
|
@@ -37421,6 +37480,7 @@ var McpServer = class {
|
|
|
37421
37480
|
}
|
|
37422
37481
|
if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
|
|
37423
37482
|
if (updates.icons !== void 0) registeredTool.icons = updates.icons;
|
|
37483
|
+
if (updates.scopeChallenge !== void 0) registeredTool.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
37424
37484
|
if (updates._meta !== void 0) registeredTool._meta = updates._meta;
|
|
37425
37485
|
if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
|
|
37426
37486
|
this.sendToolListChanged();
|
|
@@ -37433,13 +37493,13 @@ var McpServer = class {
|
|
|
37433
37493
|
}
|
|
37434
37494
|
registerTool(name, config2, cb) {
|
|
37435
37495
|
if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
|
|
37436
|
-
const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config2;
|
|
37437
|
-
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, _meta, cb);
|
|
37496
|
+
const { title, description, inputSchema, outputSchema, annotations, icons, scopeChallenge, _meta } = config2;
|
|
37497
|
+
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, scopeChallenge, _meta, cb);
|
|
37438
37498
|
}
|
|
37439
37499
|
registerPrompt(name, config2, cb) {
|
|
37440
37500
|
if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
|
|
37441
|
-
const { title, description, argsSchema, icons, _meta } = config2;
|
|
37442
|
-
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, _meta);
|
|
37501
|
+
const { title, description, argsSchema, icons, scopeChallenge, _meta } = config2;
|
|
37502
|
+
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, scopeChallenge, _meta);
|
|
37443
37503
|
this.setPromptRequestHandlers();
|
|
37444
37504
|
this.sendPromptListChanged();
|
|
37445
37505
|
return registeredPrompt;
|
|
@@ -37551,6 +37611,7 @@ function unwrapOptionalSchema(schema) {
|
|
|
37551
37611
|
}
|
|
37552
37612
|
|
|
37553
37613
|
// node_modules/@modelcontextprotocol/server/dist/stdio.mjs
|
|
37614
|
+
var swallowsErrorsAfterClose = /* @__PURE__ */ Symbol("swallowsErrorsAfterClose");
|
|
37554
37615
|
var StdioServerTransport = class {
|
|
37555
37616
|
_readBuffer;
|
|
37556
37617
|
_started = false;
|
|
@@ -37577,18 +37638,27 @@ var StdioServerTransport = class {
|
|
|
37577
37638
|
this.onerror?.(error62);
|
|
37578
37639
|
};
|
|
37579
37640
|
_onstdouterror = (error62) => {
|
|
37641
|
+
if (this._closed) return;
|
|
37580
37642
|
this.onerror?.(error62);
|
|
37581
37643
|
this.close().catch(() => {
|
|
37582
37644
|
});
|
|
37583
37645
|
};
|
|
37646
|
+
_onstdinclose = () => {
|
|
37647
|
+
this.close().catch(() => {
|
|
37648
|
+
});
|
|
37649
|
+
};
|
|
37584
37650
|
/**
|
|
37585
37651
|
* Starts listening for messages on `stdin`.
|
|
37586
37652
|
*/
|
|
37587
37653
|
async start() {
|
|
37588
37654
|
if (this._started) throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
37589
37655
|
this._started = true;
|
|
37656
|
+
for (const listener of this._stdout.listeners("error")) if (listener[swallowsErrorsAfterClose]) this._stdout.off("error", listener);
|
|
37657
|
+
if (this._stdin.readableEnded || this._stdin.destroyed) setImmediate(this._onstdinclose);
|
|
37590
37658
|
this._stdin.on("data", this._ondata);
|
|
37591
37659
|
this._stdin.on("error", this._onerror);
|
|
37660
|
+
this._stdin.on("end", this._onstdinclose);
|
|
37661
|
+
this._stdin.on("close", this._onstdinclose);
|
|
37592
37662
|
this._stdout.on("error", this._onstdouterror);
|
|
37593
37663
|
}
|
|
37594
37664
|
processReadBuffer() {
|
|
@@ -37605,7 +37675,9 @@ var StdioServerTransport = class {
|
|
|
37605
37675
|
this._closed = true;
|
|
37606
37676
|
this._stdin.off("data", this._ondata);
|
|
37607
37677
|
this._stdin.off("error", this._onerror);
|
|
37608
|
-
this.
|
|
37678
|
+
this._stdin.off("end", this._onstdinclose);
|
|
37679
|
+
this._stdin.off("close", this._onstdinclose);
|
|
37680
|
+
this._onstdouterror[swallowsErrorsAfterClose] = true;
|
|
37609
37681
|
if (this._stdin.listenerCount("data") === 0) this._stdin.pause();
|
|
37610
37682
|
this._readBuffer.clear();
|
|
37611
37683
|
this.onclose?.();
|
|
@@ -37882,6 +37954,7 @@ function serveStdio(factory, options = {}) {
|
|
|
37882
37954
|
return;
|
|
37883
37955
|
}
|
|
37884
37956
|
if (state.era === "modern" && await tryServeListen(message)) return;
|
|
37957
|
+
if (isTornDown()) return;
|
|
37885
37958
|
state.instance.channel.deliver(message);
|
|
37886
37959
|
return;
|
|
37887
37960
|
}
|
|
@@ -37948,6 +38021,7 @@ function serveStdio(factory, options = {}) {
|
|
|
37948
38021
|
};
|
|
37949
38022
|
}
|
|
37950
38023
|
if (await tryServeListen(message)) return;
|
|
38024
|
+
if (isTornDown()) return;
|
|
37951
38025
|
state.instance.channel.deliver(message, { classification: opening.classification });
|
|
37952
38026
|
return;
|
|
37953
38027
|
case "legacy": {
|
|
@@ -38034,6 +38108,9 @@ function toError(value) {
|
|
|
38034
38108
|
return value instanceof Error ? value : new Error(String(value));
|
|
38035
38109
|
}
|
|
38036
38110
|
|
|
38111
|
+
// node_modules/@modelcontextprotocol/server/dist/index.mjs
|
|
38112
|
+
var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
|
|
38113
|
+
|
|
38037
38114
|
// node_modules/@chrischall/mcp-utils/dist/errors/index.js
|
|
38038
38115
|
var DEFAULT_ERROR_MESSAGE_MAX = 500;
|
|
38039
38116
|
var McpToolError = class extends Error {
|
|
@@ -38047,11 +38124,12 @@ var McpToolError = class extends Error {
|
|
|
38047
38124
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
38048
38125
|
}
|
|
38049
38126
|
};
|
|
38127
|
+
var HEADER_NAME_RUN = "[a-z0-9_-]{0,40}";
|
|
38050
38128
|
var BEARER_RE = /(bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi;
|
|
38051
|
-
var JWT_RE =
|
|
38129
|
+
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;
|
|
38052
38130
|
var BASIC_AUTH_RE = /(authorization\s*:\s*basic\s+)[A-Za-z0-9+/=_-]{6,}/gi;
|
|
38053
|
-
var SET_COOKIE_RE = /(\bset-cookie\s*:\s*)([
|
|
38054
|
-
var COOKIE_HEADER_RE = /((?<!set-)\bcookie\s*:\s*)((?:[
|
|
38131
|
+
var SET_COOKIE_RE = /(\bset-cookie\s*:\s*)([^=;,:\s]+)=[^;,\s]*/gi;
|
|
38132
|
+
var COOKIE_HEADER_RE = /((?<!set-)\bcookie\s*:\s*)((?:[^=;,:\s]+=[^;,\s]*)(?:;\s*[^=;,:\s]+=[^;,\s]*)*)/gi;
|
|
38055
38133
|
var API_KEY_RE = new RegExp([
|
|
38056
38134
|
"sk-[A-Za-z0-9_-]{20,}(?![A-Za-z0-9_-])",
|
|
38057
38135
|
// OpenAI / Anthropic (incl. sk-ant-…)
|
|
@@ -38066,10 +38144,10 @@ var API_KEY_RE = new RegExp([
|
|
|
38066
38144
|
"whsec_[A-Za-z0-9]{16,}\\b"
|
|
38067
38145
|
// webhook signing secret (Stripe-style)
|
|
38068
38146
|
].map((p) => `\\b${p}`).join("|"), "g");
|
|
38069
|
-
var QUERY_SECRET_RE =
|
|
38147
|
+
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");
|
|
38070
38148
|
var OAUTH_CODE_RE = /([?&]code=)(?=[^&#\s"'<>`]{16,})[^&#\s"'<>`]+/gi;
|
|
38071
38149
|
var FORM_PASSWORD_RE = /((?:^|[\s,;:"'(\[{])(?:password|passwd)=)[^&#\s"'<>`]+/gim;
|
|
38072
|
-
var HEADER_SECRET_RE =
|
|
38150
|
+
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");
|
|
38073
38151
|
var AWS_SIGV4_RE = /([?&]X-Amz-(?:Signature|Security-Token|Credential)=)[^&#\s"'<>`]+/gi;
|
|
38074
38152
|
var JSON_SECRET_KEYS = [
|
|
38075
38153
|
"(?:access|refresh|id|auth|session|bearer|csrf|xsrf)[_-]?token",
|
|
@@ -38077,7 +38155,8 @@ var JSON_SECRET_KEYS = [
|
|
|
38077
38155
|
"api[_-]?secret",
|
|
38078
38156
|
"(?:x[_-])?api[_-]?key",
|
|
38079
38157
|
"private[_-]?key",
|
|
38080
|
-
|
|
38158
|
+
`x[_-]${HEADER_NAME_RUN}?(?:api[_-]?key|token|secret|auth)${HEADER_NAME_RUN}`,
|
|
38159
|
+
// bounded like HEADER_SECRET_RE
|
|
38081
38160
|
"(?:proxy-)?authorization",
|
|
38082
38161
|
"password",
|
|
38083
38162
|
"passwd",
|
|
@@ -38086,12 +38165,30 @@ var JSON_SECRET_KEYS = [
|
|
|
38086
38165
|
].join("|");
|
|
38087
38166
|
var JSON_SECRET_DQ_RE = new RegExp(`("(?:${JSON_SECRET_KEYS})"\\s*:\\s*")(?:[^"\\\\]|\\\\.)*(")`, "gi");
|
|
38088
38167
|
var JSON_SECRET_SQ_RE = new RegExp(`('(?:${JSON_SECRET_KEYS})'\\s*:\\s*')(?:[^'\\\\]|\\\\.)*(')`, "gi");
|
|
38168
|
+
var JSON_SECRET_NUM_RE = new RegExp(`(["'](?:${JSON_SECRET_KEYS})["']\\s*:\\s*)-?\\d+(?:\\.\\d+)?(?![\\d.])`, "gi");
|
|
38169
|
+
var JSON_COOKIE_DQ_RE = /("((?:set-)?cookie)"\s*:\s*)("(?:[^"\\]|\\.)*"|\[\s*"(?:[^"\\]|\\.)*"(?:\s*,\s*"(?:[^"\\]|\\.)*")*)/gi;
|
|
38170
|
+
var JSON_COOKIE_SQ_RE = /('((?:set-)?cookie)'\s*:\s*)('(?:[^'\\]|\\.)*'|\[\s*'(?:[^'\\]|\\.)*'(?:\s*,\s*'(?:[^'\\]|\\.)*')*)/gi;
|
|
38171
|
+
var DQ_STRING_RE = /"((?:[^"\\]|\\.)*)"/g;
|
|
38172
|
+
var SQ_STRING_RE = /'((?:[^'\\]|\\.)*)'/g;
|
|
38173
|
+
function redactJsonCookie(quote) {
|
|
38174
|
+
const stringRe = quote === '"' ? DQ_STRING_RE : SQ_STRING_RE;
|
|
38175
|
+
return (_m, prefix, key, value) => {
|
|
38176
|
+
const setCookie = key.toLowerCase() === "set-cookie";
|
|
38177
|
+
const redacted = value.replace(stringRe, (_s, body) => {
|
|
38178
|
+
const out = setCookie ? body.replace(/^(\s*[^=;]+)=[^;]*/, "$1=[REDACTED]") : body.replace(/=[^;]*/g, "=[REDACTED]");
|
|
38179
|
+
return `${quote}${out}${quote}`;
|
|
38180
|
+
});
|
|
38181
|
+
return `${prefix}${redacted}`;
|
|
38182
|
+
};
|
|
38183
|
+
}
|
|
38089
38184
|
function redactSecrets(text) {
|
|
38090
|
-
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]");
|
|
38185
|
+
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]");
|
|
38091
38186
|
}
|
|
38187
|
+
var ERROR_REDACTION_INPUT_MAX = 64 * 1024;
|
|
38092
38188
|
function truncateErrorMessage(text, max = DEFAULT_ERROR_MESSAGE_MAX) {
|
|
38093
38189
|
const str = text === null || text === void 0 ? "" : String(text);
|
|
38094
|
-
const
|
|
38190
|
+
const cap = Math.max(ERROR_REDACTION_INPUT_MAX, max);
|
|
38191
|
+
const redacted = redactSecrets(str.length > cap ? str.slice(0, cap) : str);
|
|
38095
38192
|
if (redacted.length <= max)
|
|
38096
38193
|
return redacted;
|
|
38097
38194
|
return `${redacted.slice(0, max)}\u2026 [truncated]`;
|
|
@@ -38120,6 +38217,69 @@ function errorResult(message) {
|
|
|
38120
38217
|
};
|
|
38121
38218
|
}
|
|
38122
38219
|
|
|
38220
|
+
// node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
|
|
38221
|
+
function createSpentTokenStore() {
|
|
38222
|
+
const spent = /* @__PURE__ */ new Map();
|
|
38223
|
+
return {
|
|
38224
|
+
has: (nonce) => spent.has(nonce),
|
|
38225
|
+
add: (nonce, exp) => {
|
|
38226
|
+
spent.set(nonce, exp);
|
|
38227
|
+
},
|
|
38228
|
+
prune: (now) => {
|
|
38229
|
+
for (const [nonce, exp] of spent)
|
|
38230
|
+
if (exp < now)
|
|
38231
|
+
spent.delete(nonce);
|
|
38232
|
+
},
|
|
38233
|
+
clear: () => spent.clear(),
|
|
38234
|
+
get size() {
|
|
38235
|
+
return spent.size;
|
|
38236
|
+
}
|
|
38237
|
+
};
|
|
38238
|
+
}
|
|
38239
|
+
var PROCESS_SPENT = createSpentTokenStore();
|
|
38240
|
+
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.`);
|
|
38241
|
+
|
|
38242
|
+
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
38243
|
+
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
38244
|
+
function readEnvVar(key, opts = {}) {
|
|
38245
|
+
const env = opts.env ?? process.env;
|
|
38246
|
+
const raw = env[key];
|
|
38247
|
+
if (typeof raw === "string") {
|
|
38248
|
+
const trimmed = raw.trim();
|
|
38249
|
+
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
38250
|
+
return trimmed;
|
|
38251
|
+
}
|
|
38252
|
+
}
|
|
38253
|
+
return opts.default;
|
|
38254
|
+
}
|
|
38255
|
+
function readPortEnv(key, fallback, opts = {}) {
|
|
38256
|
+
const raw = readEnvVar(key, { env: opts.env });
|
|
38257
|
+
if (raw === void 0)
|
|
38258
|
+
return fallback;
|
|
38259
|
+
if (!/^\d+$/.test(raw))
|
|
38260
|
+
return fallback;
|
|
38261
|
+
const port = Number(raw);
|
|
38262
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
38263
|
+
return fallback;
|
|
38264
|
+
return port;
|
|
38265
|
+
}
|
|
38266
|
+
async function loadDotenvSafely(opts = {}) {
|
|
38267
|
+
try {
|
|
38268
|
+
const mod = await import(
|
|
38269
|
+
/* @vite-ignore */
|
|
38270
|
+
"dotenv"
|
|
38271
|
+
);
|
|
38272
|
+
const result = mod.config({
|
|
38273
|
+
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
38274
|
+
override: opts.override ?? false,
|
|
38275
|
+
quiet: true
|
|
38276
|
+
});
|
|
38277
|
+
return result.error === void 0;
|
|
38278
|
+
} catch {
|
|
38279
|
+
return false;
|
|
38280
|
+
}
|
|
38281
|
+
}
|
|
38282
|
+
|
|
38123
38283
|
// node_modules/@chrischall/mcp-utils/dist/server/index.js
|
|
38124
38284
|
var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
38125
38285
|
"2026-07-28",
|
|
@@ -38237,6 +38397,8 @@ function withGracefulShutdown(target, opts = {}) {
|
|
|
38237
38397
|
};
|
|
38238
38398
|
const handler = (signal) => {
|
|
38239
38399
|
if (shuttingDown) {
|
|
38400
|
+
if (signal === "stdin-eof")
|
|
38401
|
+
return;
|
|
38240
38402
|
if (Date.now() - firstSignalAt < repeatGraceMs)
|
|
38241
38403
|
return;
|
|
38242
38404
|
if (shouldExit) {
|
|
@@ -38272,6 +38434,10 @@ function withGracefulShutdown(target, opts = {}) {
|
|
|
38272
38434
|
};
|
|
38273
38435
|
process.on("SIGINT", () => handler("SIGINT"));
|
|
38274
38436
|
process.on("SIGTERM", () => handler("SIGTERM"));
|
|
38437
|
+
if (opts.stdin) {
|
|
38438
|
+
opts.stdin.once("end", () => handler("stdin-eof"));
|
|
38439
|
+
opts.stdin.once("close", () => handler("stdin-eof"));
|
|
38440
|
+
}
|
|
38275
38441
|
}
|
|
38276
38442
|
function runMcp(opts) {
|
|
38277
38443
|
if (opts.banner !== void 0) {
|
|
@@ -38290,52 +38456,12 @@ function runMcp(opts) {
|
|
|
38290
38456
|
});
|
|
38291
38457
|
const shutdown = opts.shutdown ?? true;
|
|
38292
38458
|
if (shutdown !== false) {
|
|
38293
|
-
|
|
38459
|
+
const stdinDefault = spec === "stdio" ? { stdin: process.stdin } : {};
|
|
38460
|
+
withGracefulShutdown(handle, { ...stdinDefault, ...shutdown === true ? {} : shutdown });
|
|
38294
38461
|
}
|
|
38295
38462
|
return handle;
|
|
38296
38463
|
}
|
|
38297
38464
|
|
|
38298
|
-
// node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
38299
|
-
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
38300
|
-
function readEnvVar(key, opts = {}) {
|
|
38301
|
-
const env = opts.env ?? process.env;
|
|
38302
|
-
const raw = env[key];
|
|
38303
|
-
if (typeof raw === "string") {
|
|
38304
|
-
const trimmed = raw.trim();
|
|
38305
|
-
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
38306
|
-
return trimmed;
|
|
38307
|
-
}
|
|
38308
|
-
}
|
|
38309
|
-
return opts.default;
|
|
38310
|
-
}
|
|
38311
|
-
function readPortEnv(key, fallback, opts = {}) {
|
|
38312
|
-
const raw = readEnvVar(key, { env: opts.env });
|
|
38313
|
-
if (raw === void 0)
|
|
38314
|
-
return fallback;
|
|
38315
|
-
if (!/^\d+$/.test(raw))
|
|
38316
|
-
return fallback;
|
|
38317
|
-
const port = Number(raw);
|
|
38318
|
-
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
38319
|
-
return fallback;
|
|
38320
|
-
return port;
|
|
38321
|
-
}
|
|
38322
|
-
async function loadDotenvSafely(opts = {}) {
|
|
38323
|
-
try {
|
|
38324
|
-
const mod = await import(
|
|
38325
|
-
/* @vite-ignore */
|
|
38326
|
-
"dotenv"
|
|
38327
|
-
);
|
|
38328
|
-
const result = mod.config({
|
|
38329
|
-
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
38330
|
-
override: opts.override ?? false,
|
|
38331
|
-
quiet: true
|
|
38332
|
-
});
|
|
38333
|
-
return result.error === void 0;
|
|
38334
|
-
} catch {
|
|
38335
|
-
return false;
|
|
38336
|
-
}
|
|
38337
|
-
}
|
|
38338
|
-
|
|
38339
38465
|
// node_modules/@chrischall/mcp-utils/dist/zod/index.js
|
|
38340
38466
|
var PositiveInt = external_exports.number().int().positive();
|
|
38341
38467
|
var NonNegInt = external_exports.number().int().nonnegative();
|
|
@@ -38369,7 +38495,7 @@ function toolAnnotations(opts = {}) {
|
|
|
38369
38495
|
|
|
38370
38496
|
// src/version.ts
|
|
38371
38497
|
var PACKAGE_NAME = "microsoft-teams-mcp";
|
|
38372
|
-
var VERSION = "0.2.
|
|
38498
|
+
var VERSION = "0.2.4";
|
|
38373
38499
|
|
|
38374
38500
|
// node_modules/@fetchproxy/protocol/dist/crypto.js
|
|
38375
38501
|
var subtle = globalThis.crypto.subtle;
|
|
@@ -38574,6 +38700,30 @@ var KNOWN_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
|
38574
38700
|
"write_cookies"
|
|
38575
38701
|
]);
|
|
38576
38702
|
|
|
38703
|
+
// node_modules/@fetchproxy/protocol/dist/capability-availability.js
|
|
38704
|
+
var CAPABILITY_UNAVAILABLE_CODE = "capability_unavailable";
|
|
38705
|
+
var MAX_UNAVAILABLE_CAPABILITIES = 32;
|
|
38706
|
+
var MAX_CAPABILITY_NAME_LENGTH = 64;
|
|
38707
|
+
var UNSUPPORTED_CAPABILITY_REASON_PREFIX = "unsupported-capability:";
|
|
38708
|
+
function capabilityUnavailableMessage(capability, platform) {
|
|
38709
|
+
return `capability ${JSON.stringify(capability)} is not available in this browser (${platform})`;
|
|
38710
|
+
}
|
|
38711
|
+
var UNAVAILABLE_RE = /^capability "([^"]{1,64})" is not available in this browser(?: \(([^)]{1,32})\))?/;
|
|
38712
|
+
function parseCapabilityUnavailable(error62) {
|
|
38713
|
+
const m = UNAVAILABLE_RE.exec(error62);
|
|
38714
|
+
if (!m)
|
|
38715
|
+
return null;
|
|
38716
|
+
return { capability: m[1], platform: m[2] ?? null };
|
|
38717
|
+
}
|
|
38718
|
+
function parseUnsupportedCapabilityReason(reason) {
|
|
38719
|
+
if (!reason.startsWith(UNSUPPORTED_CAPABILITY_REASON_PREFIX))
|
|
38720
|
+
return null;
|
|
38721
|
+
const rest = reason.slice(UNSUPPORTED_CAPABILITY_REASON_PREFIX.length).replace(/\s*\(not available in this browser\)\s*$/, "").trim();
|
|
38722
|
+
if (rest === "")
|
|
38723
|
+
return [];
|
|
38724
|
+
return rest.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
38725
|
+
}
|
|
38726
|
+
|
|
38577
38727
|
// node_modules/@fetchproxy/protocol/dist/mcp-id.js
|
|
38578
38728
|
var ID_RE = /^([^:]+):([^:]+):([0-9a-f]{16})$/;
|
|
38579
38729
|
function generateMcpId(serverName, version2) {
|
|
@@ -39288,6 +39438,9 @@ function validateHello(raw) {
|
|
|
39288
39438
|
assertBase64(raw.sessionNonce, "hello.sessionNonce");
|
|
39289
39439
|
if (raw.accepts !== void 0)
|
|
39290
39440
|
assertAcceptsList(raw.accepts);
|
|
39441
|
+
if (raw.unavailableCapabilities !== void 0) {
|
|
39442
|
+
assertUnavailableCapabilities(raw.unavailableCapabilities);
|
|
39443
|
+
}
|
|
39291
39444
|
return raw;
|
|
39292
39445
|
}
|
|
39293
39446
|
throw new ProtocolError3(`hello.role: must be 'server' or 'extension', got ${String(role)}`);
|
|
@@ -39353,6 +39506,22 @@ function assertAcceptsList(accepts) {
|
|
|
39353
39506
|
}
|
|
39354
39507
|
}
|
|
39355
39508
|
}
|
|
39509
|
+
function assertUnavailableCapabilities(list) {
|
|
39510
|
+
const label = "hello.unavailableCapabilities";
|
|
39511
|
+
if (!Array.isArray(list))
|
|
39512
|
+
throw new ProtocolError3(`${label}: expected array`);
|
|
39513
|
+
if (list.length > MAX_UNAVAILABLE_CAPABILITIES) {
|
|
39514
|
+
throw new ProtocolError3(`${label}: at most ${MAX_UNAVAILABLE_CAPABILITIES} entries, got ${list.length}`);
|
|
39515
|
+
}
|
|
39516
|
+
for (const c of list) {
|
|
39517
|
+
if (typeof c !== "string") {
|
|
39518
|
+
throw new ProtocolError3(`${label}: entry must be string, got ${typeof c}`);
|
|
39519
|
+
}
|
|
39520
|
+
if (c.length < 1 || c.length > MAX_CAPABILITY_NAME_LENGTH) {
|
|
39521
|
+
throw new ProtocolError3(`${label}: entry must be 1-${MAX_CAPABILITY_NAME_LENGTH} characters, got ${c.length}`);
|
|
39522
|
+
}
|
|
39523
|
+
}
|
|
39524
|
+
}
|
|
39356
39525
|
function validatePeerGone(raw) {
|
|
39357
39526
|
assertString(raw.mcpId, "peer-gone.mcpId");
|
|
39358
39527
|
if (!isValidMcpId(raw.mcpId))
|
|
@@ -39828,6 +39997,8 @@ function validateInnerResponse(raw) {
|
|
|
39828
39997
|
}
|
|
39829
39998
|
if (raw.ok === false) {
|
|
39830
39999
|
assertString(raw.error, "inner.error");
|
|
40000
|
+
if (raw.code !== void 0)
|
|
40001
|
+
assertString(raw.code, "inner.code");
|
|
39831
40002
|
if (raw.op !== void 0) {
|
|
39832
40003
|
if (typeof raw.op !== "string" || !KNOWN_RESPONSE_OPS.has(raw.op)) {
|
|
39833
40004
|
throw new ProtocolError3(`inner.op: unknown response op ${JSON.stringify(raw.op)}`);
|
|
@@ -39923,6 +40094,38 @@ async function openEncryptedFrameDetailed(sessionKey, frame, direction) {
|
|
|
39923
40094
|
}
|
|
39924
40095
|
}
|
|
39925
40096
|
|
|
40097
|
+
// node_modules/@fetchproxy/server/dist/session-info.js
|
|
40098
|
+
function sessionInfoFromHello(hello) {
|
|
40099
|
+
const raw = hello.unavailableCapabilities;
|
|
40100
|
+
const known = /* @__PURE__ */ new Set();
|
|
40101
|
+
if (Array.isArray(raw)) {
|
|
40102
|
+
for (const c of raw) {
|
|
40103
|
+
if (typeof c === "string" && KNOWN_CAPABILITIES.has(c))
|
|
40104
|
+
known.add(c);
|
|
40105
|
+
}
|
|
40106
|
+
}
|
|
40107
|
+
return { platform: hello.platform, unavailableCapabilities: [...known].sort() };
|
|
40108
|
+
}
|
|
40109
|
+
function capabilitiesForRequest(inner) {
|
|
40110
|
+
if (inner.type !== "request")
|
|
40111
|
+
return [];
|
|
40112
|
+
if (inner.op === "graphql_query")
|
|
40113
|
+
return ["graphql"];
|
|
40114
|
+
if (inner.op === "fetch") {
|
|
40115
|
+
return inner.init.inPage === true ? ["fetch", "fetch_in_page"] : ["fetch"];
|
|
40116
|
+
}
|
|
40117
|
+
return [inner.op];
|
|
40118
|
+
}
|
|
40119
|
+
function unavailableCapabilityFor(inner, info) {
|
|
40120
|
+
if (!info || info.unavailableCapabilities.length === 0)
|
|
40121
|
+
return null;
|
|
40122
|
+
for (const c of capabilitiesForRequest(inner)) {
|
|
40123
|
+
if (info.unavailableCapabilities.includes(c))
|
|
40124
|
+
return c;
|
|
40125
|
+
}
|
|
40126
|
+
return null;
|
|
40127
|
+
}
|
|
40128
|
+
|
|
39926
40129
|
// node_modules/@fetchproxy/server/dist/election.js
|
|
39927
40130
|
import { createServer, Server as HttpServer } from "node:http";
|
|
39928
40131
|
var DEFAULT_BIND_TIMEOUT_MS = 5e3;
|
|
@@ -40168,7 +40371,7 @@ var FetchproxySessionNotReadyError = class extends Error {
|
|
|
40168
40371
|
hint;
|
|
40169
40372
|
constructor(info) {
|
|
40170
40373
|
const pairing = info.pairCode !== null && info.pairCode !== "";
|
|
40171
|
-
const hint = pairing ? `Open the
|
|
40374
|
+
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.`;
|
|
40172
40375
|
super(`fetchproxy: ${pairing ? "pairing not yet approved" : "no confirmed browser session"} for "${info.mcpId}". ${hint}`);
|
|
40173
40376
|
this.name = "FetchproxySessionNotReadyError";
|
|
40174
40377
|
this.reason = pairing ? "pair-required" : "not-ready";
|
|
@@ -40181,15 +40384,35 @@ var FetchproxySessionNotReadyError = class extends Error {
|
|
|
40181
40384
|
var FetchproxyHelloRejectedError = class extends Error {
|
|
40182
40385
|
mcpId;
|
|
40183
40386
|
reason;
|
|
40387
|
+
/**
|
|
40388
|
+
* #418: when the reason is `unsupported-capability: a, b (not available in
|
|
40389
|
+
* this browser)` — every capability this MCP declared is one the browser
|
|
40390
|
+
* cannot serve — those capabilities, parsed out of it. Empty otherwise.
|
|
40391
|
+
*/
|
|
40392
|
+
unavailableCapabilities;
|
|
40393
|
+
/** #418: the refusing browser's platform, when this bridge knew it. */
|
|
40394
|
+
platform;
|
|
40395
|
+
/**
|
|
40396
|
+
* #418: the remedy, when the reason is one this package knows how to
|
|
40397
|
+
* explain — today only `unsupported-capability`, which blames the browser
|
|
40398
|
+
* rather than the MCP. `null` otherwise.
|
|
40399
|
+
*/
|
|
40400
|
+
hint;
|
|
40184
40401
|
constructor(info) {
|
|
40185
|
-
|
|
40402
|
+
const unavailable = parseUnsupportedCapabilityReason(info.reason);
|
|
40403
|
+
const platform = info.platform ?? null;
|
|
40404
|
+
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;
|
|
40405
|
+
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.`));
|
|
40186
40406
|
this.name = "FetchproxyHelloRejectedError";
|
|
40187
40407
|
this.mcpId = info.mcpId;
|
|
40188
40408
|
this.reason = info.reason;
|
|
40409
|
+
this.unavailableCapabilities = unavailable ?? [];
|
|
40410
|
+
this.platform = platform;
|
|
40411
|
+
this.hint = hint;
|
|
40189
40412
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
40190
40413
|
}
|
|
40191
40414
|
};
|
|
40192
|
-
var
|
|
40415
|
+
var MIN_SERVER_VERSION = "3.0.0";
|
|
40193
40416
|
var FetchproxyProtocolVersionError = class extends Error {
|
|
40194
40417
|
/** The protocol version this process speaks. */
|
|
40195
40418
|
ourVersion;
|
|
@@ -40197,7 +40420,7 @@ var FetchproxyProtocolVersionError = class extends Error {
|
|
|
40197
40420
|
theirVersion;
|
|
40198
40421
|
peer;
|
|
40199
40422
|
constructor(info) {
|
|
40200
|
-
const far = info.peer === "extension" ? `the attached browser extension speaks ${info.theirVersion} \u2014 update
|
|
40423
|
+
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`;
|
|
40201
40424
|
super(`protocol version mismatch: this MCP speaks fetchproxy protocol ${info.ourVersion}, ${far}`);
|
|
40202
40425
|
this.name = "FetchproxyProtocolVersionError";
|
|
40203
40426
|
this.ourVersion = info.ourVersion;
|
|
@@ -40230,9 +40453,9 @@ async function awaitSessionReady(ready, opts) {
|
|
|
40230
40453
|
}
|
|
40231
40454
|
|
|
40232
40455
|
// node_modules/@fetchproxy/server/dist/extension-trust.js
|
|
40233
|
-
import { readFile as
|
|
40456
|
+
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";
|
|
40234
40457
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
40235
|
-
import { isAbsolute as isAbsolute2, join as
|
|
40458
|
+
import { isAbsolute as isAbsolute2, join as join3 } from "node:path";
|
|
40236
40459
|
|
|
40237
40460
|
// node_modules/@fetchproxy/server/dist/identity.js
|
|
40238
40461
|
import { readFile, readdir, writeFile, mkdir, chmod, rename, rm, unlink, link, lstat } from "node:fs/promises";
|
|
@@ -40333,6 +40556,7 @@ async function loadOrCreateIdentity(serverName, dir = defaultIdentityDir()) {
|
|
|
40333
40556
|
throw e;
|
|
40334
40557
|
}
|
|
40335
40558
|
let unreadable = null;
|
|
40559
|
+
let recovered = false;
|
|
40336
40560
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
40337
40561
|
const id = await generateIdentity();
|
|
40338
40562
|
if (await publishIdentityIfAbsent(dir, serverName, id))
|
|
@@ -40346,6 +40570,11 @@ async function loadOrCreateIdentity(serverName, dir = defaultIdentityDir()) {
|
|
|
40346
40570
|
if (!(e instanceof SyntaxError))
|
|
40347
40571
|
throw e;
|
|
40348
40572
|
unreadable = e;
|
|
40573
|
+
if (!recovered && await removeAbandonedIdentity(path)) {
|
|
40574
|
+
recovered = true;
|
|
40575
|
+
attempt--;
|
|
40576
|
+
continue;
|
|
40577
|
+
}
|
|
40349
40578
|
await new Promise((r) => setTimeout(r, 20 * (attempt + 1)));
|
|
40350
40579
|
}
|
|
40351
40580
|
}
|
|
@@ -40387,6 +40616,192 @@ async function publishIdentityIfAbsent(dir, serverName, id) {
|
|
|
40387
40616
|
await rm(tmp, { force: true });
|
|
40388
40617
|
}
|
|
40389
40618
|
}
|
|
40619
|
+
var ABANDONED_IDENTITY_MS = 5e3;
|
|
40620
|
+
var RECOVERY_LOCK_STALE_MS = 3e4;
|
|
40621
|
+
function looksAbandoned(text) {
|
|
40622
|
+
const t = text.trim();
|
|
40623
|
+
return t === "" || t.startsWith("{") && !t.endsWith("}");
|
|
40624
|
+
}
|
|
40625
|
+
function sameFile(a, b) {
|
|
40626
|
+
return a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs;
|
|
40627
|
+
}
|
|
40628
|
+
async function takeRecoveryLock(lock) {
|
|
40629
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
40630
|
+
try {
|
|
40631
|
+
await writeFile(lock, `${process.pid}
|
|
40632
|
+
`, { mode: 384, flag: "wx" });
|
|
40633
|
+
return await lstat(lock);
|
|
40634
|
+
} catch (e) {
|
|
40635
|
+
if (e.code !== "EEXIST")
|
|
40636
|
+
return null;
|
|
40637
|
+
const st = await lstat(lock).catch(() => null);
|
|
40638
|
+
if (st === null)
|
|
40639
|
+
continue;
|
|
40640
|
+
if (Date.now() - st.mtimeMs < RECOVERY_LOCK_STALE_MS)
|
|
40641
|
+
return null;
|
|
40642
|
+
const again = await lstat(lock).catch(() => null);
|
|
40643
|
+
if (again === null || !sameFile(st, again))
|
|
40644
|
+
continue;
|
|
40645
|
+
await unlink(lock).catch(() => void 0);
|
|
40646
|
+
}
|
|
40647
|
+
}
|
|
40648
|
+
return null;
|
|
40649
|
+
}
|
|
40650
|
+
async function removeAbandonedIdentity(path) {
|
|
40651
|
+
const lock = `${path}.recover.lock`;
|
|
40652
|
+
const held = await takeRecoveryLock(lock);
|
|
40653
|
+
if (held === null)
|
|
40654
|
+
return false;
|
|
40655
|
+
try {
|
|
40656
|
+
const before = await lstat(path);
|
|
40657
|
+
if (!before.isFile() || Date.now() - before.mtimeMs < ABANDONED_IDENTITY_MS)
|
|
40658
|
+
return false;
|
|
40659
|
+
if (!looksAbandoned(await readFile(path, "utf8")))
|
|
40660
|
+
return false;
|
|
40661
|
+
const now = await lstat(path);
|
|
40662
|
+
if (!sameFile(before, now))
|
|
40663
|
+
return false;
|
|
40664
|
+
await unlink(path);
|
|
40665
|
+
return true;
|
|
40666
|
+
} catch {
|
|
40667
|
+
return false;
|
|
40668
|
+
} finally {
|
|
40669
|
+
const st = await lstat(lock).catch(() => null);
|
|
40670
|
+
if (st !== null && sameFile(held, st))
|
|
40671
|
+
await unlink(lock).catch(() => void 0);
|
|
40672
|
+
}
|
|
40673
|
+
}
|
|
40674
|
+
|
|
40675
|
+
// node_modules/@fetchproxy/server/dist/extension-pins.js
|
|
40676
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
40677
|
+
import { join as join2 } from "node:path";
|
|
40678
|
+
var EXTENSION_PINS_FILE_VERSION = 1;
|
|
40679
|
+
var EXTENSION_PINS_ENV = "FETCHPROXY_EXTENSION_PINS";
|
|
40680
|
+
var ExtensionPinsError = class extends Error {
|
|
40681
|
+
code;
|
|
40682
|
+
constructor(code, message) {
|
|
40683
|
+
super(message);
|
|
40684
|
+
this.name = "ExtensionPinsError";
|
|
40685
|
+
this.code = code;
|
|
40686
|
+
}
|
|
40687
|
+
};
|
|
40688
|
+
function malformed(why) {
|
|
40689
|
+
return new ExtensionPinsError("EXTENSION_PINS_MALFORMED", `malformed extension pin set: ${why}`);
|
|
40690
|
+
}
|
|
40691
|
+
function isKey(x) {
|
|
40692
|
+
if (typeof x !== "string" || x === "")
|
|
40693
|
+
return false;
|
|
40694
|
+
let raw;
|
|
40695
|
+
try {
|
|
40696
|
+
raw = fromB64(x);
|
|
40697
|
+
} catch {
|
|
40698
|
+
return false;
|
|
40699
|
+
}
|
|
40700
|
+
return raw.length === 32 && toB64(raw) === x;
|
|
40701
|
+
}
|
|
40702
|
+
function parseExtensionPins(text) {
|
|
40703
|
+
let parsed;
|
|
40704
|
+
try {
|
|
40705
|
+
parsed = JSON.parse(text);
|
|
40706
|
+
} catch {
|
|
40707
|
+
throw malformed("not JSON");
|
|
40708
|
+
}
|
|
40709
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
40710
|
+
throw malformed("not an object");
|
|
40711
|
+
}
|
|
40712
|
+
const r = parsed;
|
|
40713
|
+
if (r.v !== EXTENSION_PINS_FILE_VERSION) {
|
|
40714
|
+
throw malformed(`"v" is not ${EXTENSION_PINS_FILE_VERSION}`);
|
|
40715
|
+
}
|
|
40716
|
+
if (r.managed !== true)
|
|
40717
|
+
throw malformed('"managed" is not true');
|
|
40718
|
+
if (r.managedBy !== void 0 && typeof r.managedBy !== "string") {
|
|
40719
|
+
throw malformed('"managedBy" is not a string');
|
|
40720
|
+
}
|
|
40721
|
+
if (!Array.isArray(r.extensions))
|
|
40722
|
+
throw malformed('"extensions" is not an array');
|
|
40723
|
+
const extensions = r.extensions.map((e, i) => {
|
|
40724
|
+
if (!e || typeof e !== "object" || Array.isArray(e)) {
|
|
40725
|
+
throw malformed(`extensions[${i}] is not an object`);
|
|
40726
|
+
}
|
|
40727
|
+
const x = e;
|
|
40728
|
+
if (!isKey(x.x25519Pub)) {
|
|
40729
|
+
throw malformed(`extensions[${i}].x25519Pub is not canonical base64 of 32 bytes`);
|
|
40730
|
+
}
|
|
40731
|
+
if (!isKey(x.ed25519Pub)) {
|
|
40732
|
+
throw malformed(`extensions[${i}].ed25519Pub is not canonical base64 of 32 bytes`);
|
|
40733
|
+
}
|
|
40734
|
+
if (x.label !== void 0 && typeof x.label !== "string") {
|
|
40735
|
+
throw malformed(`extensions[${i}].label is not a string`);
|
|
40736
|
+
}
|
|
40737
|
+
return {
|
|
40738
|
+
x25519Pub: x.x25519Pub,
|
|
40739
|
+
ed25519Pub: x.ed25519Pub,
|
|
40740
|
+
...x.label !== void 0 ? { label: x.label } : {}
|
|
40741
|
+
};
|
|
40742
|
+
});
|
|
40743
|
+
return {
|
|
40744
|
+
v: EXTENSION_PINS_FILE_VERSION,
|
|
40745
|
+
managed: true,
|
|
40746
|
+
...r.managedBy !== void 0 ? { managedBy: r.managedBy } : {},
|
|
40747
|
+
extensions
|
|
40748
|
+
};
|
|
40749
|
+
}
|
|
40750
|
+
function extensionPinsPath(serverName, trustDir) {
|
|
40751
|
+
return join2(trustDir, `${safeIdentityFileBase(serverName)}.extension-pins.json`);
|
|
40752
|
+
}
|
|
40753
|
+
async function readExtensionPinsAt(path) {
|
|
40754
|
+
let text;
|
|
40755
|
+
try {
|
|
40756
|
+
text = await readFile2(path, "utf8");
|
|
40757
|
+
} catch (e) {
|
|
40758
|
+
const code = e.code ?? "read failed";
|
|
40759
|
+
throw new ExtensionPinsError("EXTENSION_PINS_MISSING", `no managed extension pin set at ${path} (${code})`);
|
|
40760
|
+
}
|
|
40761
|
+
try {
|
|
40762
|
+
return parseExtensionPins(text);
|
|
40763
|
+
} catch (e) {
|
|
40764
|
+
const why = e instanceof ExtensionPinsError ? e.message : "malformed extension pin set";
|
|
40765
|
+
throw new ExtensionPinsError("EXTENSION_PINS_MALFORMED", `${why} at ${path}`);
|
|
40766
|
+
}
|
|
40767
|
+
}
|
|
40768
|
+
function decideManagedExtensionTrust(args) {
|
|
40769
|
+
const { set: set2, hello, serverName } = args;
|
|
40770
|
+
const listed = set2.extensions.some((e) => e.x25519Pub === hello.identityX25519Pub && e.ed25519Pub === hello.identityEd25519Pub);
|
|
40771
|
+
if (listed)
|
|
40772
|
+
return { decision: "pinned" };
|
|
40773
|
+
return {
|
|
40774
|
+
decision: "refused",
|
|
40775
|
+
code: "EXTENSION_NOT_PINNED",
|
|
40776
|
+
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.`
|
|
40777
|
+
};
|
|
40778
|
+
}
|
|
40779
|
+
async function evaluateManagedExtensionTrust(port, hello, serverName) {
|
|
40780
|
+
let set2;
|
|
40781
|
+
try {
|
|
40782
|
+
set2 = await port.read();
|
|
40783
|
+
} catch (e) {
|
|
40784
|
+
const code = e instanceof ExtensionPinsError ? e.code : "EXTENSION_PINS_MISSING";
|
|
40785
|
+
const detail = e instanceof ExtensionPinsError ? e.message : `could not read ${port.location}`;
|
|
40786
|
+
return {
|
|
40787
|
+
decision: "refused",
|
|
40788
|
+
code,
|
|
40789
|
+
message: `[fetchproxy] ${serverName}: ${code}: ${detail} \u2014 refusing every extension until the host that manages this MCP's pins writes a valid set.`
|
|
40790
|
+
};
|
|
40791
|
+
}
|
|
40792
|
+
return decideManagedExtensionTrust({ set: set2, hello, serverName, location: port.location });
|
|
40793
|
+
}
|
|
40794
|
+
function resolveExtensionPinsMode(explicit, env = process.env) {
|
|
40795
|
+
if (explicit === "managed")
|
|
40796
|
+
return "managed";
|
|
40797
|
+
const raw = env[EXTENSION_PINS_ENV];
|
|
40798
|
+
if (raw === void 0 || raw.trim() === "")
|
|
40799
|
+
return "first-use";
|
|
40800
|
+
if (raw === "managed")
|
|
40801
|
+
return "managed";
|
|
40802
|
+
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.`);
|
|
40803
|
+
return "managed";
|
|
40804
|
+
}
|
|
40390
40805
|
|
|
40391
40806
|
// node_modules/@fetchproxy/server/dist/extension-trust.js
|
|
40392
40807
|
var TRUST_DIR_ENV = "FETCHPROXY_TRUST_DIR";
|
|
@@ -40410,6 +40825,22 @@ function defaultTrustDir() {
|
|
|
40410
40825
|
}
|
|
40411
40826
|
function fileExtensionTrust(args) {
|
|
40412
40827
|
const dir = resolveTrustDir(args.trustDir, args.dir);
|
|
40828
|
+
if (args.extensionPins === "managed") {
|
|
40829
|
+
const location = extensionPinsPath(args.serverName, dir);
|
|
40830
|
+
return {
|
|
40831
|
+
// Managed mode has no first-use pin: nothing to read, nothing to write,
|
|
40832
|
+
// and no operator override. `write` REJECTS rather than no-ops, so a
|
|
40833
|
+
// path that ever reached it would log the attempt instead of silently
|
|
40834
|
+
// pretending to have pinned.
|
|
40835
|
+
allowNew: false,
|
|
40836
|
+
location,
|
|
40837
|
+
read: async () => null,
|
|
40838
|
+
write: async () => {
|
|
40839
|
+
throw new Error(`refusing to write an extension pin: ${location} is host-managed and this MCP never pins on first use`);
|
|
40840
|
+
},
|
|
40841
|
+
managed: { location, read: () => readExtensionPinsAt(location) }
|
|
40842
|
+
};
|
|
40843
|
+
}
|
|
40413
40844
|
return {
|
|
40414
40845
|
allowNew: args.allowNew,
|
|
40415
40846
|
location: extensionTrustPath(args.serverName, dir),
|
|
@@ -40443,13 +40874,13 @@ function decideExtensionTrust(args) {
|
|
|
40443
40874
|
};
|
|
40444
40875
|
}
|
|
40445
40876
|
function extensionTrustPath(serverName, dir = defaultTrustDir()) {
|
|
40446
|
-
return
|
|
40877
|
+
return join3(dir, `${safeIdentityFileBase(serverName)}.extension-trust.json`);
|
|
40447
40878
|
}
|
|
40448
40879
|
function extensionTrustPathHint(serverName) {
|
|
40449
40880
|
try {
|
|
40450
40881
|
return extensionTrustPath(serverName);
|
|
40451
40882
|
} catch {
|
|
40452
|
-
return
|
|
40883
|
+
return join3(defaultTrustDir(), "<server-name>.extension-trust.json");
|
|
40453
40884
|
}
|
|
40454
40885
|
}
|
|
40455
40886
|
function isPin(x) {
|
|
@@ -40462,7 +40893,7 @@ async function readExtensionPin(serverName, dir = defaultTrustDir()) {
|
|
|
40462
40893
|
const path = extensionTrustPath(serverName, dir);
|
|
40463
40894
|
let raw;
|
|
40464
40895
|
try {
|
|
40465
|
-
raw = await
|
|
40896
|
+
raw = await readFile3(path, "utf8");
|
|
40466
40897
|
} catch (e) {
|
|
40467
40898
|
if (e.code === "ENOENT")
|
|
40468
40899
|
return null;
|
|
@@ -40635,6 +41066,7 @@ async function startHost(opts) {
|
|
|
40635
41066
|
return true;
|
|
40636
41067
|
}
|
|
40637
41068
|
let extensionHello = null;
|
|
41069
|
+
let ownSessionInfo = null;
|
|
40638
41070
|
let extensionClaim = null;
|
|
40639
41071
|
const pairCodeFor = async (hello, mint) => {
|
|
40640
41072
|
if (!mint)
|
|
@@ -40653,6 +41085,7 @@ async function startHost(opts) {
|
|
|
40653
41085
|
return;
|
|
40654
41086
|
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).`);
|
|
40655
41087
|
ownSession = dropOwnSessionAndEphemeral();
|
|
41088
|
+
ownSessionInfo = null;
|
|
40656
41089
|
resetSessionPromise();
|
|
40657
41090
|
const mintedKeypair = await generateSessionKeypair();
|
|
40658
41091
|
const mintedHello = await buildServerHello({
|
|
@@ -40711,28 +41144,39 @@ async function startHost(opts) {
|
|
|
40711
41144
|
return;
|
|
40712
41145
|
}
|
|
40713
41146
|
extensionClaim = ws;
|
|
40714
|
-
|
|
40715
|
-
|
|
40716
|
-
|
|
40717
|
-
|
|
40718
|
-
|
|
40719
|
-
|
|
40720
|
-
|
|
40721
|
-
|
|
40722
|
-
|
|
41147
|
+
const managed = opts.extensionTrust.managed;
|
|
41148
|
+
let outcome;
|
|
41149
|
+
let refusalReason = "extension identity is not the pinned one";
|
|
41150
|
+
if (managed) {
|
|
41151
|
+
const decided = await evaluateManagedExtensionTrust(managed, frame, opts.ownServerName);
|
|
41152
|
+
outcome = decided;
|
|
41153
|
+
if (decided.decision === "refused") {
|
|
41154
|
+
refusalReason = decided.code === "EXTENSION_NOT_PINNED" ? "extension identity is not in the managed pin set" : "extension pin set unavailable";
|
|
41155
|
+
}
|
|
41156
|
+
} else {
|
|
41157
|
+
let pin;
|
|
41158
|
+
try {
|
|
41159
|
+
pin = await opts.extensionTrust.read();
|
|
41160
|
+
} catch (e) {
|
|
41161
|
+
console.error(`[fetchproxy] ${String(e)}`);
|
|
41162
|
+
if (extensionClaim === ws)
|
|
41163
|
+
extensionClaim = null;
|
|
41164
|
+
ws.close(1008, "extension pin unreadable");
|
|
41165
|
+
return;
|
|
41166
|
+
}
|
|
41167
|
+
outcome = decideExtensionTrust({
|
|
41168
|
+
pin,
|
|
41169
|
+
hello: frame,
|
|
41170
|
+
allowNew: opts.extensionTrust.allowNew,
|
|
41171
|
+
serverName: opts.ownServerName,
|
|
41172
|
+
location: opts.extensionTrust.location
|
|
41173
|
+
});
|
|
40723
41174
|
}
|
|
40724
|
-
const outcome = decideExtensionTrust({
|
|
40725
|
-
pin,
|
|
40726
|
-
hello: frame,
|
|
40727
|
-
allowNew: opts.extensionTrust.allowNew,
|
|
40728
|
-
serverName: opts.ownServerName,
|
|
40729
|
-
location: opts.extensionTrust.location
|
|
40730
|
-
});
|
|
40731
41175
|
if (outcome.decision === "refused") {
|
|
40732
41176
|
console.warn(outcome.message);
|
|
40733
41177
|
if (extensionClaim === ws)
|
|
40734
41178
|
extensionClaim = null;
|
|
40735
|
-
ws.close(1008,
|
|
41179
|
+
ws.close(1008, refusalReason);
|
|
40736
41180
|
return;
|
|
40737
41181
|
}
|
|
40738
41182
|
if (outcome.decision === "replace")
|
|
@@ -40827,8 +41271,9 @@ async function startHost(opts) {
|
|
|
40827
41271
|
console.warn("[fetchproxy] discarding a ready for a session ephemeral this host no longer holds (the extension reconnected while a hello was in flight)");
|
|
40828
41272
|
return;
|
|
40829
41273
|
}
|
|
40830
|
-
const
|
|
40831
|
-
const
|
|
41274
|
+
const verifiedHello = extensionHello;
|
|
41275
|
+
const extEdPub = fromB64(verifiedHello.identityEd25519Pub);
|
|
41276
|
+
const extNonce = fromB64(verifiedHello.sessionNonce);
|
|
40832
41277
|
const msg = readySignaturePayload(held.nonce, extNonce, fromB64(frame.extensionSessionPub), held.pub);
|
|
40833
41278
|
const sig = fromB64(frame.sessionSig);
|
|
40834
41279
|
let sigOk = false;
|
|
@@ -40861,6 +41306,7 @@ async function startHost(opts) {
|
|
|
40861
41306
|
if (extensionWs !== ws)
|
|
40862
41307
|
return;
|
|
40863
41308
|
ownSession = new SessionState(key);
|
|
41309
|
+
ownSessionInfo = sessionInfoFromHello(verifiedHello);
|
|
40864
41310
|
ownDecryptFailures = 0;
|
|
40865
41311
|
ownPendingPairCode = null;
|
|
40866
41312
|
resolveOwnSession(ownSession);
|
|
@@ -40931,7 +41377,11 @@ async function startHost(opts) {
|
|
|
40931
41377
|
}
|
|
40932
41378
|
if (frame.type === "hello-rejected" && identified === "extension") {
|
|
40933
41379
|
if (frame.mcpId === opts.ownMcpId) {
|
|
40934
|
-
rejectOwnSession(new FetchproxyHelloRejectedError({
|
|
41380
|
+
rejectOwnSession(new FetchproxyHelloRejectedError({
|
|
41381
|
+
mcpId: frame.mcpId,
|
|
41382
|
+
reason: frame.reason,
|
|
41383
|
+
platform: extensionHello?.platform ?? null
|
|
41384
|
+
}));
|
|
40935
41385
|
} else {
|
|
40936
41386
|
const slot = peers.get(frame.mcpId);
|
|
40937
41387
|
if (slot?.helloFrame.accepts?.includes("hello-rejected")) {
|
|
@@ -40977,6 +41427,7 @@ async function startHost(opts) {
|
|
|
40977
41427
|
rejectOwnSession(new Error("extension disconnected before ready"));
|
|
40978
41428
|
}
|
|
40979
41429
|
ownSession = dropOwnSessionAndEphemeral();
|
|
41430
|
+
ownSessionInfo = null;
|
|
40980
41431
|
ownDecryptFailures = 0;
|
|
40981
41432
|
ownPendingPairCode = null;
|
|
40982
41433
|
resetSessionPromise();
|
|
@@ -41023,6 +41474,7 @@ async function startHost(opts) {
|
|
|
41023
41474
|
});
|
|
41024
41475
|
if (!extensionWs)
|
|
41025
41476
|
throw new Error("host: no extension connected");
|
|
41477
|
+
opts.refuseOutbound?.(inner, ownSessionInfo);
|
|
41026
41478
|
const plaintext = encodeOutboundInnerFrame(opts.ownMcpId, inner);
|
|
41027
41479
|
const sealed = await sealInnerFrame(session.sessionKey, opts.ownMcpId, session.nextOutboundSeq(), plaintext, "s2e");
|
|
41028
41480
|
extensionWs.send(JSON.stringify(sealed));
|
|
@@ -41038,7 +41490,8 @@ async function startHost(opts) {
|
|
|
41038
41490
|
},
|
|
41039
41491
|
pendingPairCode: () => ownPendingPairCode,
|
|
41040
41492
|
extensionConnected: () => extensionWs !== null,
|
|
41041
|
-
sessionLinked: () => ownSession !== null
|
|
41493
|
+
sessionLinked: () => ownSession !== null,
|
|
41494
|
+
sessionInfo: () => ownSession !== null ? ownSessionInfo : null
|
|
41042
41495
|
};
|
|
41043
41496
|
}
|
|
41044
41497
|
|
|
@@ -41123,6 +41576,7 @@ async function startPeer(opts) {
|
|
|
41123
41576
|
const closeListeners = [];
|
|
41124
41577
|
const extensionDisconnectListeners = [];
|
|
41125
41578
|
let session = null;
|
|
41579
|
+
let sessionInfo = null;
|
|
41126
41580
|
let sessionEphemeral = null;
|
|
41127
41581
|
function dropSessionEphemeral() {
|
|
41128
41582
|
if (sessionEphemeral)
|
|
@@ -41188,6 +41642,15 @@ async function startPeer(opts) {
|
|
|
41188
41642
|
console.warn(`[fetchproxy] ${opts.serverName}: extension session signature invalid \u2014 refusing (the concentrator may be answering in the browser's place)`);
|
|
41189
41643
|
return null;
|
|
41190
41644
|
}
|
|
41645
|
+
const managed = opts.extensionTrust.managed;
|
|
41646
|
+
if (managed) {
|
|
41647
|
+
const decided = await evaluateManagedExtensionTrust(managed, hello2, opts.serverName);
|
|
41648
|
+
if (decided.decision === "refused") {
|
|
41649
|
+
console.warn(decided.message);
|
|
41650
|
+
return null;
|
|
41651
|
+
}
|
|
41652
|
+
return hello2;
|
|
41653
|
+
}
|
|
41191
41654
|
if (cachedPin === void 0) {
|
|
41192
41655
|
try {
|
|
41193
41656
|
cachedPin = await opts.extensionTrust.read();
|
|
@@ -41255,6 +41718,7 @@ async function startPeer(opts) {
|
|
|
41255
41718
|
extensionGone = true;
|
|
41256
41719
|
dropSessionEphemeral();
|
|
41257
41720
|
pendingPairCode = null;
|
|
41721
|
+
sessionInfo = null;
|
|
41258
41722
|
if (session !== null) {
|
|
41259
41723
|
session = null;
|
|
41260
41724
|
if (sessionPromiseSettled)
|
|
@@ -41287,6 +41751,7 @@ async function startPeer(opts) {
|
|
|
41287
41751
|
}
|
|
41288
41752
|
const isRenegotiation = session !== null;
|
|
41289
41753
|
session = new SessionState(sessionKey);
|
|
41754
|
+
sessionInfo = sessionInfoFromHello(authenticated);
|
|
41290
41755
|
extensionGone = false;
|
|
41291
41756
|
pendingPairCode = null;
|
|
41292
41757
|
if (isRenegotiation) {
|
|
@@ -41297,7 +41762,11 @@ async function startPeer(opts) {
|
|
|
41297
41762
|
return;
|
|
41298
41763
|
}
|
|
41299
41764
|
if (frame.type === "hello-rejected" && frame.mcpId === opts.mcpId) {
|
|
41300
|
-
rejectFirstReady(new FetchproxyHelloRejectedError({
|
|
41765
|
+
rejectFirstReady(new FetchproxyHelloRejectedError({
|
|
41766
|
+
mcpId: frame.mcpId,
|
|
41767
|
+
reason: frame.reason,
|
|
41768
|
+
platform: extensionHello?.platform ?? null
|
|
41769
|
+
}));
|
|
41301
41770
|
}
|
|
41302
41771
|
if (frame.type === "pair-pending" && frame.mcpId === opts.mcpId) {
|
|
41303
41772
|
const hello2 = extensionHello;
|
|
@@ -41397,6 +41866,7 @@ async function startPeer(opts) {
|
|
|
41397
41866
|
const s = session;
|
|
41398
41867
|
if (s === null)
|
|
41399
41868
|
throw new Error("peer: extension disconnected");
|
|
41869
|
+
opts.refuseOutbound?.(inner, sessionInfo);
|
|
41400
41870
|
const plaintext = encodeOutboundInnerFrame(opts.mcpId, inner);
|
|
41401
41871
|
const sealed = await sealInnerFrame(s.sessionKey, opts.mcpId, s.nextOutboundSeq(), plaintext, "s2e");
|
|
41402
41872
|
if (ws.readyState !== import_websocket.default.OPEN)
|
|
@@ -41415,6 +41885,7 @@ async function startPeer(opts) {
|
|
|
41415
41885
|
pendingPairCode: () => pendingPairCode,
|
|
41416
41886
|
extensionConnected: () => extensionHello !== null,
|
|
41417
41887
|
sessionLinked: () => session !== null && !extensionGone,
|
|
41888
|
+
sessionInfo: () => session !== null && !extensionGone ? sessionInfo : null,
|
|
41418
41889
|
onClose: (cb) => {
|
|
41419
41890
|
closeListeners.push(cb);
|
|
41420
41891
|
},
|
|
@@ -41427,7 +41898,9 @@ async function startPeer(opts) {
|
|
|
41427
41898
|
}
|
|
41428
41899
|
|
|
41429
41900
|
// node_modules/@fetchproxy/server/dist/error-kind.js
|
|
41430
|
-
function classifyFetchError(error62) {
|
|
41901
|
+
function classifyFetchError(error62, code) {
|
|
41902
|
+
if (code === CAPABILITY_UNAVAILABLE_CODE)
|
|
41903
|
+
return "capability_unavailable";
|
|
41431
41904
|
if (/^(in-page )?fetch threw:/.test(error62)) {
|
|
41432
41905
|
return "tab_fetch_failed";
|
|
41433
41906
|
}
|
|
@@ -41443,6 +41916,9 @@ function classifyFetchError(error62) {
|
|
|
41443
41916
|
if (/not in domains \[/.test(error62)) {
|
|
41444
41917
|
return "domain_denied";
|
|
41445
41918
|
}
|
|
41919
|
+
if (parseCapabilityUnavailable(error62) !== null) {
|
|
41920
|
+
return "capability_unavailable";
|
|
41921
|
+
}
|
|
41446
41922
|
if (/^capability .+ not granted/.test(error62)) {
|
|
41447
41923
|
return "capability_denied";
|
|
41448
41924
|
}
|
|
@@ -41521,7 +41997,7 @@ var FetchproxyBridgeDownError = class extends FetchproxyProtocolError {
|
|
|
41521
41997
|
const retryAttempted = args.retryAttempted ?? false;
|
|
41522
41998
|
const op = args.op ?? "fetch";
|
|
41523
41999
|
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). `;
|
|
41524
|
-
const hint = `
|
|
42000
|
+
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.`;
|
|
41525
42001
|
super(`fetchproxy bridge down during ${op}${args.url ? ` (${args.url})` : ""}. ${hint}`);
|
|
41526
42002
|
this.name = "FetchproxyBridgeDownError";
|
|
41527
42003
|
this.originalError = args.originalError;
|
|
@@ -41548,7 +42024,7 @@ var FetchproxyHintedError = class extends FetchproxyProtocolError {
|
|
|
41548
42024
|
};
|
|
41549
42025
|
var FetchproxyScopeError = class extends FetchproxyHintedError {
|
|
41550
42026
|
constructor(originalError) {
|
|
41551
|
-
super(originalError, "the declared scope changed since you paired, so the extension is refusing the request. Revoke this MCP in the
|
|
42027
|
+
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.");
|
|
41552
42028
|
this.name = "FetchproxyScopeError";
|
|
41553
42029
|
}
|
|
41554
42030
|
};
|
|
@@ -41570,6 +42046,19 @@ var FetchproxyWaitedError = class extends FetchproxyHintedError {
|
|
|
41570
42046
|
this.name = "FetchproxyWaitedError";
|
|
41571
42047
|
}
|
|
41572
42048
|
};
|
|
42049
|
+
var FetchproxyCapabilityUnavailableError = class extends FetchproxyHintedError {
|
|
42050
|
+
/** The capability the browser cannot serve (`graphql` for a `graphql_query`). */
|
|
42051
|
+
capability;
|
|
42052
|
+
/** The browser, when known (`'safari'`); `null` when the extension did not say. */
|
|
42053
|
+
platform;
|
|
42054
|
+
constructor(originalError, info) {
|
|
42055
|
+
const where = info.platform ? `this browser (${info.platform})` : "this browser";
|
|
42056
|
+
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).`);
|
|
42057
|
+
this.name = "FetchproxyCapabilityUnavailableError";
|
|
42058
|
+
this.capability = info.capability;
|
|
42059
|
+
this.platform = info.platform;
|
|
42060
|
+
}
|
|
42061
|
+
};
|
|
41573
42062
|
function waitedHint(op) {
|
|
41574
42063
|
const tail = " This is not a version problem and does not need an update.";
|
|
41575
42064
|
if (op === "capture" || op === "capture_redirect") {
|
|
@@ -41583,7 +42072,15 @@ function waitedHint(op) {
|
|
|
41583
42072
|
var SCOPE_REJECTION = /not in declared/;
|
|
41584
42073
|
var NO_TAB_REJECTION = /no tab matching (?!.*(content script loaded|one is still opening))/;
|
|
41585
42074
|
var TAB_OPENING_REJECTION = /no tab matching .*one is still opening/;
|
|
41586
|
-
function protocolErrorFrom(error62, op) {
|
|
42075
|
+
function protocolErrorFrom(error62, op, response) {
|
|
42076
|
+
const unavailable = parseCapabilityUnavailable(error62);
|
|
42077
|
+
if (unavailable !== null || response?.code === CAPABILITY_UNAVAILABLE_CODE) {
|
|
42078
|
+
const fromOp = response?.op === "graphql_query" ? "graphql" : response?.op ?? "unknown";
|
|
42079
|
+
return new FetchproxyCapabilityUnavailableError(error62, {
|
|
42080
|
+
capability: unavailable?.capability ?? fromOp,
|
|
42081
|
+
platform: unavailable?.platform ?? null
|
|
42082
|
+
});
|
|
42083
|
+
}
|
|
41587
42084
|
if (error62 === "timeout")
|
|
41588
42085
|
return new FetchproxyWaitedError(error62, op);
|
|
41589
42086
|
if (SCOPE_REJECTION.test(error62))
|
|
@@ -41642,7 +42139,8 @@ var FetchproxyTimeoutError = class extends FetchproxyProtocolError {
|
|
|
41642
42139
|
constructor(args) {
|
|
41643
42140
|
const graceMs = args.graceMs ?? VERB_DEADLINE_GRACE_MS;
|
|
41644
42141
|
const callerChose = args.requestedTimeoutMs !== void 0 && args.timeoutMs === args.requestedTimeoutMs + graceMs;
|
|
41645
|
-
|
|
42142
|
+
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.` : "");
|
|
42143
|
+
super(args.retrySafe === false ? withNotResentNote(base) : base);
|
|
41646
42144
|
this.name = "FetchproxyTimeoutError";
|
|
41647
42145
|
this.url = args.url;
|
|
41648
42146
|
this.timeoutMs = args.timeoutMs;
|
|
@@ -41654,6 +42152,10 @@ var FetchproxyTimeoutError = class extends FetchproxyProtocolError {
|
|
|
41654
42152
|
this.retrySafe = args.retrySafe ?? true;
|
|
41655
42153
|
}
|
|
41656
42154
|
};
|
|
42155
|
+
var TIMEOUT_NOT_RESENT_NOTE = "It was not re-sent because it may already have run in the browser \u2014 check before retrying.";
|
|
42156
|
+
function withNotResentNote(message) {
|
|
42157
|
+
return `${message}${message.endsWith(".") ? " " : ". "}${TIMEOUT_NOT_RESENT_NOTE}`;
|
|
42158
|
+
}
|
|
41657
42159
|
var SUBDOMAIN_LABEL_RE = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
|
|
41658
42160
|
function normalizeCookiePath(path) {
|
|
41659
42161
|
if (path === void 0 || path === "")
|
|
@@ -41913,6 +42415,7 @@ var FetchproxyServer = class {
|
|
|
41913
42415
|
identityDir: opts.identityDir,
|
|
41914
42416
|
trustDir: opts.trustDir,
|
|
41915
42417
|
allowNewExtensionIdentity: opts.allowNewExtensionIdentity,
|
|
42418
|
+
extensionPins: opts.extensionPins,
|
|
41916
42419
|
requireExtensionIdentity: opts.requireExtensionIdentity,
|
|
41917
42420
|
onPairCode: opts.onPairCode
|
|
41918
42421
|
};
|
|
@@ -41998,6 +42501,7 @@ var FetchproxyServer = class {
|
|
|
41998
42501
|
this.role = "host";
|
|
41999
42502
|
this.hostHandle = await startHost({
|
|
42000
42503
|
httpServer: el.server,
|
|
42504
|
+
refuseOutbound: (inner, info) => this.refuseIfUnavailable(inner, info),
|
|
42001
42505
|
ownIdentity: identity,
|
|
42002
42506
|
ownMcpId: mcpId,
|
|
42003
42507
|
ownServerName: this.opts.serverName,
|
|
@@ -42028,6 +42532,7 @@ var FetchproxyServer = class {
|
|
|
42028
42532
|
} else {
|
|
42029
42533
|
this.role = "peer";
|
|
42030
42534
|
this.peerHandle = await startPeer({
|
|
42535
|
+
refuseOutbound: (inner, info) => this.refuseIfUnavailable(inner, info),
|
|
42031
42536
|
host: this.opts.host,
|
|
42032
42537
|
port: this.opts.port,
|
|
42033
42538
|
identity,
|
|
@@ -42076,7 +42581,7 @@ var FetchproxyServer = class {
|
|
|
42076
42581
|
}
|
|
42077
42582
|
}
|
|
42078
42583
|
pairingErrorMessage(code) {
|
|
42079
|
-
return `fetchproxy transport error: pairing required for ${this.opts.serverName}. Tell the user to open the
|
|
42584
|
+
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.`;
|
|
42080
42585
|
}
|
|
42081
42586
|
/**
|
|
42082
42587
|
* Raw single-shot fetch through the bridge. Most callers should prefer
|
|
@@ -42206,13 +42711,28 @@ var FetchproxyServer = class {
|
|
|
42206
42711
|
* every one of them.
|
|
42207
42712
|
*/
|
|
42208
42713
|
extensionTrust() {
|
|
42714
|
+
const allowNew = allowNewExtensionIdentity(this.opts.allowNewExtensionIdentity);
|
|
42715
|
+
if (resolveExtensionPinsMode(this.opts.extensionPins) === "managed") {
|
|
42716
|
+
if (allowNew && !this.warnedAllowNewIgnored) {
|
|
42717
|
+
this.warnedAllowNewIgnored = true;
|
|
42718
|
+
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.`);
|
|
42719
|
+
}
|
|
42720
|
+
return fileExtensionTrust({
|
|
42721
|
+
serverName: this.opts.serverName,
|
|
42722
|
+
dir: this.opts.identityDir,
|
|
42723
|
+
trustDir: this.opts.trustDir,
|
|
42724
|
+
allowNew: false,
|
|
42725
|
+
extensionPins: "managed"
|
|
42726
|
+
});
|
|
42727
|
+
}
|
|
42209
42728
|
return fileExtensionTrust({
|
|
42210
42729
|
serverName: this.opts.serverName,
|
|
42211
42730
|
dir: this.opts.identityDir,
|
|
42212
42731
|
trustDir: this.opts.trustDir,
|
|
42213
|
-
allowNew
|
|
42732
|
+
allowNew
|
|
42214
42733
|
});
|
|
42215
42734
|
}
|
|
42735
|
+
warnedAllowNewIgnored = false;
|
|
42216
42736
|
noteActivityForKeepalive() {
|
|
42217
42737
|
const intervalMs = this.opts.keepAliveIntervalMs;
|
|
42218
42738
|
if (intervalMs <= 0)
|
|
@@ -42306,6 +42826,15 @@ var FetchproxyServer = class {
|
|
|
42306
42826
|
resendable: isRetrySafeOnTimeout(init.method, fetchOpts.retryOnTimeout)
|
|
42307
42827
|
});
|
|
42308
42828
|
} catch (err) {
|
|
42829
|
+
if (err instanceof FetchproxyCapabilityUnavailableError) {
|
|
42830
|
+
return {
|
|
42831
|
+
ok: false,
|
|
42832
|
+
error: err.originalError,
|
|
42833
|
+
kind: "capability_unavailable",
|
|
42834
|
+
retryAttempted: false,
|
|
42835
|
+
cause: err
|
|
42836
|
+
};
|
|
42837
|
+
}
|
|
42309
42838
|
return {
|
|
42310
42839
|
ok: false,
|
|
42311
42840
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -42326,7 +42855,8 @@ var FetchproxyServer = class {
|
|
|
42326
42855
|
timer = setTimeout(() => {
|
|
42327
42856
|
this.pending.delete(id);
|
|
42328
42857
|
const elapsedMs = Date.now() - start;
|
|
42329
|
-
const
|
|
42858
|
+
const base = `fetchproxy: ${init.url} did not respond within ${timeoutMs}ms`;
|
|
42859
|
+
const error62 = isRetrySafeOnTimeout(init.method, fetchOpts.retryOnTimeout) ? base : withNotResentNote(base);
|
|
42330
42860
|
resolve({
|
|
42331
42861
|
ok: false,
|
|
42332
42862
|
error: error62,
|
|
@@ -42448,6 +42978,9 @@ var FetchproxyServer = class {
|
|
|
42448
42978
|
port: this.opts.port
|
|
42449
42979
|
});
|
|
42450
42980
|
}
|
|
42981
|
+
if (result.kind === "capability_unavailable") {
|
|
42982
|
+
return protocolErrorFrom(result.error, void 0, { code: CAPABILITY_UNAVAILABLE_CODE, op });
|
|
42983
|
+
}
|
|
42451
42984
|
return protocolErrorFrom(result.error);
|
|
42452
42985
|
}
|
|
42453
42986
|
/**
|
|
@@ -42514,6 +43047,9 @@ var FetchproxyServer = class {
|
|
|
42514
43047
|
if (result.kind === "session_not_ready" && result.cause instanceof Error) {
|
|
42515
43048
|
throw result.cause;
|
|
42516
43049
|
}
|
|
43050
|
+
if (result.kind === "capability_unavailable" && result.cause instanceof FetchproxyCapabilityUnavailableError) {
|
|
43051
|
+
throw result.cause;
|
|
43052
|
+
}
|
|
42517
43053
|
throw this._typedErrorFor(result, init.url, "fetch", result.retryAttempted ?? false, isRetrySafeOnTimeout(method, opts.retryOnTimeout));
|
|
42518
43054
|
}
|
|
42519
43055
|
const response = {
|
|
@@ -42696,7 +43232,9 @@ var FetchproxyServer = class {
|
|
|
42696
43232
|
session_state: health.session.state,
|
|
42697
43233
|
pending_pair_code: health.session.pairCode,
|
|
42698
43234
|
extension_connected: health.session.extensionConnected,
|
|
42699
|
-
last_extension_message_at: health.lastExtensionMessageAt
|
|
43235
|
+
last_extension_message_at: health.lastExtensionMessageAt,
|
|
43236
|
+
unavailable_capabilities: health.session.unavailableCapabilities,
|
|
43237
|
+
platform: health.session.platform
|
|
42700
43238
|
},
|
|
42701
43239
|
...error62 ? { error: error62 } : {}
|
|
42702
43240
|
};
|
|
@@ -43342,7 +43880,7 @@ var FetchproxyServer = class {
|
|
|
43342
43880
|
fetchCb({
|
|
43343
43881
|
ok: false,
|
|
43344
43882
|
error: inner.error,
|
|
43345
|
-
kind: classifyFetchError(inner.error),
|
|
43883
|
+
kind: classifyFetchError(inner.error, inner.code),
|
|
43346
43884
|
retryAttempted: false
|
|
43347
43885
|
});
|
|
43348
43886
|
}
|
|
@@ -43358,7 +43896,7 @@ var FetchproxyServer = class {
|
|
|
43358
43896
|
storageCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on storage awaiter`));
|
|
43359
43897
|
}
|
|
43360
43898
|
} else {
|
|
43361
|
-
storageCb.reject(protocolErrorFrom(inner.error));
|
|
43899
|
+
storageCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
43362
43900
|
}
|
|
43363
43901
|
return;
|
|
43364
43902
|
}
|
|
@@ -43372,7 +43910,7 @@ var FetchproxyServer = class {
|
|
|
43372
43910
|
captureCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on capture awaiter`));
|
|
43373
43911
|
}
|
|
43374
43912
|
} else {
|
|
43375
|
-
captureCb.reject(protocolErrorFrom(inner.error, "capture"));
|
|
43913
|
+
captureCb.reject(protocolErrorFrom(inner.error, "capture", inner));
|
|
43376
43914
|
}
|
|
43377
43915
|
return;
|
|
43378
43916
|
}
|
|
@@ -43386,7 +43924,7 @@ var FetchproxyServer = class {
|
|
|
43386
43924
|
redirectCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on capture_redirect awaiter`));
|
|
43387
43925
|
}
|
|
43388
43926
|
} else {
|
|
43389
|
-
redirectCb.reject(protocolErrorFrom(inner.error, "capture_redirect"));
|
|
43927
|
+
redirectCb.reject(protocolErrorFrom(inner.error, "capture_redirect", inner));
|
|
43390
43928
|
}
|
|
43391
43929
|
return;
|
|
43392
43930
|
}
|
|
@@ -43400,7 +43938,7 @@ var FetchproxyServer = class {
|
|
|
43400
43938
|
idbCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on read_indexed_db awaiter`));
|
|
43401
43939
|
}
|
|
43402
43940
|
} else {
|
|
43403
|
-
idbCb.reject(protocolErrorFrom(inner.error));
|
|
43941
|
+
idbCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
43404
43942
|
}
|
|
43405
43943
|
return;
|
|
43406
43944
|
}
|
|
@@ -43414,7 +43952,7 @@ var FetchproxyServer = class {
|
|
|
43414
43952
|
domListCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on read_dom_list awaiter`));
|
|
43415
43953
|
}
|
|
43416
43954
|
} else {
|
|
43417
|
-
domListCb.reject(protocolErrorFrom(inner.error));
|
|
43955
|
+
domListCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
43418
43956
|
}
|
|
43419
43957
|
return;
|
|
43420
43958
|
}
|
|
@@ -43428,7 +43966,7 @@ var FetchproxyServer = class {
|
|
|
43428
43966
|
downloadCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on download awaiter`));
|
|
43429
43967
|
}
|
|
43430
43968
|
} else {
|
|
43431
|
-
downloadCb.reject(protocolErrorFrom(inner.error, "download"));
|
|
43969
|
+
downloadCb.reject(protocolErrorFrom(inner.error, "download", inner));
|
|
43432
43970
|
}
|
|
43433
43971
|
return;
|
|
43434
43972
|
}
|
|
@@ -43442,7 +43980,7 @@ var FetchproxyServer = class {
|
|
|
43442
43980
|
graphqlCb.reject(new FetchproxyProtocolError(`unexpected ${String(inner.op)} response on graphql_query awaiter`));
|
|
43443
43981
|
}
|
|
43444
43982
|
} else {
|
|
43445
|
-
graphqlCb.reject(protocolErrorFrom(inner.error));
|
|
43983
|
+
graphqlCb.reject(protocolErrorFrom(inner.error, void 0, inner));
|
|
43446
43984
|
}
|
|
43447
43985
|
return;
|
|
43448
43986
|
}
|
|
@@ -43452,7 +43990,7 @@ var FetchproxyServer = class {
|
|
|
43452
43990
|
if (inner.ok && inner.op === "write_cookies") {
|
|
43453
43991
|
writeCookiesCb.resolve([...inner.written]);
|
|
43454
43992
|
} else {
|
|
43455
|
-
writeCookiesCb.reject(
|
|
43993
|
+
writeCookiesCb.reject(inner.ok ? protocolErrorFrom("write_cookies response had the wrong op") : protocolErrorFrom(inner.error, void 0, inner));
|
|
43456
43994
|
}
|
|
43457
43995
|
return;
|
|
43458
43996
|
}
|
|
@@ -43642,11 +44180,38 @@ var FetchproxyServer = class {
|
|
|
43642
44180
|
const handle = this.hostHandle ?? this.peerHandle;
|
|
43643
44181
|
const pairCode = this.currentPendingPairCode();
|
|
43644
44182
|
if (!handle || this.role === null) {
|
|
43645
|
-
return {
|
|
44183
|
+
return {
|
|
44184
|
+
state: "not_listening",
|
|
44185
|
+
pairCode,
|
|
44186
|
+
extensionConnected: false,
|
|
44187
|
+
unavailableCapabilities: [],
|
|
44188
|
+
platform: null
|
|
44189
|
+
};
|
|
43646
44190
|
}
|
|
44191
|
+
const info = handle.sessionInfo?.() ?? null;
|
|
43647
44192
|
const extensionConnected = handle.extensionConnected();
|
|
43648
44193
|
const state = handle.sessionLinked() ? "linked" : pairCode !== null ? "pair_pending" : !extensionConnected ? "extension_disconnected" : "no_session";
|
|
43649
|
-
return {
|
|
44194
|
+
return {
|
|
44195
|
+
state,
|
|
44196
|
+
pairCode,
|
|
44197
|
+
extensionConnected,
|
|
44198
|
+
unavailableCapabilities: info ? [...info.unavailableCapabilities] : [],
|
|
44199
|
+
platform: info?.platform ?? null
|
|
44200
|
+
};
|
|
44201
|
+
}
|
|
44202
|
+
/**
|
|
44203
|
+
* #418: refuse, before a seq is claimed, a request whose capability the
|
|
44204
|
+
* extension said this browser cannot serve. Called by the host / peer
|
|
44205
|
+
* handle once the session is ready, so it judges against the list from the
|
|
44206
|
+
* hello that session was verified against. Advisory: the list is unsigned,
|
|
44207
|
+
* so it may only ever make this MCP refuse MORE — the extension still
|
|
44208
|
+
* enforces from its own runtime check for anything that gets through.
|
|
44209
|
+
*/
|
|
44210
|
+
refuseIfUnavailable(inner, info) {
|
|
44211
|
+
const cap = unavailableCapabilityFor(inner, info);
|
|
44212
|
+
if (cap === null || info === null)
|
|
44213
|
+
return;
|
|
44214
|
+
throw new FetchproxyCapabilityUnavailableError(capabilityUnavailableMessage(cap, info.platform), { capability: cap, platform: info.platform });
|
|
43650
44215
|
}
|
|
43651
44216
|
/**
|
|
43652
44217
|
* 0.5.2+: throw `FetchproxyProtocolError` with the actionable pair-code
|
|
@@ -43773,6 +44338,55 @@ function createFetchproxyTransport(opts) {
|
|
|
43773
44338
|
};
|
|
43774
44339
|
return transport;
|
|
43775
44340
|
}
|
|
44341
|
+
var CONTEXTMINT_BRIDGE_RELEASES = "https://github.com/nullnet-app/contextmint-bridge/releases";
|
|
44342
|
+
var CAPABILITY_UNAVAILABLE_RE = /capability "([^"]{1,64})" is not available in this browser(?: \(([^)]{1,32})\))?/;
|
|
44343
|
+
var UNSUPPORTED_CAPABILITY_RE = /unsupported-capability:\s*([^()]+?)\s*\(not available in this browser\)/;
|
|
44344
|
+
var CAPABILITY_DENIED_RE = /\bcapability \S.* not granted/;
|
|
44345
|
+
function mayBeCapabilityError(kind) {
|
|
44346
|
+
return kind === "protocol" || kind === "hello_rejected" || kind === "other";
|
|
44347
|
+
}
|
|
44348
|
+
function stringField(err, key) {
|
|
44349
|
+
if (typeof err !== "object" || err === null)
|
|
44350
|
+
return void 0;
|
|
44351
|
+
const v = err[key];
|
|
44352
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
44353
|
+
}
|
|
44354
|
+
function capabilityGapOf(err) {
|
|
44355
|
+
const name = err instanceof Error ? err.name : void 0;
|
|
44356
|
+
const message = messageOf(err);
|
|
44357
|
+
const originalError = stringField(err, "originalError");
|
|
44358
|
+
const platformField = stringField(err, "platform") ?? null;
|
|
44359
|
+
if (name === "FetchproxyHelloRejectedError") {
|
|
44360
|
+
const listed = err.unavailableCapabilities;
|
|
44361
|
+
const parsed = UNSUPPORTED_CAPABILITY_RE.exec(stringField(err, "reason") ?? message);
|
|
44362
|
+
const capabilities = Array.isArray(listed) && listed.length > 0 ? listed.map(String) : parsed ? parsed[1].split(",").map((c) => c.trim()).filter(Boolean) : [];
|
|
44363
|
+
return capabilities.length > 0 ? { capabilities, platform: platformField } : null;
|
|
44364
|
+
}
|
|
44365
|
+
const wording = CAPABILITY_UNAVAILABLE_RE.exec(originalError ?? message);
|
|
44366
|
+
const typed = name === "FetchproxyCapabilityUnavailableError";
|
|
44367
|
+
const coded = stringField(err, "code") === "capability_unavailable";
|
|
44368
|
+
const classified = classifyFetchError(originalError ?? message) === "capability_unavailable";
|
|
44369
|
+
if (!typed && !coded && !wording && !classified)
|
|
44370
|
+
return null;
|
|
44371
|
+
const capability = stringField(err, "capability") ?? wording?.[1];
|
|
44372
|
+
return {
|
|
44373
|
+
capabilities: capability ? [capability] : [],
|
|
44374
|
+
platform: platformField ?? wording?.[2] ?? null,
|
|
44375
|
+
...originalError !== void 0 ? { originalError } : {}
|
|
44376
|
+
};
|
|
44377
|
+
}
|
|
44378
|
+
function isCapabilityDenied(err) {
|
|
44379
|
+
const text = stringField(err, "originalError") ?? messageOf(err);
|
|
44380
|
+
if (CAPABILITY_UNAVAILABLE_RE.test(text))
|
|
44381
|
+
return false;
|
|
44382
|
+
return classifyFetchError(text) === "capability_denied" || CAPABILITY_DENIED_RE.test(text);
|
|
44383
|
+
}
|
|
44384
|
+
function capabilityUnavailableHint(gap) {
|
|
44385
|
+
const where = gap.platform ? `This browser (${gap.platform})` : "This browser";
|
|
44386
|
+
const what = gap.capabilities.length === 0 ? "what this tool needs" : gap.capabilities.length === 1 ? `the "${gap.capabilities[0]}" capability this tool needs` : `the capabilities this MCP needs (${gap.capabilities.map((c) => `"${c}"`).join(", ")})`;
|
|
44387
|
+
return `${where} can't serve ${what} \u2014 ContextMint Bridge checked for the browser API and it is missing. The MCP isn't at fault, and re-pairing or updating won't change it: use a browser that supports it (for example Chrome) for this.`;
|
|
44388
|
+
}
|
|
44389
|
+
var CAPABILITY_DENIED_HINT = "The MCP asked ContextMint Bridge for a capability it never declared, so the request was refused. This is a bug in the MCP, not in your browser or pairing \u2014 please report it to the maintainer of the MCP.";
|
|
43776
44390
|
function healthcheckHint(args) {
|
|
43777
44391
|
const { hostLabel, prefix, probePath, port } = args;
|
|
43778
44392
|
const portNote = port === null ? "" : ` (port ${port})`;
|
|
@@ -43780,20 +44394,26 @@ function healthcheckHint(args) {
|
|
|
43780
44394
|
if (args.direct) {
|
|
43781
44395
|
return `Direct fetch round-tripped ${probePath} successfully \u2014 the browser bridge wasn't used for this probe. If real tools still fail, the problem is on the ${hostLabel} side (a bot wall answering some calls but not this one, a field that moved, \u2026), not the transport.`;
|
|
43782
44396
|
}
|
|
43783
|
-
return `Bridge round-tripped ${probePath} successfully. If real tools still fail, the problem is downstream of
|
|
44397
|
+
return `Bridge round-tripped ${probePath} successfully. If real tools still fail, the problem is downstream of ContextMint Bridge (${hostLabel} redirecting on login, a bot-wall / behavioral challenge, etc.) \u2014 not the bridge.`;
|
|
44398
|
+
}
|
|
44399
|
+
if (args.errorKind === "capability_unavailable") {
|
|
44400
|
+
return capabilityUnavailableHint(args.capabilityGap ?? { capabilities: [], platform: null });
|
|
44401
|
+
}
|
|
44402
|
+
if (args.errorKind === "capability_denied") {
|
|
44403
|
+
return CAPABILITY_DENIED_HINT;
|
|
43784
44404
|
}
|
|
43785
44405
|
if (args.errorKind === "session_not_ready") {
|
|
43786
44406
|
const s = args.session;
|
|
43787
44407
|
if (s?.pairCode) {
|
|
43788
|
-
return `
|
|
44408
|
+
return `ContextMint Bridge is waiting for you to approve pair code ${s.pairCode} for ${prefix}-mcp. Open the ContextMint Bridge popup, approve it, then retry.`;
|
|
43789
44409
|
}
|
|
43790
44410
|
if (s?.state === "extension_disconnected") {
|
|
43791
|
-
return `
|
|
44411
|
+
return `ContextMint Bridge isn't attached to this bridge${portNote}. Open a browser with ContextMint Bridge installed and a ${hostLabel} tab, then retry. (Chrome: load the extension from ${CONTEXTMINT_BRIDGE_RELEASES}; Safari: it ships inside the ContextMint app.)`;
|
|
43792
44412
|
}
|
|
43793
|
-
return `
|
|
44413
|
+
return `ContextMint Bridge is attached but never confirmed a session for ${prefix}-mcp \u2014 its hello got no answer within the session-ready timeout. Reload the extension (chrome://extensions) or reopen the ${hostLabel} tab, then retry. On a hosted bridge this is also what a relay that dialled the child before it bound its port${portNote} looks like.`;
|
|
43794
44414
|
}
|
|
43795
44415
|
if (args.errorKind === "bridge_down") {
|
|
43796
|
-
const base = `The
|
|
44416
|
+
const base = `The ContextMint Bridge extension's service worker is not responding. Chrome evicts extension service workers after ~30s idle by default \u2014 this looks like that case. Wake it by clicking the ContextMint Bridge icon in the toolbar (or opening any ${hostLabel} tab and reloading), then retry. If it keeps happening, reload the extension from chrome://extensions.`;
|
|
43797
44417
|
return args.bridgeHint ? `${args.bridgeHint} ${base}` : base;
|
|
43798
44418
|
}
|
|
43799
44419
|
if (args.direct) {
|
|
@@ -43803,10 +44423,10 @@ function healthcheckHint(args) {
|
|
|
43803
44423
|
return `The bridge never bound a role. listen() may have failed silently on startup. Check stderr from ${prefix}-mcp for an error during start, and confirm ${port === null ? "the bridge port" : `port ${port}`} isn't blocked.`;
|
|
43804
44424
|
}
|
|
43805
44425
|
if (args.errorKind === "timeout") {
|
|
43806
|
-
return `Bridge is alive (role=${args.role}), but the request didn't get a response in time. Either (a)
|
|
44426
|
+
return `Bridge is alive (role=${args.role}), but the request didn't get a response in time. Either (a) ContextMint Bridge isn't connected to this MCP yet \u2014 open the ContextMint Bridge popup and check for a green dot next to "${prefix}-mcp", or (b) the signed-in ${hostLabel} tab is sleeping / closed. Open ${hostLabel} in your browser, then retry.`;
|
|
43807
44427
|
}
|
|
43808
44428
|
if (args.errorKind === "protocol" || args.errorKind === "http") {
|
|
43809
|
-
return `The bridge returned a protocol error before any HTTP response. Most commonly: no ${hostLabel} tab is open, or
|
|
44429
|
+
return `The bridge returned a protocol error before any HTTP response. Most commonly: no ${hostLabel} tab is open, or ContextMint Bridge declined the request. Open ${hostLabel}, sign in, and retry.`;
|
|
43810
44430
|
}
|
|
43811
44431
|
return `Unexpected error \u2014 see the error.message field for details.`;
|
|
43812
44432
|
}
|
|
@@ -43828,7 +44448,10 @@ function projectBridgeStatus(health) {
|
|
|
43828
44448
|
...session ? {
|
|
43829
44449
|
session_state: session.state,
|
|
43830
44450
|
pending_pair_code: session.pairCode,
|
|
43831
|
-
extension_connected: session.extensionConnected
|
|
44451
|
+
extension_connected: session.extensionConnected,
|
|
44452
|
+
// 3.3+ only; absent keys stay absent on an older server.
|
|
44453
|
+
...session.unavailableCapabilities !== void 0 ? { unavailable_capabilities: session.unavailableCapabilities } : {},
|
|
44454
|
+
...session.platform !== void 0 ? { platform: session.platform } : {}
|
|
43832
44455
|
} : {}
|
|
43833
44456
|
};
|
|
43834
44457
|
}
|
|
@@ -43836,7 +44459,7 @@ function probeDisplayUrl(hostLabel, probePath) {
|
|
|
43836
44459
|
return `https://${hostLabel}${probePath.startsWith("/") ? "" : "/"}${probePath}`;
|
|
43837
44460
|
}
|
|
43838
44461
|
function bridgeHealthcheckDescription(hostLabel, probePath) {
|
|
43839
|
-
return `Round-trips a small public ${hostLabel} URL (${probePath}) through
|
|
44462
|
+
return `Round-trips a small public ${hostLabel} URL (${probePath}) through ContextMint Bridge (your signed-in browser tab) and returns diagnostics: the bridge's role (host/peer/null), port, version, the extension link (linked / pair pending / not attached / never answered), the elapsed round-trip time, and a plain-English hint distinguishing 'bridge never came up' from 'extension not connected' from 'this browser can't serve a capability' from 'real ${hostLabel}-side problem'. Read-only, no auth required.`;
|
|
43840
44463
|
}
|
|
43841
44464
|
async function runBridgeHealthcheck(args) {
|
|
43842
44465
|
const { prefix, probePath, hostLabel, probeFn, classifyThrown, hints, path } = args;
|
|
@@ -43891,6 +44514,7 @@ async function runBridgeHealthcheck(args) {
|
|
|
43891
44514
|
let bridgeHint;
|
|
43892
44515
|
let customHint;
|
|
43893
44516
|
let customDetail;
|
|
44517
|
+
let capabilityGap;
|
|
43894
44518
|
if (rawError) {
|
|
43895
44519
|
let kind = rawError.kind === "other" ? "unknown" : rawError.kind;
|
|
43896
44520
|
if (thrown instanceof FetchproxySessionNotReadyError) {
|
|
@@ -43898,6 +44522,14 @@ async function runBridgeHealthcheck(args) {
|
|
|
43898
44522
|
bridgeHint = thrown.hint;
|
|
43899
44523
|
} else if (thrown instanceof FetchproxyBridgeDownError) {
|
|
43900
44524
|
bridgeHint = thrown.hint;
|
|
44525
|
+
} else if (thrown !== void 0 && mayBeCapabilityError(rawError.kind)) {
|
|
44526
|
+
const gap = capabilityGapOf(thrown);
|
|
44527
|
+
if (gap) {
|
|
44528
|
+
kind = "capability_unavailable";
|
|
44529
|
+
capabilityGap = gap;
|
|
44530
|
+
} else if (isCapabilityDenied(thrown)) {
|
|
44531
|
+
kind = "capability_denied";
|
|
44532
|
+
}
|
|
43901
44533
|
}
|
|
43902
44534
|
if (thrown !== void 0 && classifyThrown) {
|
|
43903
44535
|
const custom2 = classifyThrown(thrown);
|
|
@@ -43915,7 +44547,7 @@ async function runBridgeHealthcheck(args) {
|
|
|
43915
44547
|
};
|
|
43916
44548
|
}
|
|
43917
44549
|
const direct = pathNow ? pathNow.transport === "direct" : bridge === void 0;
|
|
43918
|
-
const arm = ok ? "ok" : error62?.kind === "session_not_ready" ? "session_not_ready" : error62?.kind === "bridge_down" ? "bridge_down" : direct ? "direct" : bridge === void 0 || bridge.role === null ? "no_role" : error62?.kind === "timeout" ? "timeout" : error62?.kind === "protocol" || error62?.kind === "http" ? "protocol" : "unknown";
|
|
44550
|
+
const arm = ok ? "ok" : error62?.kind === "capability_unavailable" || error62?.kind === "capability_denied" ? error62.kind : error62?.kind === "session_not_ready" ? "session_not_ready" : error62?.kind === "bridge_down" ? "bridge_down" : direct ? "direct" : bridge === void 0 || bridge.role === null ? "no_role" : error62?.kind === "timeout" ? "timeout" : error62?.kind === "protocol" || error62?.kind === "http" ? "protocol" : "unknown";
|
|
43919
44551
|
const defaultHint = healthcheckHint({
|
|
43920
44552
|
ok,
|
|
43921
44553
|
role: bridge?.role ?? null,
|
|
@@ -43930,7 +44562,14 @@ async function runBridgeHealthcheck(args) {
|
|
|
43930
44562
|
...bridge?.session_state !== void 0 ? { state: bridge.session_state } : {},
|
|
43931
44563
|
pairCode: bridge?.pending_pair_code ?? (thrown instanceof FetchproxySessionNotReadyError ? thrown.pairCode : null)
|
|
43932
44564
|
},
|
|
43933
|
-
direct
|
|
44565
|
+
direct,
|
|
44566
|
+
...capabilityGap ? {
|
|
44567
|
+
capabilityGap: {
|
|
44568
|
+
capabilities: capabilityGap.capabilities,
|
|
44569
|
+
// The error may not name the browser; the session snapshot can.
|
|
44570
|
+
platform: capabilityGap.platform ?? bridge?.platform ?? null
|
|
44571
|
+
}
|
|
44572
|
+
} : {}
|
|
43934
44573
|
});
|
|
43935
44574
|
const result = {
|
|
43936
44575
|
ok,
|
|
@@ -43947,10 +44586,10 @@ async function runBridgeHealthcheck(args) {
|
|
|
43947
44586
|
}
|
|
43948
44587
|
function registerBridgeHealthcheckTool(args) {
|
|
43949
44588
|
args.server.registerTool(`${args.prefix}_healthcheck`, {
|
|
43950
|
-
title: "Verify the
|
|
44589
|
+
title: "Verify the ContextMint Bridge connection end-to-end",
|
|
43951
44590
|
description: `${bridgeHealthcheckDescription(args.hostLabel, args.probePath)} Call this when a real tool fails and you want to know which hop broke.`,
|
|
43952
44591
|
annotations: {
|
|
43953
|
-
title: "Verify the
|
|
44592
|
+
title: "Verify the ContextMint Bridge connection end-to-end",
|
|
43954
44593
|
readOnlyHint: true,
|
|
43955
44594
|
idempotentHint: true,
|
|
43956
44595
|
openWorldHint: true
|
|
@@ -44054,11 +44693,11 @@ var TeamsClient = class {
|
|
|
44054
44693
|
port: getWsPort(),
|
|
44055
44694
|
// stderr only — stdout is the JSON-RPC channel. Without this the
|
|
44056
44695
|
// first-ever pairing (or a scope widening) leaves a tool call
|
|
44057
|
-
// hanging with no way for the user to know a
|
|
44696
|
+
// hanging with no way for the user to know a ContextMint Bridge approval
|
|
44058
44697
|
// is what it's waiting on.
|
|
44059
44698
|
onPairCode: (code) => {
|
|
44060
44699
|
console.error(
|
|
44061
|
-
`[microsoft-teams-mcp] fetchproxy pair code: ${code} \u2014 approve in the
|
|
44700
|
+
`[microsoft-teams-mcp] fetchproxy pair code: ${code} \u2014 approve in the ContextMint Bridge extension popup`
|
|
44062
44701
|
);
|
|
44063
44702
|
}
|
|
44064
44703
|
});
|
|
@@ -44142,6 +44781,16 @@ var TeamsClient = class {
|
|
|
44142
44781
|
|
|
44143
44782
|
// src/tools/errors.ts
|
|
44144
44783
|
function wrapBridgeError(err, action) {
|
|
44784
|
+
if (err instanceof FetchproxyCapabilityUnavailableError) {
|
|
44785
|
+
const where = err.platform ? `this browser (${err.platform})` : "this browser";
|
|
44786
|
+
return new McpToolError(
|
|
44787
|
+
`Cannot ${action}: ${where} cannot serve the "${err.capability}" capability.`,
|
|
44788
|
+
{
|
|
44789
|
+
hint: "Nothing is wrong with the pairing or this MCP. Use Teams in a browser that supports it (for example Chrome) with ContextMint Bridge installed.",
|
|
44790
|
+
cause: err
|
|
44791
|
+
}
|
|
44792
|
+
);
|
|
44793
|
+
}
|
|
44145
44794
|
const message = err instanceof Error ? err.message : String(err);
|
|
44146
44795
|
if (/no tab matching|could not reach a signed-in/i.test(message)) {
|
|
44147
44796
|
return new McpToolError(`Could not reach a signed-in Teams tab to ${action}.`, {
|
|
@@ -44150,7 +44799,7 @@ function wrapBridgeError(err, action) {
|
|
|
44150
44799
|
}
|
|
44151
44800
|
if (/pair code|not granted|not in declared/i.test(message)) {
|
|
44152
44801
|
return new McpToolError(`The Teams browser bridge is not yet approved: ${message}`, {
|
|
44153
|
-
hint: "Approve the pairing request in the
|
|
44802
|
+
hint: "Approve the pairing request in the ContextMint Bridge extension popup, then retry."
|
|
44154
44803
|
});
|
|
44155
44804
|
}
|
|
44156
44805
|
return new McpToolError(`Failed to ${action}: ${message}`);
|
|
@@ -44314,7 +44963,7 @@ await runMcp({
|
|
|
44314
44963
|
});
|
|
44315
44964
|
/*! Bundled license information:
|
|
44316
44965
|
|
|
44317
|
-
@modelcontextprotocol/server/dist/src-
|
|
44966
|
+
@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs:
|
|
44318
44967
|
(*!
|
|
44319
44968
|
* content-type
|
|
44320
44969
|
* Copyright(c) 2015 Douglas Christopher Wilson
|