scrapeless-mcp-server 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/build/tools/browser/browser.js +39 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -442,3 +442,42 @@ export const browserScrollTo = defineTool({
|
|
|
442
442
|
}
|
|
443
443
|
},
|
|
444
444
|
});
|
|
445
|
+
export const browserPressKey = defineTool({
|
|
446
|
+
name: "browser_press_key",
|
|
447
|
+
description: `Simulate a key press.
|
|
448
|
+
Restrictions: Must specify a valid key name; optional target selector.
|
|
449
|
+
Valid: Press Enter in #search.
|
|
450
|
+
Invalid: Press a key without specifying the key name.`,
|
|
451
|
+
inputSchema: {
|
|
452
|
+
selector: z.string().describe("The CSS selector of the element to focus.").optional(),
|
|
453
|
+
key: z.string().describe('Name of the key to press or a character to generate, such as `ArrowLeft` or `a`'),
|
|
454
|
+
},
|
|
455
|
+
handle: async (context, params) => {
|
|
456
|
+
const session = context.getSession(params.sessionId);
|
|
457
|
+
if (!session?.page) {
|
|
458
|
+
return wrapMcpBrowserResponse("No active browser session found. Please create a browser session first.");
|
|
459
|
+
}
|
|
460
|
+
try {
|
|
461
|
+
if (params.selector) {
|
|
462
|
+
await session.page.focus(params.selector);
|
|
463
|
+
}
|
|
464
|
+
await session.page.keyboard.press(params.key);
|
|
465
|
+
const accessibilitySnapshot = await snapshot(session.page);
|
|
466
|
+
return {
|
|
467
|
+
content: [
|
|
468
|
+
{
|
|
469
|
+
type: "text",
|
|
470
|
+
text: params.selector ? `Focus on the ${params.selector} and press ${params.key}` : `press ${params.key}`,
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
type: "text",
|
|
474
|
+
text: accessibilitySnapshot,
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
return wrapMcpBrowserResponse(`Failed to press key: ${error.message}`);
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
});
|