@arabold/docs-mcp-server 2.0.2 → 2.0.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/dist/index.js +137 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5243,6 +5243,16 @@ class HtmlPlaywrightMiddleware {
|
|
|
5243
5243
|
* @param credentials Optional credentials for same-origin requests
|
|
5244
5244
|
* @param origin The origin for same-origin credential checking
|
|
5245
5245
|
*/
|
|
5246
|
+
/**
|
|
5247
|
+
* Checks if an error is a Playwright "Route is already handled" error.
|
|
5248
|
+
* This specific error occurs when multiple handlers attempt to handle the same route.
|
|
5249
|
+
*/
|
|
5250
|
+
isRouteAlreadyHandledError(error) {
|
|
5251
|
+
if (error instanceof Error) {
|
|
5252
|
+
return error.message.includes("Route is already handled");
|
|
5253
|
+
}
|
|
5254
|
+
return false;
|
|
5255
|
+
}
|
|
5246
5256
|
async setupCachingRouteInterception(page, customHeaders = {}, credentials, origin) {
|
|
5247
5257
|
await page.route("**/*", async (route) => {
|
|
5248
5258
|
const reqUrl = route.request().url();
|
|
@@ -5255,17 +5265,33 @@ class HtmlPlaywrightMiddleware {
|
|
|
5255
5265
|
})();
|
|
5256
5266
|
const resourceType = route.request().resourceType();
|
|
5257
5267
|
if (["image", "font", "media"].includes(resourceType)) {
|
|
5258
|
-
|
|
5268
|
+
try {
|
|
5269
|
+
return await route.abort();
|
|
5270
|
+
} catch (error) {
|
|
5271
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5272
|
+
logger.debug(`Route already handled (abort): ${reqUrl}`);
|
|
5273
|
+
return;
|
|
5274
|
+
}
|
|
5275
|
+
throw error;
|
|
5276
|
+
}
|
|
5259
5277
|
}
|
|
5260
5278
|
if (route.request().method() === "GET") {
|
|
5261
5279
|
const cached = HtmlPlaywrightMiddleware.resourceCache.get(reqUrl);
|
|
5262
5280
|
if (cached !== void 0) {
|
|
5263
5281
|
logger.debug(`✓ Cache hit for ${resourceType}: ${reqUrl}`);
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5282
|
+
try {
|
|
5283
|
+
return await route.fulfill({
|
|
5284
|
+
status: 200,
|
|
5285
|
+
contentType: cached.contentType,
|
|
5286
|
+
body: cached.body
|
|
5287
|
+
});
|
|
5288
|
+
} catch (error) {
|
|
5289
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5290
|
+
logger.debug(`Route already handled (fulfill cached): ${reqUrl}`);
|
|
5291
|
+
return;
|
|
5292
|
+
}
|
|
5293
|
+
throw error;
|
|
5294
|
+
}
|
|
5269
5295
|
}
|
|
5270
5296
|
const headers2 = mergePlaywrightHeaders(
|
|
5271
5297
|
route.request().headers(),
|
|
@@ -5291,13 +5317,29 @@ class HtmlPlaywrightMiddleware {
|
|
|
5291
5317
|
);
|
|
5292
5318
|
}
|
|
5293
5319
|
}
|
|
5294
|
-
|
|
5320
|
+
try {
|
|
5321
|
+
return await route.fulfill({ response });
|
|
5322
|
+
} catch (error) {
|
|
5323
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5324
|
+
logger.debug(`Route already handled (fulfill): ${reqUrl}`);
|
|
5325
|
+
return;
|
|
5326
|
+
}
|
|
5327
|
+
throw error;
|
|
5328
|
+
}
|
|
5295
5329
|
} catch (error) {
|
|
5296
5330
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5297
5331
|
logger.debug(
|
|
5298
5332
|
`Network error fetching ${resourceType} ${reqUrl}: ${errorMessage}`
|
|
5299
5333
|
);
|
|
5300
|
-
|
|
5334
|
+
try {
|
|
5335
|
+
return await route.abort("failed");
|
|
5336
|
+
} catch (abortError) {
|
|
5337
|
+
if (this.isRouteAlreadyHandledError(abortError)) {
|
|
5338
|
+
logger.debug(`Route already handled (abort after error): ${reqUrl}`);
|
|
5339
|
+
return;
|
|
5340
|
+
}
|
|
5341
|
+
throw abortError;
|
|
5342
|
+
}
|
|
5301
5343
|
}
|
|
5302
5344
|
}
|
|
5303
5345
|
const headers = mergePlaywrightHeaders(
|
|
@@ -5310,9 +5352,21 @@ class HtmlPlaywrightMiddleware {
|
|
|
5310
5352
|
try {
|
|
5311
5353
|
return await route.continue({ headers });
|
|
5312
5354
|
} catch (error) {
|
|
5355
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5356
|
+
logger.debug(`Route already handled (continue): ${reqUrl}`);
|
|
5357
|
+
return;
|
|
5358
|
+
}
|
|
5313
5359
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5314
|
-
logger.debug(`
|
|
5315
|
-
|
|
5360
|
+
logger.debug(`Error continuing ${resourceType} ${reqUrl}: ${errorMessage}`);
|
|
5361
|
+
try {
|
|
5362
|
+
return await route.abort("failed");
|
|
5363
|
+
} catch (abortError) {
|
|
5364
|
+
if (this.isRouteAlreadyHandledError(abortError)) {
|
|
5365
|
+
logger.debug(`Route already handled (abort after continue error): ${reqUrl}`);
|
|
5366
|
+
return;
|
|
5367
|
+
}
|
|
5368
|
+
throw abortError;
|
|
5369
|
+
}
|
|
5316
5370
|
}
|
|
5317
5371
|
});
|
|
5318
5372
|
}
|
|
@@ -5465,11 +5519,19 @@ ${frame.content}
|
|
|
5465
5519
|
await page.route("**/*", async (route) => {
|
|
5466
5520
|
const reqUrl = route.request().url();
|
|
5467
5521
|
if (reqUrl === context.source) {
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5522
|
+
try {
|
|
5523
|
+
return await route.fulfill({
|
|
5524
|
+
status: 200,
|
|
5525
|
+
contentType: "text/html; charset=utf-8",
|
|
5526
|
+
body: context.content
|
|
5527
|
+
});
|
|
5528
|
+
} catch (error) {
|
|
5529
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5530
|
+
logger.debug(`Route already handled (initial page): ${reqUrl}`);
|
|
5531
|
+
return;
|
|
5532
|
+
}
|
|
5533
|
+
throw error;
|
|
5534
|
+
}
|
|
5473
5535
|
}
|
|
5474
5536
|
const reqOrigin = (() => {
|
|
5475
5537
|
try {
|
|
@@ -5480,17 +5542,33 @@ ${frame.content}
|
|
|
5480
5542
|
})();
|
|
5481
5543
|
const resourceType = route.request().resourceType();
|
|
5482
5544
|
if (["image", "font", "media"].includes(resourceType)) {
|
|
5483
|
-
|
|
5545
|
+
try {
|
|
5546
|
+
return await route.abort();
|
|
5547
|
+
} catch (error) {
|
|
5548
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5549
|
+
logger.debug(`Route already handled (abort): ${reqUrl}`);
|
|
5550
|
+
return;
|
|
5551
|
+
}
|
|
5552
|
+
throw error;
|
|
5553
|
+
}
|
|
5484
5554
|
}
|
|
5485
5555
|
if (route.request().method() === "GET") {
|
|
5486
5556
|
const cached = HtmlPlaywrightMiddleware.resourceCache.get(reqUrl);
|
|
5487
5557
|
if (cached !== void 0) {
|
|
5488
5558
|
logger.debug(`✓ Cache hit for ${resourceType}: ${reqUrl}`);
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5559
|
+
try {
|
|
5560
|
+
return await route.fulfill({
|
|
5561
|
+
status: 200,
|
|
5562
|
+
contentType: cached.contentType,
|
|
5563
|
+
body: cached.body
|
|
5564
|
+
});
|
|
5565
|
+
} catch (error) {
|
|
5566
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5567
|
+
logger.debug(`Route already handled (fulfill cached): ${reqUrl}`);
|
|
5568
|
+
return;
|
|
5569
|
+
}
|
|
5570
|
+
throw error;
|
|
5571
|
+
}
|
|
5494
5572
|
}
|
|
5495
5573
|
const headers2 = mergePlaywrightHeaders(
|
|
5496
5574
|
route.request().headers(),
|
|
@@ -5517,13 +5595,29 @@ ${frame.content}
|
|
|
5517
5595
|
);
|
|
5518
5596
|
}
|
|
5519
5597
|
}
|
|
5520
|
-
|
|
5598
|
+
try {
|
|
5599
|
+
return await route.fulfill({ response });
|
|
5600
|
+
} catch (error) {
|
|
5601
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5602
|
+
logger.debug(`Route already handled (fulfill): ${reqUrl}`);
|
|
5603
|
+
return;
|
|
5604
|
+
}
|
|
5605
|
+
throw error;
|
|
5606
|
+
}
|
|
5521
5607
|
} catch (error) {
|
|
5522
5608
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5523
5609
|
logger.debug(
|
|
5524
5610
|
`Network error fetching ${resourceType} ${reqUrl}: ${errorMessage}`
|
|
5525
5611
|
);
|
|
5526
|
-
|
|
5612
|
+
try {
|
|
5613
|
+
return await route.abort("failed");
|
|
5614
|
+
} catch (abortError) {
|
|
5615
|
+
if (this.isRouteAlreadyHandledError(abortError)) {
|
|
5616
|
+
logger.debug(`Route already handled (abort after error): ${reqUrl}`);
|
|
5617
|
+
return;
|
|
5618
|
+
}
|
|
5619
|
+
throw abortError;
|
|
5620
|
+
}
|
|
5527
5621
|
}
|
|
5528
5622
|
}
|
|
5529
5623
|
const headers = mergePlaywrightHeaders(
|
|
@@ -5536,9 +5630,23 @@ ${frame.content}
|
|
|
5536
5630
|
try {
|
|
5537
5631
|
return await route.continue({ headers });
|
|
5538
5632
|
} catch (error) {
|
|
5633
|
+
if (this.isRouteAlreadyHandledError(error)) {
|
|
5634
|
+
logger.debug(`Route already handled (continue): ${reqUrl}`);
|
|
5635
|
+
return;
|
|
5636
|
+
}
|
|
5539
5637
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5540
|
-
logger.debug(`
|
|
5541
|
-
|
|
5638
|
+
logger.debug(`Error continuing ${resourceType} ${reqUrl}: ${errorMessage}`);
|
|
5639
|
+
try {
|
|
5640
|
+
return await route.abort("failed");
|
|
5641
|
+
} catch (abortError) {
|
|
5642
|
+
if (this.isRouteAlreadyHandledError(abortError)) {
|
|
5643
|
+
logger.debug(
|
|
5644
|
+
`Route already handled (abort after continue error): ${reqUrl}`
|
|
5645
|
+
);
|
|
5646
|
+
return;
|
|
5647
|
+
}
|
|
5648
|
+
throw abortError;
|
|
5649
|
+
}
|
|
5542
5650
|
}
|
|
5543
5651
|
});
|
|
5544
5652
|
await page.goto(context.source, { waitUntil: "load" });
|
|
@@ -12038,7 +12146,7 @@ const Layout = ({
|
|
|
12038
12146
|
children,
|
|
12039
12147
|
eventClientConfig
|
|
12040
12148
|
}) => {
|
|
12041
|
-
const versionString = version || "2.0.
|
|
12149
|
+
const versionString = version || "2.0.4";
|
|
12042
12150
|
const versionInitializer = `versionUpdate({ currentVersion: ${`'${versionString}'`} })`;
|
|
12043
12151
|
return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
|
|
12044
12152
|
/* @__PURE__ */ jsxs("head", { children: [
|
|
@@ -14388,7 +14496,7 @@ class AppServer {
|
|
|
14388
14496
|
try {
|
|
14389
14497
|
if (telemetry.isEnabled()) {
|
|
14390
14498
|
telemetry.setGlobalContext({
|
|
14391
|
-
appVersion: "2.0.
|
|
14499
|
+
appVersion: "2.0.4",
|
|
14392
14500
|
appPlatform: process.platform,
|
|
14393
14501
|
appNodeVersion: process.version,
|
|
14394
14502
|
appServicesEnabled: this.getActiveServicesList(),
|
|
@@ -18641,7 +18749,7 @@ function createCli(argv) {
|
|
|
18641
18749
|
let globalEventBus = null;
|
|
18642
18750
|
let globalTelemetryService = null;
|
|
18643
18751
|
const commandStartTimes = /* @__PURE__ */ new Map();
|
|
18644
|
-
const cli = yargs(hideBin(argv)).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("2.0.
|
|
18752
|
+
const cli = yargs(hideBin(argv)).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("2.0.4").option("verbose", {
|
|
18645
18753
|
type: "boolean",
|
|
18646
18754
|
description: "Enable verbose (debug) logging",
|
|
18647
18755
|
default: false
|
|
@@ -18701,7 +18809,7 @@ function createCli(argv) {
|
|
|
18701
18809
|
if (shouldEnableTelemetry() && telemetry.isEnabled()) {
|
|
18702
18810
|
const commandName = argv2._[0]?.toString() || "default";
|
|
18703
18811
|
telemetry.setGlobalContext({
|
|
18704
|
-
appVersion: "2.0.
|
|
18812
|
+
appVersion: "2.0.4",
|
|
18705
18813
|
appPlatform: process.platform,
|
|
18706
18814
|
appNodeVersion: process.version,
|
|
18707
18815
|
appInterface: "cli",
|