@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/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@democratize-quality/mcp-server",
3
+ "version": "1.0.0",
4
+ "main": "mcpServer.js",
5
+ "bin": {
6
+ "democratize-quality-mcp": "cli.js",
7
+ "dq-mcp-server": "cli.js"
8
+ },
9
+ "files": [
10
+ "mcpServer.js",
11
+ "run-server.js",
12
+ "cli.js",
13
+ "browserControl.js",
14
+ "src/",
15
+ "docs/",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "test": "node test-mcp.js",
24
+ "docs:generate": "node scripts/generate-docs.js",
25
+ "docs:watch": "nodemon scripts/generate-docs.js",
26
+ "docs:clean": "rm -rf docs/",
27
+ "start": "NODE_ENV=production node mcpServer.js",
28
+ "mcp": "NODE_ENV=production node mcpServer.js",
29
+ "mcp:debug": "MCP_FEATURES_ENABLEDEBUGMODE=true node mcpServer.js",
30
+ "dev": "MCP_FEATURES_ENABLEDEBUGMODE=true node mcpServer.js",
31
+ "server": "node run-server.js",
32
+ "server:debug": "node run-server.js --debug",
33
+ "server:prod": "node run-server.js --production",
34
+ "inspector": "npx @modelcontextprotocol/inspector node mcpServer.js",
35
+ "prepare-publish": "node prepare-publish.js",
36
+ "prepublishOnly": "npm run prepare-publish",
37
+ "postinstall": "echo '\n🎯 Democratize Quality MCP Server installed successfully!\n\nQuick start:\n npx @democratize-quality/mcp-server --help\n npx dq-mcp-server --help\n\nDocumentation: https://github.com/democratize-quality/mcp-server#readme\n'"
38
+ },
39
+ "keywords": [
40
+ "mcp",
41
+ "model-context-protocol",
42
+ "browser-automation",
43
+ "api-testing",
44
+ "quality-assurance",
45
+ "testing",
46
+ "democratize-quality",
47
+ "chrome-devtools",
48
+ "end-to-end-testing"
49
+ ],
50
+ "author": "Raj Uppadhyay",
51
+ "license": "ISC",
52
+ "description": "MCP Server for democratizing quality through browser automation and comprehensive API testing capabilities",
53
+ "homepage": "https://github.com/uppadhyayraj/democratize-quality-mcp-server#readme",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/uppadhyayraj/democratize-quality-mcp-server.git"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/uppadhyayraj/democratize-quality-mcp-server/issues"
60
+ },
61
+ "mcp": {
62
+ "server": {
63
+ "command": "node",
64
+ "args": [
65
+ "mcpServer.js"
66
+ ],
67
+ "env": {
68
+ "NODE_ENV": "production"
69
+ }
70
+ }
71
+ },
72
+ "dependencies": {
73
+ "body-parser": "^2.2.0",
74
+ "chrome-launcher": "^1.2.0",
75
+ "chrome-remote-interface": "^0.33.3",
76
+ "express": "^5.1.0",
77
+ "json-rpc-2.0": "^1.7.1",
78
+ "zod": "^4.0.10"
79
+ },
80
+ "devDependencies": {
81
+ "nodemon": "^3.1.10"
82
+ }
83
+ }
package/run-server.js ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Democratize Quality MCP Server Startup Script
5
+ * Provides easy configuration and startup options
6
+ */
7
+
8
+ const { spawn } = require('child_process');
9
+ const path = require('path');
10
+
11
+ // Parse command line arguments
12
+ const args = process.argv.slice(2);
13
+ const options = {
14
+ debug: args.includes('--debug') || args.includes('-d'),
15
+ production: args.includes('--production') || args.includes('-p'),
16
+ help: args.includes('--help') || args.includes('-h')
17
+ };
18
+
19
+ if (options.help) {
20
+ console.log(`
21
+ 🎯 Democratize Quality MCP Server
22
+
23
+ Usage: npm run server [options]
24
+ or: node run-server.js [options]
25
+
26
+ Options:
27
+ --debug, -d Enable debug mode with verbose logging
28
+ --production, -p Run in production mode
29
+ --help, -h Show this help message
30
+
31
+ Environment Variables:
32
+ NODE_ENV Set environment (development/production)
33
+ OUTPUT_DIR Directory for screenshots, PDFs, reports
34
+ PORT Server port (default: 3000)
35
+
36
+ Integration Examples:
37
+
38
+ 1. Claude Desktop (add to claude_desktop_config.json):
39
+ {
40
+ "mcpServers": {
41
+ "democratize-quality": {
42
+ "command": "node",
43
+ "args": ["${path.join(__dirname, 'mcpServer.js')}"]
44
+ }
45
+ }
46
+ }
47
+
48
+ 2. MCP Inspector (for testing):
49
+ npx @modelcontextprotocol/inspector node mcpServer.js
50
+
51
+ 3. Direct STDIO communication:
52
+ echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node mcpServer.js
53
+
54
+ Available Tools: 20 total
55
+ - Browser Tools (17): automation, interaction, content capture
56
+ - API Tools (3): HTTP testing, session management, reporting
57
+
58
+ Repository: https://github.com/democratize-quality/mcp-server
59
+ `);
60
+ process.exit(0);
61
+ }
62
+
63
+ // Set environment variables
64
+ const env = { ...process.env };
65
+
66
+ if (options.debug) {
67
+ env.MCP_FEATURES_ENABLEDEBUGMODE = 'true';
68
+ env.NODE_ENV = 'development';
69
+ console.log('🐛 Debug mode enabled');
70
+ }
71
+
72
+ if (options.production) {
73
+ env.NODE_ENV = 'production';
74
+ console.log('🏭 Production mode enabled');
75
+ }
76
+
77
+ if (!env.OUTPUT_DIR) {
78
+ env.OUTPUT_DIR = path.join(__dirname, 'output');
79
+ }
80
+
81
+ // Ensure output directory exists
82
+ const fs = require('fs');
83
+ if (!fs.existsSync(env.OUTPUT_DIR)) {
84
+ fs.mkdirSync(env.OUTPUT_DIR, { recursive: true });
85
+ console.log(`📁 Created output directory: ${env.OUTPUT_DIR}`);
86
+ }
87
+
88
+ console.log(`
89
+ 🚀 Starting CDP Browser Control MCP Server
90
+
91
+ 📊 Configuration:
92
+ Environment: ${env.NODE_ENV || 'development'}
93
+ Debug Mode: ${env.MCP_FEATURES_ENABLEDEBUGMODE || 'false'}
94
+ Output Dir: ${env.OUTPUT_DIR}
95
+
96
+ 🔧 Available Tools: 20
97
+ Browser Automation: 17 tools
98
+ API Testing: 3 tools
99
+
100
+ 🔗 Integration ready for:
101
+ • Claude Desktop
102
+ • MCP Inspector
103
+ • Custom MCP clients
104
+
105
+ 💡 Use --help for integration examples
106
+ `);
107
+
108
+ // Start the server
109
+ const serverPath = path.join(__dirname, 'mcpServer.js');
110
+ const serverProcess = spawn('node', [serverPath], {
111
+ env,
112
+ stdio: 'inherit'
113
+ });
114
+
115
+ // Handle process events
116
+ serverProcess.on('error', (error) => {
117
+ console.error('❌ Failed to start server:', error.message);
118
+ process.exit(1);
119
+ });
120
+
121
+ serverProcess.on('exit', (code, signal) => {
122
+ if (signal) {
123
+ console.log(`\n👋 Server stopped by signal: ${signal}`);
124
+ } else if (code !== 0) {
125
+ console.error(`❌ Server exited with code: ${code}`);
126
+ process.exit(code);
127
+ } else {
128
+ console.log('\n👋 Server stopped gracefully');
129
+ }
130
+ });
131
+
132
+ // Forward signals to server
133
+ process.on('SIGINT', () => {
134
+ console.log('\n⏹️ Stopping server...');
135
+ serverProcess.kill('SIGINT');
136
+ });
137
+
138
+ process.on('SIGTERM', () => {
139
+ serverProcess.kill('SIGTERM');
140
+ });
@@ -0,0 +1,53 @@
1
+ /**
2
+ * API-only environment configuration
3
+ * Only enables API testing tools, disables all browser automation tools
4
+ * Ideal for lightweight deployments focused on API testing
5
+ */
6
+ module.exports = {
7
+ features: {
8
+ enableDebugMode: process.env.MCP_FEATURES_ENABLEDEBUGMODE === 'true',
9
+ // Only API tools enabled
10
+ enableApiTools: true,
11
+ enableBrowserTools: false,
12
+ enableAdvancedTools: false,
13
+ enableFileTools: false,
14
+ enableNetworkTools: false,
15
+ enableOtherTools: false
16
+ },
17
+
18
+ logging: {
19
+ level: 'warn',
20
+ enableToolDebug: false
21
+ },
22
+
23
+ tools: {
24
+ validationLevel: 'strict',
25
+ // API tool specific configurations
26
+ api: {
27
+ api_request: {
28
+ maxSessionTimeout: 300000, // 5 minutes
29
+ maxConcurrentSessions: 10,
30
+ enableRetries: true,
31
+ defaultRetryAttempts: 3,
32
+ enableRequestLogging: true,
33
+ enableResponseLogging: true
34
+ },
35
+ api_session_report: {
36
+ defaultTheme: 'light',
37
+ includeTimestamp: true,
38
+ maxReportSize: '10MB',
39
+ enableCompressionForLargeReports: true
40
+ },
41
+ api_session_status: {
42
+ enableRealTimeUpdates: true,
43
+ maxHistoryEntries: 1000
44
+ }
45
+ }
46
+ },
47
+
48
+ security: {
49
+ enableInputValidation: true,
50
+ rateLimiting: true,
51
+ maxRequestsPerMinute: 100
52
+ }
53
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Development environment configuration
3
+ * Settings optimized for development and debugging
4
+ */
5
+ module.exports = {
6
+ features: {
7
+ enableDebugMode: true,
8
+ // Tool category feature flags - all enabled by default in development
9
+ enableApiTools: true,
10
+ enableBrowserTools: true,
11
+ enableAdvancedTools: true,
12
+ enableFileTools: true,
13
+ enableNetworkTools: true,
14
+ enableOtherTools: true
15
+ },
16
+
17
+ logging: {
18
+ level: 'debug',
19
+ enableToolDebug: true
20
+ },
21
+
22
+ tools: {
23
+ validationLevel: 'strict',
24
+ browser: {
25
+ browser_launch: {
26
+ defaultHeadless: false, // Show browser in development
27
+ maxInstances: 5,
28
+ chromeFlags: [
29
+ '--disable-gpu',
30
+ '--no-sandbox',
31
+ '--disable-web-security', // Allow CORS in development
32
+ '--disable-features=VizDisplayCompositor'
33
+ ]
34
+ },
35
+ browser_screenshot: {
36
+ enableTimestamps: true,
37
+ outputDirectory: require('path').resolve(__dirname, '../../../output/dev')
38
+ },
39
+ browser_dom: {
40
+ highlightElements: true, // Highlight elements for debugging
41
+ enableRetries: true
42
+ },
43
+ global: {
44
+ enableScreenshotOnError: true,
45
+ enablePerformanceMetrics: true
46
+ }
47
+ }
48
+ },
49
+
50
+ security: {
51
+ enableInputValidation: true,
52
+ rateLimiting: false
53
+ }
54
+ };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Production environment configuration
3
+ * Settings optimized for production deployment
4
+ */
5
+ module.exports = {
6
+ features: {
7
+ enableDebugMode: false,
8
+ // Tool category feature flags - API tools enabled by default, others can be controlled
9
+ enableApiTools: true,
10
+ enableBrowserTools: process.env.ENABLE_BROWSER_TOOLS !== 'false',
11
+ enableAdvancedTools: process.env.ENABLE_ADVANCED_TOOLS === 'true',
12
+ enableFileTools: process.env.ENABLE_FILE_TOOLS === 'true',
13
+ enableNetworkTools: process.env.ENABLE_NETWORK_TOOLS === 'true',
14
+ enableOtherTools: process.env.ENABLE_OTHER_TOOLS === 'true'
15
+ },
16
+
17
+ logging: {
18
+ level: 'error',
19
+ enableToolDebug: false
20
+ },
21
+
22
+ tools: {
23
+ validationLevel: 'strict',
24
+ browser: {
25
+ browser_launch: {
26
+ defaultHeadless: true, // Always headless in production
27
+ maxInstances: 3, // Conservative limit
28
+ launchTimeout: 15000, // Shorter timeout
29
+ chromeFlags: [
30
+ '--headless=new',
31
+ '--disable-gpu',
32
+ '--no-sandbox',
33
+ '--disable-dev-shm-usage',
34
+ '--disable-background-timer-throttling',
35
+ '--disable-backgrounding-occluded-windows',
36
+ '--disable-renderer-backgrounding',
37
+ '--memory-pressure-off',
38
+ '--max_old_space_size=4096'
39
+ ]
40
+ },
41
+ browser_screenshot: {
42
+ defaultQuality: 60, // Lower quality for performance
43
+ compressionLevel: 9, // Higher compression
44
+ enableTimestamps: false
45
+ },
46
+ browser_dom: {
47
+ highlightElements: false,
48
+ enableRetries: false, // Fail fast in production
49
+ defaultWaitTimeout: 3000 // Shorter timeout
50
+ },
51
+ browser_type: {
52
+ typingDelay: 5, // Faster typing
53
+ enableNaturalTyping: false
54
+ },
55
+ global: {
56
+ maxConcurrentOperations: 2,
57
+ enableScreenshotOnError: false,
58
+ enablePerformanceMetrics: false,
59
+ healthCheckInterval: 300000 // 5 minutes
60
+ }
61
+ }
62
+ },
63
+
64
+ security: {
65
+ enableInputValidation: true,
66
+ rateLimiting: true,
67
+ maxRequestSize: '5MB'
68
+ }
69
+ };