@democratize-quality/mcp-server 1.0.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.
Files changed (48) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +423 -0
  3. package/browserControl.js +113 -0
  4. package/cli.js +187 -0
  5. package/docs/api/tool-reference.md +317 -0
  6. package/docs/api_tools_usage.md +477 -0
  7. package/docs/development/adding-tools.md +274 -0
  8. package/docs/development/configuration.md +332 -0
  9. package/docs/examples/authentication.md +124 -0
  10. package/docs/examples/basic-automation.md +105 -0
  11. package/docs/getting-started.md +214 -0
  12. package/docs/index.md +61 -0
  13. package/mcpServer.js +280 -0
  14. package/package.json +83 -0
  15. package/run-server.js +140 -0
  16. package/src/config/environments/api-only.js +53 -0
  17. package/src/config/environments/development.js +54 -0
  18. package/src/config/environments/production.js +69 -0
  19. package/src/config/index.js +341 -0
  20. package/src/config/server.js +41 -0
  21. package/src/config/tools/api.js +67 -0
  22. package/src/config/tools/browser.js +90 -0
  23. package/src/config/tools/default.js +32 -0
  24. package/src/services/browserService.js +325 -0
  25. package/src/tools/api/api-request.js +641 -0
  26. package/src/tools/api/api-session-report.js +1262 -0
  27. package/src/tools/api/api-session-status.js +395 -0
  28. package/src/tools/base/ToolBase.js +230 -0
  29. package/src/tools/base/ToolRegistry.js +269 -0
  30. package/src/tools/browser/advanced/browser-console.js +384 -0
  31. package/src/tools/browser/advanced/browser-dialog.js +319 -0
  32. package/src/tools/browser/advanced/browser-evaluate.js +337 -0
  33. package/src/tools/browser/advanced/browser-file.js +480 -0
  34. package/src/tools/browser/advanced/browser-keyboard.js +343 -0
  35. package/src/tools/browser/advanced/browser-mouse.js +332 -0
  36. package/src/tools/browser/advanced/browser-network.js +421 -0
  37. package/src/tools/browser/advanced/browser-pdf.js +407 -0
  38. package/src/tools/browser/advanced/browser-tabs.js +497 -0
  39. package/src/tools/browser/advanced/browser-wait.js +378 -0
  40. package/src/tools/browser/click.js +168 -0
  41. package/src/tools/browser/close.js +60 -0
  42. package/src/tools/browser/dom.js +70 -0
  43. package/src/tools/browser/launch.js +67 -0
  44. package/src/tools/browser/navigate.js +270 -0
  45. package/src/tools/browser/screenshot.js +351 -0
  46. package/src/tools/browser/type.js +174 -0
  47. package/src/tools/index.js +95 -0
  48. package/src/utils/browserHelpers.js +83 -0
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2025, Democratize Quality Team
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,423 @@
1
+ # 🎯 Democratize Quality MCP Server
2
+
3
+ A comprehensive **Model Context Protocol (MCP)** server that democratizes quality through comprehensive API testing capabilities.
4
+
5
+ ## 📋 Overview
6
+
7
+ This MCP server offers **3 powerful API testing tools** for comprehensive API quality assurance:
8
+
9
+ ### 🔗 API Testing Tools
10
+ - **`api_request`**: HTTP requests with validation and session management
11
+ - **`api_session_status`**: Query API test session status and logs
12
+ - **`api_session_report`**: Generate comprehensive HTML test reports
13
+
14
+ **Key Features:**
15
+ - ✅ **Enhanced Validation**: Shows "expected vs actual" values in validation failures
16
+ - 🔗 **Request Chaining**: Use response data in subsequent requests
17
+ - 📊 **Session Management**: Track API test sequences across multiple requests
18
+ - 📈 **HTML Reports**: Beautiful, interactive test reports with detailed validation results
19
+ - 🎯 **Comprehensive Testing**: Support for all HTTP methods with advanced validation options
20
+
21
+ ## �️ Installation & Setup
22
+
23
+ ### Prerequisites
24
+ - Node.js 14+
25
+ - MCP-compatible client (Claude Desktop, VS Code, etc.)
26
+
27
+ ### Quick Start
28
+
29
+ **Option 1: Use with npx (Recommended)**
30
+ ```bash
31
+ # Run directly without installation
32
+ npx @democratize-quality/mcp-server --help
33
+
34
+ # Use in Claude Desktop (see integration section below)
35
+ ```
36
+
37
+ **Option 2: Global Installation**
38
+ ```bash
39
+ # Install globally
40
+ npm install -g @democratize-quality/mcp-server
41
+
42
+ # Then run anywhere
43
+ democratize-quality-mcp --help
44
+ dq-mcp-server --help
45
+ ```
46
+
47
+ **Option 3: Local Development**
48
+ ```bash
49
+ # Clone and install dependencies
50
+ git clone https://github.com/democratize-quality/mcp-server.git
51
+ cd mcp-server
52
+ npm install
53
+
54
+ # Test the server
55
+ npm test
56
+
57
+ # Start the server (API-only mode by default)
58
+ npm start
59
+ ```
60
+
61
+ ## 🔌 Integration Methods
62
+
63
+ ### Claude Desktop Integration (Recommended)
64
+
65
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json`):
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "democratize-quality": {
71
+ "command": "npx",
72
+ "args": ["@democratize-quality/mcp-server"],
73
+ "env": {
74
+ "NODE_ENV": "production"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ > **Note:** The server runs in `api-only` mode by default, providing secure and lightweight API testing capabilities.
82
+
83
+ ### Alternative Integration Methods
84
+
85
+ **Global Installation:**
86
+ ```bash
87
+ npm install -g @democratize-quality/mcp-server
88
+ ```
89
+
90
+ Then configure Claude Desktop:
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "democratize-quality": {
95
+ "command": "democratize-quality-mcp"
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ **MCP Inspector (Development/Testing):**
102
+ ```bash
103
+ npx @modelcontextprotocol/inspector npx @democratize-quality/mcp-server
104
+ ```
105
+
106
+ **Direct Usage:**
107
+ ```bash
108
+ # Run the server directly
109
+ npx @democratize-quality/mcp-server
110
+
111
+ # Or if installed globally
112
+ democratize-quality-mcp
113
+ ```
114
+
115
+ ## 📚 Usage Examples
116
+
117
+ ### Basic API Testing
118
+
119
+ ```javascript
120
+ // Single API request with validation
121
+ await tools.api_request({
122
+ method: "GET",
123
+ url: "https://jsonplaceholder.typicode.com/users/1",
124
+ expect: {
125
+ status: 200,
126
+ contentType: "application/json"
127
+ }
128
+ })
129
+ ```
130
+
131
+ ### Advanced API Testing with Session Management
132
+
133
+ ```javascript
134
+ // 1. Start a test session
135
+ await tools.api_request({
136
+ sessionId: "user-workflow-test",
137
+ method: "POST",
138
+ url: "https://jsonplaceholder.typicode.com/users",
139
+ data: {
140
+ name: "John Doe",
141
+ email: "john@example.com"
142
+ },
143
+ expect: { status: 201 }
144
+ })
145
+
146
+ // 2. Follow up request in same session
147
+ await tools.api_request({
148
+ sessionId: "user-workflow-test",
149
+ method: "GET",
150
+ url: "https://jsonplaceholder.typicode.com/users/1",
151
+ expect: {
152
+ status: 200,
153
+ body: { name: "John Doe" }
154
+ }
155
+ })
156
+
157
+ // 3. Generate comprehensive HTML report
158
+ await tools.api_session_report({
159
+ sessionId: "user-workflow-test",
160
+ outputPath: "user_workflow_test_report.html"
161
+ })
162
+ ```
163
+
164
+ ### Request Chaining Example
165
+
166
+ ```javascript
167
+ // Chain requests using response data
168
+ await tools.api_request({
169
+ sessionId: "chained-test",
170
+ chain: [
171
+ {
172
+ name: "create_user",
173
+ method: "POST",
174
+ url: "https://jsonplaceholder.typicode.com/users",
175
+ data: { name: "Jane Doe", email: "jane@example.com" },
176
+ expect: { status: 201 },
177
+ extract: { userId: "id" }
178
+ },
179
+ {
180
+ name: "get_user",
181
+ method: "GET",
182
+ url: "https://jsonplaceholder.typicode.com/users/{{ create_user.userId }}",
183
+ expect: {
184
+ status: 200,
185
+ body: { name: "Jane Doe" }
186
+ }
187
+ }
188
+ ]
189
+ })
190
+ ```
191
+
192
+ 📖 **For comprehensive API testing examples and advanced usage patterns, see:** [API Tools Usage Guide](docs/api_tools_usage.md)
193
+
194
+ ## ⚙️ Configuration
195
+
196
+ ### Environment Settings
197
+
198
+ The server runs in **API-only mode** by default for secure, lightweight deployments focused on API testing.
199
+
200
+ ```bash
201
+ NODE_ENV=production # Default: API-only mode
202
+ OUTPUT_DIR=./output # Output directory for reports
203
+ MCP_FEATURES_ENABLEDEBUGMODE=true # Enable debug logging
204
+ ```
205
+
206
+ ### Command Line Options
207
+ ```bash
208
+ npx @democratize-quality/mcp-server [options]
209
+
210
+ Options:
211
+ --help, -h Show help
212
+ --version, -v Show version
213
+ --debug Enable debug mode
214
+ --port <number> Set server port
215
+ ```
216
+
217
+ ### Configuration Examples
218
+
219
+ #### Basic Claude Desktop Configuration
220
+ ```json
221
+ {
222
+ "mcpServers": {
223
+ "democratize-quality": {
224
+ "command": "npx",
225
+ "args": ["@democratize-quality/mcp-server"],
226
+ "env": {
227
+ "OUTPUT_DIR": "~/api-test-reports"
228
+ }
229
+ }
230
+ }
231
+ }
232
+ ```
233
+
234
+ #### Debug Mode Configuration
235
+ ```json
236
+ {
237
+ "mcpServers": {
238
+ "democratize-quality": {
239
+ "command": "npx",
240
+ "args": ["@democratize-quality/mcp-server", "--debug"],
241
+ "env": {
242
+ "MCP_FEATURES_ENABLEDEBUGMODE": "true"
243
+ }
244
+ }
245
+ }
246
+ }
247
+ ```
248
+
249
+ ### Output Directory Behavior
250
+ - **VS Code/Local**: Uses `./output` in your project directory
251
+ - **Claude Desktop**: Uses `~/.mcp-browser-control` (in your home directory)
252
+ - **Custom**: Set `OUTPUT_DIR` environment variable to specify location
253
+
254
+ > **Note:** API test reports and session data will be saved to the configured output directory.
255
+
256
+ ## 🔧 Troubleshooting
257
+
258
+ ### Common Issues
259
+
260
+ **1. "No such file or directory: mkdir /mcp-output"**
261
+ - This happens when Claude Desktop runs the server with restricted permissions
262
+ - The server automatically creates `~/.mcp-browser-control` in your home directory
263
+ - API test reports will be saved there instead of your project folder
264
+
265
+ **2. Output files not appearing in expected location**
266
+ - Check the actual output directory: `~/.mcp-browser-control/`
267
+ - You can set a custom location with: `OUTPUT_DIR=/your/custom/path`
268
+
269
+ **3. Server not starting in Claude Desktop**
270
+ - Verify the npx package is published: `npx @democratize-quality/mcp-server --help`
271
+ - Check Claude Desktop logs for detailed error messages
272
+ - Try running directly in terminal first to test functionality
273
+
274
+ **4. API validation failures not showing details**
275
+ - The enhanced validation feature shows "expected vs actual" values
276
+ - Check the generated HTML reports for detailed comparison views
277
+ - Enable debug mode for more detailed logging
278
+
279
+ ### Debug Mode
280
+
281
+ ```bash
282
+ # Enable debug output with CLI tool
283
+ npx @democratize-quality/mcp-server --debug
284
+
285
+ # Or via environment variable
286
+ MCP_FEATURES_ENABLEDEBUGMODE=true node mcpServer.js
287
+ ```
288
+
289
+ **Logging Levels:**
290
+ - **Production Mode**: Shows only essential startup messages and errors
291
+ - **Debug Mode**: Shows detailed API request/response logs and validation details
292
+
293
+ ## 🔍 Advanced API Testing Features
294
+
295
+ - **📊 Session Management**: Track API test sequences across multiple requests
296
+ - **🔗 Request Chaining**: Use response data from one request in subsequent requests
297
+ - **✅ Enhanced Validation**: Shows "expected vs actual" values when validation fails
298
+ - **📈 Interactive Reports**: Beautiful HTML test reports with detailed validation results
299
+ - **🎯 Comprehensive Testing**: Support for all HTTP methods (GET, POST, PUT, DELETE, PATCH, etc.)
300
+ - **🔄 Response Extraction**: Extract and reuse data from API responses
301
+ - **📝 Detailed Logging**: Complete request/response logging for debugging
302
+
303
+ ## 📄 License
304
+
305
+ ISC License
306
+
307
+ ---
308
+
309
+ **Ready to democratize quality through comprehensive API testing with MCP!** 🎯
310
+
311
+ ## 📚 Documentation
312
+
313
+ - [📖 Getting Started](docs/getting-started.md) - Quick start guide
314
+ - [🔧 Tool Reference](docs/api/tool-reference.md) - Complete tool documentation
315
+ - [🎯 API Tools Usage Guide](docs/api_tools_usage.md) - Comprehensive API testing examples and patterns
316
+ - [👨‍💻 Developer Guide](docs/development/adding-tools.md) - Extending the server
317
+ - [⚙️ Configuration](docs/development/configuration.md) - Advanced configuration
318
+ - [💡 Examples](docs/examples/) - Real-world usage examples
319
+
320
+ ## 🏗️ Architecture
321
+
322
+ ```
323
+ src/
324
+ ├── tools/api/ # API testing tools
325
+ ├── config/ # Configuration management
326
+ └── utils/ # Utility functions
327
+ ```
328
+
329
+ ### Key Features
330
+ - **Automatic Tool Discovery**: API tools are automatically loaded and registered
331
+ - **Configuration System**: Environment-based configuration with sensible defaults
332
+ - **Error Handling**: Comprehensive error handling and validation with detailed reporting
333
+ - **Session Management**: Track and manage API test sessions
334
+
335
+ ## 🔧 Development
336
+
337
+ ### Adding New API Tools
338
+ 1. Create tool file in `src/tools/api/`
339
+ 2. Extend `ToolBase` class
340
+ 3. Define tool schema and implementation
341
+ 4. Tools are automatically discovered!
342
+
343
+ ### Example API Tool
344
+ ```javascript
345
+ class MyApiTool extends ToolBase {
346
+ static definition = {
347
+ name: "my_api_tool",
348
+ description: "Performs API testing operations",
349
+ input_schema: { /* JSON schema */ },
350
+ output_schema: { /* JSON schema */ }
351
+ };
352
+
353
+ async execute(parameters) {
354
+ // API tool implementation
355
+ return { success: true, data: responseData };
356
+ }
357
+ }
358
+ ```
359
+
360
+ ## 🧪 Testing
361
+
362
+ ```bash
363
+ # Run tests
364
+ npm test
365
+
366
+ # Run with coverage
367
+ npm run test:coverage
368
+ ```
369
+
370
+ ## � Security Considerations
371
+
372
+ ### Default Security Posture
373
+ - **API-Only Mode**: Enabled by default for secure, lightweight deployments
374
+ - **HTTP Requests**: All API requests are performed using standard HTTP libraries
375
+ - **No File System Access**: API tools don't access local file system (except for report generation)
376
+ - **No Browser Automation**: No browser processes are launched in API-only mode
377
+
378
+ ### Production Deployment Recommendations
379
+ ```json
380
+ {
381
+ "mcpServers": {
382
+ "democratize-quality": {
383
+ "command": "npx",
384
+ "args": ["@democratize-quality/mcp-server"],
385
+ "env": {
386
+ "NODE_ENV": "production",
387
+ "OUTPUT_DIR": "~/api-test-reports"
388
+ }
389
+ }
390
+ }
391
+ }
392
+ ```
393
+
394
+ ### Security Levels
395
+ - **🟢 Low Risk**: API Tools - HTTP requests with validation and reporting
396
+
397
+ ### Best Practices
398
+ 1. **Secure Output Directory**: Ensure output directories have appropriate permissions
399
+ 2. **Regular Updates**: Keep the package updated for security patches
400
+ 3. **Environment Separation**: Use different configurations for development vs production
401
+ 4. **Monitoring**: Enable debug mode during initial deployment to monitor API usage
402
+
403
+ ## �📄 License
404
+
405
+ [License Type] - see [LICENSE](LICENSE) file for details
406
+
407
+ ## 🤝 Contributing
408
+
409
+ 1. Fork the repository
410
+ 2. Create a feature branch
411
+ 3. Add your changes with tests
412
+ 4. Update documentation
413
+ 5. Submit a pull request
414
+
415
+ ## 📞 Support
416
+
417
+ - [Issues](link-to-issues) - Bug reports and feature requests
418
+ - [Discussions](link-to-discussions) - Questions and community support
419
+ - [Documentation](docs/) - Comprehensive guides and references
420
+
421
+ ---
422
+
423
+ *Generated automatically from tool definitions and configuration*
@@ -0,0 +1,113 @@
1
+ // browserControl.js
2
+ const CDP = require('chrome-remote-interface');
3
+ const fs = require('fs');
4
+ const path = require('path'); // We need path for resolving userDataDir
5
+
6
+
7
+ async function automateBrowser() {
8
+ let chrome;
9
+ let client;
10
+ const { launch: launchChrome } = await import('chrome-launcher');
11
+ // Define your user data directory path
12
+ // IMPORTANT: Create this directory if it doesn't exist before running the script
13
+ const myUserDataDir = path.resolve(__dirname, './my_test_profile'); // This will create it in your project folder
14
+
15
+ try {
16
+ // Ensure the directory exists
17
+ if (!fs.existsSync(myUserDataDir)) {
18
+ fs.mkdirSync(myUserDataDir, { recursive: true });
19
+ console.log(`Created user data directory: ${myUserDataDir}`);
20
+ } else {
21
+ console.log(`Using existing user data directory: ${myUserDataDir}`);
22
+ }
23
+
24
+ console.log('Launching Chrome with remote debugging...');
25
+ chrome = await launchChrome({
26
+ port: 9222,
27
+ userDataDir: myUserDataDir, // <--- THE KEY CHANGE HERE
28
+ chromeFlags: [
29
+ // Set to false to see the browser UI
30
+ // For initial login, it's highly recommended to use false so you can interact
31
+ //'--headless=false', // Set this to 'new' or '' for headless mode once logged in
32
+ '--disable-gpu',
33
+ '--disable-setuid-sandbox',
34
+ '--no-sandbox'
35
+ ]
36
+ });
37
+ console.log(`Chrome launched on port ${chrome.port} using profile: ${myUserDataDir}`);
38
+
39
+ client = await CDP({ port: chrome.port });
40
+ console.log('Connected to Chrome DevTools Protocol.');
41
+
42
+ const { Page, Runtime, DOM, Network } = client; // Also enable Network for potential cookie inspection later
43
+
44
+ await Page.enable();
45
+ await Runtime.enable();
46
+ await DOM.enable();
47
+ await Network.enable(); // Enable Network domain
48
+
49
+ console.log('Page, Runtime, DOM, and Network domains enabled.');
50
+
51
+ const url = 'https://www.saucedemo.com'; // You can change this to your company login page
52
+ console.log(`Navigating to: ${url}`);
53
+ await Page.navigate({ url: url });
54
+ await Page.loadEventFired();
55
+ console.log('Page loaded.');
56
+
57
+ // --- Authentication Step ---
58
+ // FIRST RUN:
59
+ // When you run this for the first time with `--headless=false`,
60
+ // a Chrome window will open. Manually navigate to your company's login page
61
+ // and sign in. Complete all login steps (username, password, MFA, SSO etc.).
62
+ // Once logged in, DO NOT close the browser manually.
63
+ // Let the script finish, or press Ctrl+C to trigger the finally block.
64
+ // The script will then close Chrome, and the session state will be saved
65
+ // in 'my_test_profile' directory.
66
+
67
+ // SUBSEQUENT RUNS:
68
+ // For subsequent runs, you can change `--headless=false` to `--headless=new`
69
+ // (or just remove it if you prefer `chrome-launcher`'s default headless behavior).
70
+ // Chrome will launch, load the saved profile, and you should be logged in automatically.
71
+ // You can then add your actual UI automation steps here, e.g., navigating to
72
+ // internal dashboards, filling forms, etc.
73
+
74
+ // Example: Wait for a few seconds so you can see the login happen
75
+ console.log('Waiting for 10 seconds (for manual login/observation)...');
76
+ await new Promise(resolve => setTimeout(resolve, 10000));
77
+
78
+ // After the wait, take a screenshot to verify login state
79
+ console.log('Taking screenshot after wait...');
80
+ const screenshot = await Page.captureScreenshot({ format: 'png', quality: 80 });
81
+ const screenshotBuffer = Buffer.from(screenshot.data, 'base64');
82
+ fs.writeFileSync('example_screenshot_after_login.png', screenshotBuffer);
83
+ console.log('Screenshot saved as example_screenshot_after_login.png');
84
+
85
+ console.log('Getting page title...');
86
+ const result = await Runtime.evaluate({ expression: 'document.title' });
87
+ const pageTitle = result.result.value;
88
+ console.log(`Page Title: "${pageTitle}"`);
89
+
90
+ console.log('Getting outer HTML...');
91
+ const documentNode = await DOM.getDocument({ depth: -1 });
92
+ const outerHTML = await DOM.getOuterHTML({ nodeId: documentNode.root.nodeId });
93
+ fs.writeFileSync('example_dom_after_login.html', outerHTML.outerHTML);
94
+ console.log('DOM saved as example_dom_after_login.html');
95
+
96
+
97
+ } catch (err) {
98
+ console.error('CRITICAL ERROR during browser automation:', err.message);
99
+ console.error('Details:', err);
100
+ } finally {
101
+ if (client) {
102
+ console.log('Disconnecting CDP client...');
103
+ client.close();
104
+ }
105
+ if (chrome) {
106
+ console.log('Closing launched Chrome instance...');
107
+ await chrome.kill();
108
+ console.log('Chrome instance closed.');
109
+ }
110
+ }
111
+ }
112
+
113
+ automateBrowser();