real-browser-mcp-server 1.1.8 → 1.1.9
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.
|
@@ -342,7 +342,7 @@ exports.visionHandlers = {
|
|
|
342
342
|
},
|
|
343
343
|
async see_page(params = {}) {
|
|
344
344
|
const { page } = (0, state_1.requireBrowser)();
|
|
345
|
-
const { fullPage = false, format = 'jpeg', quality = 70, includeElements = true, maxElements = 60, path: savePath } = params;
|
|
345
|
+
const { fullPage = false, format = 'jpeg', quality = 70, includeElements = true, includeDomText = false, maxElements = 60, path: savePath } = params;
|
|
346
346
|
(0, state_1.notifyProgress)('see_page', 'started', `👁️ Looking at the page (${fullPage ? 'full page' : 'viewport'})...`);
|
|
347
347
|
// 1. Capture what the page looks like (the "eyes")
|
|
348
348
|
const shotOpts = { type: format, fullPage };
|
|
@@ -359,7 +359,7 @@ exports.visionHandlers = {
|
|
|
359
359
|
let elements = [];
|
|
360
360
|
let pageInfo = {};
|
|
361
361
|
if (includeElements) {
|
|
362
|
-
const data = await page.evaluate((maxEls) => {
|
|
362
|
+
const data = await page.evaluate(({ maxEls, isFullPage }) => {
|
|
363
363
|
const out = [];
|
|
364
364
|
const seen = new Set();
|
|
365
365
|
const sel = 'a[href], button, input, select, textarea, [role="button"], [role="link"], [onclick], [tabindex]';
|
|
@@ -398,9 +398,11 @@ exports.visionHandlers = {
|
|
|
398
398
|
const style = window.getComputedStyle(el);
|
|
399
399
|
if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0')
|
|
400
400
|
continue;
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
if (!isFullPage) {
|
|
402
|
+
if (rect.bottom < 0 || rect.right < 0 || rect.top > window.innerHeight || rect.left > window.innerWidth) {
|
|
403
|
+
// outside current viewport — skip (we report what is seen)
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
404
406
|
}
|
|
405
407
|
const tag = el.tagName.toLowerCase();
|
|
406
408
|
let label = (el.innerText || el.value || el.getAttribute('aria-label') || el.getAttribute('placeholder') || el.getAttribute('title') || el.getAttribute('alt') || '').trim().replace(/\s+/g, ' ').slice(0, 80);
|
|
@@ -437,10 +439,16 @@ exports.visionHandlers = {
|
|
|
437
439
|
scrollHeight: document.body ? document.body.scrollHeight : 0
|
|
438
440
|
}
|
|
439
441
|
};
|
|
440
|
-
}, maxElements).catch(() => ({ elements: [], info: {} }));
|
|
442
|
+
}, { maxEls: maxElements, isFullPage: fullPage }).catch(() => ({ elements: [], info: {} }));
|
|
441
443
|
elements = data.elements || [];
|
|
442
444
|
pageInfo = data.info || {};
|
|
443
445
|
}
|
|
446
|
+
let domText = undefined;
|
|
447
|
+
if (includeDomText) {
|
|
448
|
+
domText = await page.evaluate(() => {
|
|
449
|
+
return document.body ? document.body.innerText : '';
|
|
450
|
+
}).catch(() => '');
|
|
451
|
+
}
|
|
444
452
|
// 3. Optionally save the image too
|
|
445
453
|
let savedTo = null;
|
|
446
454
|
if (savePath) {
|
|
@@ -459,6 +467,7 @@ exports.visionHandlers = {
|
|
|
459
467
|
viewport: pageInfo.viewport,
|
|
460
468
|
scroll: { y: pageInfo.scrollY, pageHeight: pageInfo.scrollHeight },
|
|
461
469
|
visibleInteractiveElements: elements.length,
|
|
470
|
+
domText,
|
|
462
471
|
elements,
|
|
463
472
|
savedTo
|
|
464
473
|
};
|
package/dist/src/shared/tools.js
CHANGED
|
@@ -554,6 +554,7 @@ const TOOLS = [
|
|
|
554
554
|
format: { type: 'string', enum: ['png', 'jpeg'], default: 'jpeg', description: 'Image format (jpeg = smaller, faster for vision)' },
|
|
555
555
|
quality: { type: 'number', default: 70, description: 'JPEG quality 0-100 (lower = smaller image to the AI)' },
|
|
556
556
|
includeElements: { type: 'boolean', default: true, description: 'Include the visual map of interactive elements' },
|
|
557
|
+
includeDomText: { type: 'boolean', default: false, description: 'Include the full text content of the page (DOM reading)' },
|
|
557
558
|
maxElements: { type: 'number', default: 60, description: 'Max number of interactive elements to map' },
|
|
558
559
|
path: { type: 'string', description: 'Optional file path to also save the captured image' }
|
|
559
560
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "real-browser-mcp-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "MCP Server for Real Browser - Patchright (undetected Playwright fork) with Stealth Mode, Ad Blocker, and Turnstile Auto-Solver for undetectable web automation.",
|
|
5
5
|
"main": "dist/lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.mjs",
|