chrome-devtools-mcp-for-extension 0.9.11 → 0.9.13

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.
@@ -98,6 +98,61 @@ function scanExtensionsDirectory(extensionsDir) {
98
98
  }
99
99
  return extensionPaths;
100
100
  }
101
+ /**
102
+ * Get system Chrome executable path
103
+ */
104
+ function getSystemChromeExecutable(channel) {
105
+ const platform = os.platform();
106
+ if (platform === 'darwin') {
107
+ // macOS
108
+ if (channel === 'canary') {
109
+ return '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary';
110
+ }
111
+ else if (channel === 'beta') {
112
+ return '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta';
113
+ }
114
+ else if (channel === 'dev') {
115
+ return '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev';
116
+ }
117
+ return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
118
+ }
119
+ else if (platform === 'win32') {
120
+ // Windows
121
+ const programFiles = process.env['ProgramFiles'] || 'C:\\Program Files';
122
+ const programFilesX86 = process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)';
123
+ if (channel === 'canary') {
124
+ return path.join(process.env.LOCALAPPDATA || '', 'Google', 'Chrome SxS', 'Application', 'chrome.exe');
125
+ }
126
+ else if (channel === 'beta') {
127
+ return path.join(programFiles, 'Google', 'Chrome Beta', 'Application', 'chrome.exe');
128
+ }
129
+ else if (channel === 'dev') {
130
+ return path.join(programFiles, 'Google', 'Chrome Dev', 'Application', 'chrome.exe');
131
+ }
132
+ // Try both Program Files locations
133
+ const path1 = path.join(programFiles, 'Google', 'Chrome', 'Application', 'chrome.exe');
134
+ const path2 = path.join(programFilesX86, 'Google', 'Chrome', 'Application', 'chrome.exe');
135
+ if (fs.existsSync(path1))
136
+ return path1;
137
+ if (fs.existsSync(path2))
138
+ return path2;
139
+ return path1; // Default fallback
140
+ }
141
+ else {
142
+ // Linux
143
+ if (channel === 'canary' || channel === 'dev') {
144
+ return '/usr/bin/google-chrome-unstable';
145
+ }
146
+ else if (channel === 'beta') {
147
+ return '/usr/bin/google-chrome-beta';
148
+ }
149
+ // Try google-chrome first, fallback to chromium
150
+ if (fs.existsSync('/usr/bin/google-chrome')) {
151
+ return '/usr/bin/google-chrome';
152
+ }
153
+ return '/usr/bin/chromium-browser';
154
+ }
155
+ }
101
156
  /**
102
157
  * Get System Chrome User Data directory (not Chrome for Testing)
103
158
  */
@@ -369,6 +424,7 @@ export async function launch(options) {
369
424
  let userDataDir = options.userDataDir;
370
425
  let usingSystemProfile = false;
371
426
  let profileDirectory = 'Default';
427
+ let needsSystemProfile = false;
372
428
  if (!userDataDir) {
373
429
  // Use isolated profile (independent from system Chrome)
374
430
  userDataDir = path.join(os.homedir(), '.cache', 'chrome-devtools-mcp', profileDirName);
@@ -447,17 +503,32 @@ export async function launch(options) {
447
503
  // Add Google login automation detection bypass
448
504
  args.push('--disable-blink-features=AutomationControlled');
449
505
  console.error('Added Google login bypass: --disable-blink-features=AutomationControlled');
506
+ // Use system Chrome instead of Chrome for Testing when loading extensions
450
507
  let puppeterChannel;
451
- if (!executablePath) {
508
+ let effectiveExecutablePath = executablePath;
509
+ if (!executablePath && extensionPaths.length > 0) {
510
+ // Auto-detect system Chrome executable for extension support
511
+ effectiveExecutablePath = getSystemChromeExecutable(channel);
512
+ needsSystemProfile = true;
513
+ console.error(`🔍 Auto-detected system Chrome: ${effectiveExecutablePath}`);
514
+ console.error(`💡 Using system Chrome for extension support (not Chrome for Testing)`);
515
+ }
516
+ else if (!executablePath) {
517
+ // No extensions, use Chrome for Testing via channel
452
518
  puppeterChannel =
453
519
  channel && channel !== 'stable'
454
520
  ? `chrome-${channel}`
455
521
  : 'chrome';
456
522
  }
523
+ // If using system Chrome, also use system Chrome's profile
524
+ if (needsSystemProfile && !options.userDataDir) {
525
+ userDataDir = getSystemChromeUserDataDir(channel);
526
+ console.error(`📁 Switching to system Chrome profile: ${userDataDir}`);
527
+ }
457
528
  // Log complete Chrome configuration before launch
458
529
  console.error('Chrome Launch Configuration:');
459
530
  console.error(` Channel: ${puppeterChannel || 'default'}`);
460
- console.error(` Executable: ${executablePath || 'auto-detected'}`);
531
+ console.error(` Executable: ${effectiveExecutablePath || 'auto-detected'}`);
461
532
  console.error(` User Data Dir: ${userDataDir || 'temporary'}`);
462
533
  console.error(` Profile Directory: ${profileDirectory}`);
463
534
  console.error(` Profile Type: ${usingSystemProfile ? 'System Profile (auto-detected)' : 'Custom Profile'}`);
@@ -475,7 +546,7 @@ export async function launch(options) {
475
546
  const browser = await puppeteer.launch({
476
547
  ...connectOptions,
477
548
  channel: puppeterChannel,
478
- executablePath,
549
+ executablePath: effectiveExecutablePath,
479
550
  defaultViewport: null,
480
551
  userDataDir,
481
552
  pipe: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp-for-extension",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "description": "MCP server for Chrome extension development with Web Store automation. Fork of chrome-devtools-mcp with extension-specific tools.",
5
5
  "type": "module",
6
6
  "bin": "./build/src/index.js",