@ricardodeazambuja/browser-mcp-server 1.0.3 → 1.4.0
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/CHANGELOG-v1.3.0.md +42 -0
- package/CHANGELOG-v1.4.0.md +8 -0
- package/README.md +271 -45
- package/package.json +11 -10
- package/plugins/.gitkeep +0 -0
- package/src/.gitkeep +0 -0
- package/src/browser.js +152 -0
- package/src/cdp.js +58 -0
- package/src/index.js +126 -0
- package/src/tools/.gitkeep +0 -0
- package/src/tools/console.js +139 -0
- package/src/tools/docs.js +1611 -0
- package/src/tools/index.js +60 -0
- package/src/tools/info.js +139 -0
- package/src/tools/interaction.js +126 -0
- package/src/tools/keyboard.js +27 -0
- package/src/tools/media.js +264 -0
- package/src/tools/mouse.js +104 -0
- package/src/tools/navigation.js +72 -0
- package/src/tools/network.js +552 -0
- package/src/tools/pages.js +149 -0
- package/src/tools/performance.js +517 -0
- package/src/tools/security.js +470 -0
- package/src/tools/storage.js +467 -0
- package/src/tools/system.js +196 -0
- package/src/utils.js +131 -0
- package/tests/.gitkeep +0 -0
- package/tests/fixtures/.gitkeep +0 -0
- package/tests/fixtures/test-media.html +35 -0
- package/tests/fixtures/test-network.html +48 -0
- package/tests/fixtures/test-performance.html +61 -0
- package/tests/fixtures/test-security.html +33 -0
- package/tests/fixtures/test-storage.html +76 -0
- package/tests/run-all.js +50 -0
- package/{test-browser-automation.js → tests/test-browser-automation.js} +44 -5
- package/{test-mcp.js → tests/test-mcp.js} +9 -4
- package/tests/test-media-tools.js +168 -0
- package/tests/test-network.js +212 -0
- package/tests/test-performance.js +254 -0
- package/tests/test-security.js +203 -0
- package/tests/test-storage.js +192 -0
- package/CHANGELOG-v1.0.2.md +0 -126
- package/browser-mcp-server-playwright.js +0 -792
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const { connectToBrowser } = require('../browser');
|
|
2
|
+
|
|
3
|
+
const definitions = [
|
|
4
|
+
{
|
|
5
|
+
name: 'browser_mouse_move',
|
|
6
|
+
description: 'Move the mouse to specific coordinates (see browser_docs)',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
x: { type: 'number', description: 'X coordinate' },
|
|
11
|
+
y: { type: 'number', description: 'Y coordinate' }
|
|
12
|
+
},
|
|
13
|
+
required: ['x', 'y'],
|
|
14
|
+
additionalProperties: false,
|
|
15
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'browser_mouse_click',
|
|
20
|
+
description: 'Click the mouse at specific coordinates or on current position (see browser_docs)',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
x: { type: 'number', description: 'Optional X coordinate' },
|
|
25
|
+
y: { type: 'number', description: 'Optional Y coordinate' },
|
|
26
|
+
button: { type: 'string', description: 'left, right, or middle', default: 'left' },
|
|
27
|
+
clickCount: { type: 'number', description: '1 for single click, 2 for double click', default: 1 }
|
|
28
|
+
},
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'browser_mouse_drag',
|
|
35
|
+
description: 'Drag from one position to another (see browser_docs)',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
fromX: { type: 'number', description: 'Starting X coordinate' },
|
|
40
|
+
fromY: { type: 'number', description: 'Starting Y coordinate' },
|
|
41
|
+
toX: { type: 'number', description: 'Ending X coordinate' },
|
|
42
|
+
toY: { type: 'number', description: 'Ending Y coordinate' }
|
|
43
|
+
},
|
|
44
|
+
required: ['fromX', 'fromY', 'toX', 'toY'],
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'browser_mouse_wheel',
|
|
51
|
+
description: 'Scroll the mouse wheel (see browser_docs)',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
deltaX: { type: 'number', description: 'Horizontal scroll amount' },
|
|
56
|
+
deltaY: { type: 'number', description: 'Vertical scroll amount' }
|
|
57
|
+
},
|
|
58
|
+
required: ['deltaX', 'deltaY'],
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const handlers = {
|
|
66
|
+
browser_mouse_move: async (args) => {
|
|
67
|
+
const { page } = await connectToBrowser();
|
|
68
|
+
await page.mouse.move(args.x, args.y);
|
|
69
|
+
return { content: [{ type: 'text', text: `Moved mouse to ${args.x}, ${args.y}` }] };
|
|
70
|
+
},
|
|
71
|
+
browser_mouse_click: async (args) => {
|
|
72
|
+
const { page } = await connectToBrowser();
|
|
73
|
+
if (args.x !== undefined && args.y !== undefined) {
|
|
74
|
+
await page.mouse.click(args.x, args.y, {
|
|
75
|
+
button: args.button || 'left',
|
|
76
|
+
clickCount: args.clickCount || 1
|
|
77
|
+
});
|
|
78
|
+
return { content: [{ type: 'text', text: `Clicked at ${args.x}, ${args.y}` }] };
|
|
79
|
+
} else {
|
|
80
|
+
// Click at current position
|
|
81
|
+
// Note: page.mouse.click() without coords clicks at current position
|
|
82
|
+
await page.mouse.click(undefined, undefined, {
|
|
83
|
+
button: args.button || 'left',
|
|
84
|
+
clickCount: args.clickCount || 1
|
|
85
|
+
});
|
|
86
|
+
return { content: [{ type: 'text', text: `Clicked at current mouse position` }] };
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
browser_mouse_drag: async (args) => {
|
|
90
|
+
const { page } = await connectToBrowser();
|
|
91
|
+
await page.mouse.move(args.fromX, args.fromY);
|
|
92
|
+
await page.mouse.down();
|
|
93
|
+
await page.mouse.move(args.toX, args.toY);
|
|
94
|
+
await page.mouse.up();
|
|
95
|
+
return { content: [{ type: 'text', text: `Dragged from ${args.fromX},${args.fromY} to ${args.toX},${args.toY}` }] };
|
|
96
|
+
},
|
|
97
|
+
browser_mouse_wheel: async (args) => {
|
|
98
|
+
const { page } = await connectToBrowser();
|
|
99
|
+
await page.mouse.wheel(args.deltaX, args.deltaY);
|
|
100
|
+
return { content: [{ type: 'text', text: `Scrolled wheel by ${args.deltaX}, ${args.deltaY}` }] };
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
module.exports = { definitions, handlers };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const { connectToBrowser } = require('../browser');
|
|
2
|
+
|
|
3
|
+
const definitions = [
|
|
4
|
+
{
|
|
5
|
+
name: 'browser_navigate',
|
|
6
|
+
description: 'Navigate to a URL in the browser (see browser_docs)',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
url: { type: 'string', description: 'The URL to navigate to' }
|
|
11
|
+
},
|
|
12
|
+
required: ['url'],
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'browser_reload',
|
|
19
|
+
description: 'Reload the current page (see browser_docs)',
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {},
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'browser_go_back',
|
|
29
|
+
description: 'Navigate back in history (see browser_docs)',
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'browser_go_forward',
|
|
39
|
+
description: 'Navigate forward in history (see browser_docs)',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {},
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const handlers = {
|
|
50
|
+
browser_navigate: async (args) => {
|
|
51
|
+
const { page } = await connectToBrowser();
|
|
52
|
+
await page.goto(args.url, { waitUntil: 'domcontentloaded' });
|
|
53
|
+
return { content: [{ type: 'text', text: `Navigated to ${args.url}` }] };
|
|
54
|
+
},
|
|
55
|
+
browser_reload: async (args) => {
|
|
56
|
+
const { page } = await connectToBrowser();
|
|
57
|
+
await page.reload({ waitUntil: 'domcontentloaded' });
|
|
58
|
+
return { content: [{ type: 'text', text: `Reloaded page` }] };
|
|
59
|
+
},
|
|
60
|
+
browser_go_back: async (args) => {
|
|
61
|
+
const { page } = await connectToBrowser();
|
|
62
|
+
await page.goBack({ waitUntil: 'domcontentloaded' });
|
|
63
|
+
return { content: [{ type: 'text', text: `Navigated back` }] };
|
|
64
|
+
},
|
|
65
|
+
browser_go_forward: async (args) => {
|
|
66
|
+
const { page } = await connectToBrowser();
|
|
67
|
+
await page.goForward({ waitUntil: 'domcontentloaded' });
|
|
68
|
+
return { content: [{ type: 'text', text: `Navigated forward` }] };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
module.exports = { definitions, handlers };
|