@democratize-quality/mcp-server 1.2.0 → 1.2.1

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.
Files changed (56) hide show
  1. package/cli.js +248 -0
  2. package/package.json +7 -5
  3. package/src/chatmodes//360/237/214/220 api-generator.chatmode.md" +409 -0
  4. package/src/chatmodes//360/237/214/220 api-healer.chatmode.md" +494 -0
  5. package/src/chatmodes//360/237/214/220 api-planner.chatmode.md" +954 -0
  6. package/src/config/environments/api-only.js +72 -0
  7. package/src/config/environments/development.js +73 -0
  8. package/src/config/environments/production.js +88 -0
  9. package/src/config/index.js +360 -0
  10. package/src/config/server.js +60 -0
  11. package/src/config/tools/api.js +86 -0
  12. package/src/config/tools/browser.js +109 -0
  13. package/src/config/tools/default.js +51 -0
  14. package/src/docs/Agent_README.md +310 -0
  15. package/src/docs/QUICK_REFERENCE.md +111 -0
  16. package/src/server.ts +234 -0
  17. package/src/services/browserService.js +344 -0
  18. package/src/skills/api-planning/SKILL.md +224 -0
  19. package/src/skills/test-execution/SKILL.md +777 -0
  20. package/src/skills/test-generation/SKILL.md +309 -0
  21. package/src/skills/test-healing/SKILL.md +405 -0
  22. package/src/tools/api/api-generator.js +1884 -0
  23. package/src/tools/api/api-healer.js +636 -0
  24. package/src/tools/api/api-planner.js +2617 -0
  25. package/src/tools/api/api-project-setup.js +332 -0
  26. package/src/tools/api/api-request.js +660 -0
  27. package/src/tools/api/api-session-report.js +1297 -0
  28. package/src/tools/api/api-session-status.js +414 -0
  29. package/src/tools/api/prompts/README.md +293 -0
  30. package/src/tools/api/prompts/generation-prompts.js +722 -0
  31. package/src/tools/api/prompts/healing-prompts.js +214 -0
  32. package/src/tools/api/prompts/index.js +44 -0
  33. package/src/tools/api/prompts/orchestrator.js +353 -0
  34. package/src/tools/api/prompts/validation-rules.js +358 -0
  35. package/src/tools/base/ToolBase.js +249 -0
  36. package/src/tools/base/ToolRegistry.js +288 -0
  37. package/src/tools/browser/advanced/browser-console.js +403 -0
  38. package/src/tools/browser/advanced/browser-dialog.js +338 -0
  39. package/src/tools/browser/advanced/browser-evaluate.js +356 -0
  40. package/src/tools/browser/advanced/browser-file.js +499 -0
  41. package/src/tools/browser/advanced/browser-keyboard.js +362 -0
  42. package/src/tools/browser/advanced/browser-mouse.js +351 -0
  43. package/src/tools/browser/advanced/browser-network.js +440 -0
  44. package/src/tools/browser/advanced/browser-pdf.js +426 -0
  45. package/src/tools/browser/advanced/browser-tabs.js +516 -0
  46. package/src/tools/browser/advanced/browser-wait.js +397 -0
  47. package/src/tools/browser/click.js +187 -0
  48. package/src/tools/browser/close.js +79 -0
  49. package/src/tools/browser/dom.js +89 -0
  50. package/src/tools/browser/launch.js +86 -0
  51. package/src/tools/browser/navigate.js +289 -0
  52. package/src/tools/browser/screenshot.js +370 -0
  53. package/src/tools/browser/type.js +193 -0
  54. package/src/tools/index.js +114 -0
  55. package/src/utils/agentInstaller.js +437 -0
  56. package/src/utils/browserHelpers.js +102 -0
@@ -0,0 +1,351 @@
1
+ /**
2
+ * Copyright (C) 2025 Democratize Quality
3
+ *
4
+ * This file is part of Democratize Quality MCP Server.
5
+ *
6
+ * Democratize Quality MCP Server is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * Democratize Quality MCP Server is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with Democratize Quality MCP Server. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ const ToolBase = require('../../base/ToolBase');
21
+ const browserService = require('../../../services/browserService');
22
+
23
+ /**
24
+ * Enhanced Mouse Tool - Provides precise mouse interactions with coordinate support
25
+ * Inspired by Playwright MCP mouse capabilities
26
+ */
27
+ class BrowserMouseTool extends ToolBase {
28
+ static definition = {
29
+ name: "browser_mouse",
30
+ description: "Perform mouse actions including clicks, moves, and drags with precise coordinate control. Supports both CSS selectors and direct coordinates.",
31
+ input_schema: {
32
+ type: "object",
33
+ properties: {
34
+ browserId: {
35
+ type: "string",
36
+ description: "The ID of the browser instance"
37
+ },
38
+ action: {
39
+ type: "string",
40
+ enum: ["click", "move", "drag", "hover", "rightClick", "doubleClick"],
41
+ description: "The mouse action to perform"
42
+ },
43
+ target: {
44
+ type: "object",
45
+ oneOf: [
46
+ {
47
+ type: "object",
48
+ properties: {
49
+ type: { type: "string", enum: ["coordinates"] },
50
+ x: { type: "number", description: "X coordinate" },
51
+ y: { type: "number", description: "Y coordinate" }
52
+ },
53
+ required: ["type", "x", "y"]
54
+ },
55
+ {
56
+ type: "object",
57
+ properties: {
58
+ type: { type: "string", enum: ["selector"] },
59
+ selector: { type: "string", description: "CSS selector" },
60
+ offset: {
61
+ type: "object",
62
+ properties: {
63
+ x: { type: "number", description: "X offset from element center" },
64
+ y: { type: "number", description: "Y offset from element center" }
65
+ }
66
+ }
67
+ },
68
+ required: ["type", "selector"]
69
+ }
70
+ ],
71
+ description: "Target for the mouse action - either coordinates or CSS selector"
72
+ },
73
+ dragTo: {
74
+ type: "object",
75
+ properties: {
76
+ x: { type: "number", description: "End X coordinate for drag" },
77
+ y: { type: "number", description: "End Y coordinate for drag" }
78
+ },
79
+ description: "End coordinates for drag actions"
80
+ },
81
+ button: {
82
+ type: "string",
83
+ enum: ["left", "right", "middle"],
84
+ default: "left",
85
+ description: "Mouse button to use"
86
+ },
87
+ modifiers: {
88
+ type: "array",
89
+ items: { type: "string", enum: ["ctrl", "shift", "alt", "meta"] },
90
+ description: "Keyboard modifiers to hold during action"
91
+ }
92
+ },
93
+ required: ["browserId", "action", "target"]
94
+ },
95
+ output_schema: {
96
+ type: "object",
97
+ properties: {
98
+ success: { type: "boolean", description: "Whether the mouse action was successful" },
99
+ action: { type: "string", description: "The action that was performed" },
100
+ coordinates: {
101
+ type: "object",
102
+ properties: {
103
+ x: { type: "number" },
104
+ y: { type: "number" }
105
+ },
106
+ description: "Final coordinates of the mouse action"
107
+ },
108
+ element: { type: "string", description: "CSS selector if targeting an element" },
109
+ browserId: { type: "string", description: "Browser instance ID" }
110
+ },
111
+ required: ["success", "action", "browserId"]
112
+ }
113
+ };
114
+
115
+ async execute(parameters) {
116
+ const { browserId, action, target, dragTo, button = 'left', modifiers = [] } = parameters;
117
+
118
+ const browser = browserService.getBrowserInstance(browserId);
119
+ if (!browser) {
120
+ throw new Error(`Browser instance '${browserId}' not found`);
121
+ }
122
+
123
+ const client = browser.client;
124
+
125
+ // Calculate target coordinates
126
+ let targetX, targetY;
127
+ let elementInfo = null;
128
+
129
+ if (target.type === 'coordinates') {
130
+ targetX = target.x;
131
+ targetY = target.y;
132
+ } else if (target.type === 'selector') {
133
+ // Get element bounds using DOM API
134
+ const result = await client.Runtime.evaluate({
135
+ expression: `
136
+ (() => {
137
+ const element = document.querySelector('${target.selector}');
138
+ if (!element) return null;
139
+ const rect = element.getBoundingClientRect();
140
+ return {
141
+ x: rect.left + rect.width / 2,
142
+ y: rect.top + rect.height / 2,
143
+ width: rect.width,
144
+ height: rect.height,
145
+ selector: '${target.selector}'
146
+ };
147
+ })()
148
+ `
149
+ });
150
+
151
+ if (!result.result.value) {
152
+ throw new Error(`Element not found with selector: ${target.selector}`);
153
+ }
154
+
155
+ const elementData = result.result.value;
156
+ targetX = elementData.x + (target.offset?.x || 0);
157
+ targetY = elementData.y + (target.offset?.y || 0);
158
+ elementInfo = {
159
+ selector: target.selector,
160
+ bounds: elementData
161
+ };
162
+ }
163
+
164
+ // Convert modifiers to CDP format
165
+ const cdpModifiers = this.convertModifiers(modifiers);
166
+
167
+ // Perform the mouse action
168
+ let actionResult;
169
+
170
+ switch (action) {
171
+ case 'move':
172
+ await client.Input.dispatchMouseEvent({
173
+ type: 'mouseMoved',
174
+ x: targetX,
175
+ y: targetY,
176
+ modifiers: cdpModifiers
177
+ });
178
+ actionResult = { type: 'move', x: targetX, y: targetY };
179
+ break;
180
+
181
+ case 'click':
182
+ await client.Input.dispatchMouseEvent({
183
+ type: 'mousePressed',
184
+ x: targetX,
185
+ y: targetY,
186
+ button: button,
187
+ clickCount: 1,
188
+ modifiers: cdpModifiers
189
+ });
190
+ await client.Input.dispatchMouseEvent({
191
+ type: 'mouseReleased',
192
+ x: targetX,
193
+ y: targetY,
194
+ button: button,
195
+ clickCount: 1,
196
+ modifiers: cdpModifiers
197
+ });
198
+ actionResult = { type: 'click', x: targetX, y: targetY };
199
+ break;
200
+
201
+ case 'doubleClick':
202
+ // First click
203
+ await client.Input.dispatchMouseEvent({
204
+ type: 'mousePressed',
205
+ x: targetX,
206
+ y: targetY,
207
+ button: button,
208
+ clickCount: 1,
209
+ modifiers: cdpModifiers
210
+ });
211
+ await client.Input.dispatchMouseEvent({
212
+ type: 'mouseReleased',
213
+ x: targetX,
214
+ y: targetY,
215
+ button: button,
216
+ clickCount: 1,
217
+ modifiers: cdpModifiers
218
+ });
219
+
220
+ // Second click (double click)
221
+ await client.Input.dispatchMouseEvent({
222
+ type: 'mousePressed',
223
+ x: targetX,
224
+ y: targetY,
225
+ button: button,
226
+ clickCount: 2,
227
+ modifiers: cdpModifiers
228
+ });
229
+ await client.Input.dispatchMouseEvent({
230
+ type: 'mouseReleased',
231
+ x: targetX,
232
+ y: targetY,
233
+ button: button,
234
+ clickCount: 2,
235
+ modifiers: cdpModifiers
236
+ });
237
+ actionResult = { type: 'doubleClick', x: targetX, y: targetY };
238
+ break;
239
+
240
+ case 'rightClick':
241
+ await client.Input.dispatchMouseEvent({
242
+ type: 'mousePressed',
243
+ x: targetX,
244
+ y: targetY,
245
+ button: 'right',
246
+ clickCount: 1,
247
+ modifiers: cdpModifiers
248
+ });
249
+ await client.Input.dispatchMouseEvent({
250
+ type: 'mouseReleased',
251
+ x: targetX,
252
+ y: targetY,
253
+ button: 'right',
254
+ clickCount: 1,
255
+ modifiers: cdpModifiers
256
+ });
257
+ actionResult = { type: 'rightClick', x: targetX, y: targetY };
258
+ break;
259
+
260
+ case 'hover':
261
+ await client.Input.dispatchMouseEvent({
262
+ type: 'mouseMoved',
263
+ x: targetX,
264
+ y: targetY,
265
+ modifiers: cdpModifiers
266
+ });
267
+ actionResult = { type: 'hover', x: targetX, y: targetY };
268
+ break;
269
+
270
+ case 'drag':
271
+ if (!dragTo) {
272
+ throw new Error('dragTo coordinates required for drag action');
273
+ }
274
+
275
+ // Start drag
276
+ await client.Input.dispatchMouseEvent({
277
+ type: 'mousePressed',
278
+ x: targetX,
279
+ y: targetY,
280
+ button: button,
281
+ clickCount: 1,
282
+ modifiers: cdpModifiers
283
+ });
284
+
285
+ // Move to end position
286
+ await client.Input.dispatchMouseEvent({
287
+ type: 'mouseMoved',
288
+ x: dragTo.x,
289
+ y: dragTo.y,
290
+ modifiers: cdpModifiers
291
+ });
292
+
293
+ // Release
294
+ await client.Input.dispatchMouseEvent({
295
+ type: 'mouseReleased',
296
+ x: dragTo.x,
297
+ y: dragTo.y,
298
+ button: button,
299
+ clickCount: 1,
300
+ modifiers: cdpModifiers
301
+ });
302
+
303
+ actionResult = {
304
+ type: 'drag',
305
+ from: { x: targetX, y: targetY },
306
+ to: { x: dragTo.x, y: dragTo.y }
307
+ };
308
+ break;
309
+
310
+ default:
311
+ throw new Error(`Unsupported mouse action: ${action}`);
312
+ }
313
+
314
+ return {
315
+ success: true,
316
+ action: action,
317
+ coordinates: action === 'drag' ? actionResult : { x: targetX, y: targetY },
318
+ element: elementInfo?.selector,
319
+ browserId: browserId,
320
+ actionDetails: actionResult
321
+ };
322
+ }
323
+
324
+ /**
325
+ * Convert modifier keys to CDP format
326
+ */
327
+ convertModifiers(modifiers) {
328
+ let cdpModifiers = 0;
329
+
330
+ for (const modifier of modifiers) {
331
+ switch (modifier) {
332
+ case 'ctrl':
333
+ cdpModifiers |= 2; // Ctrl
334
+ break;
335
+ case 'shift':
336
+ cdpModifiers |= 8; // Shift
337
+ break;
338
+ case 'alt':
339
+ cdpModifiers |= 1; // Alt
340
+ break;
341
+ case 'meta':
342
+ cdpModifiers |= 4; // Meta/Cmd
343
+ break;
344
+ }
345
+ }
346
+
347
+ return cdpModifiers;
348
+ }
349
+ }
350
+
351
+ module.exports = BrowserMouseTool;