opera-devtools-mcp 0.6.1 → 0.7.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 (51) hide show
  1. package/build/src/McpContext.js +78 -41
  2. package/build/src/McpPage.js +5 -1
  3. package/build/src/ToolHandler.js +45 -74
  4. package/build/src/bin/chrome-devtools-mcp-main.js +4 -4
  5. package/build/src/bin/chrome-devtools.js +29 -30
  6. package/build/src/bin/opera-devtools-cli-options.js +1 -1
  7. package/build/src/bin/opera-devtools-mcp-cli-options.js +1 -1
  8. package/build/src/browser.js +5 -16
  9. package/build/src/config/browser-options.js +126 -0
  10. package/build/src/config/category-options.js +81 -0
  11. package/build/src/{bin/chrome-devtools-cli-options.js → config/cli-options.js} +368 -26
  12. package/build/src/{bin/chrome-devtools-mcp-cli-options.js → config/mcp-options.js} +143 -164
  13. package/build/src/daemon/client.js +9 -0
  14. package/build/src/daemon/utils.js +6 -0
  15. package/build/src/devtools/DevtoolsUtils.js +27 -21
  16. package/build/src/formatters/NetworkFormatter.js +5 -2
  17. package/build/src/index.js +166 -100
  18. package/build/src/processors/HeapSnapshotManager.js +12 -0
  19. package/build/src/telemetry/ClearcutLogger.js +19 -6
  20. package/build/src/telemetry/transformation.js +4 -0
  21. package/build/src/telemetry/types.js +4 -0
  22. package/build/src/third_party/THIRD_PARTY_NOTICES +5 -5
  23. package/build/src/third_party/bundled-packages.json +3 -3
  24. package/build/src/third_party/devtools-formatter-worker.js +22 -0
  25. package/build/src/third_party/devtools-heap-snapshot-worker.js +100 -20
  26. package/build/src/third_party/index.js +15459 -14256
  27. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
  28. package/build/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
  29. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
  30. package/build/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
  31. package/build/src/tools/ToolDefinition.js +15 -0
  32. package/build/src/tools/categories.js +0 -6
  33. package/build/src/tools/comments.js +90 -0
  34. package/build/src/tools/console.js +1 -1
  35. package/build/src/tools/emulation.js +1 -1
  36. package/build/src/tools/extensions.js +1 -1
  37. package/build/src/tools/memory.js +60 -6
  38. package/build/src/tools/network.js +2 -2
  39. package/build/src/tools/pages.js +26 -15
  40. package/build/src/tools/performance.js +4 -3
  41. package/build/src/tools/screencast.js +3 -2
  42. package/build/src/tools/screenshot.js +39 -8
  43. package/build/src/tools/script.js +17 -4
  44. package/build/src/tools/slim/tools.js +41 -33
  45. package/build/src/tools/snapshot.js +1 -1
  46. package/build/src/tools/tools.js +2 -0
  47. package/build/src/utils/WaitForHelper.js +12 -1
  48. package/build/src/utils/bytes.js +105 -0
  49. package/build/src/utils/url.js +73 -0
  50. package/build/src/version.js +1 -1
  51. package/package.json +23 -4
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Modified by Opera Software AS.
7
+ */
8
+ import { CACHE_DIR_NAME, MCP_BIN_NAME, REPO_URL } from '../opera/branding.js';
9
+ export const browserOptions = {
10
+ autoConnect: {
11
+ type: 'boolean',
12
+ description: 'If specified, automatically connects to a browser (Chrome 144+) running locally from the user data directory identified by the channel param (default channel is stable). Requires the remote debugging server to be started in the Chrome instance via chrome://inspect/#remote-debugging.',
13
+ conflicts: ['isolated', 'executablePath'],
14
+ default: false,
15
+ coerce: (value) => {
16
+ if (!value) {
17
+ return;
18
+ }
19
+ return value;
20
+ },
21
+ },
22
+ browserUrl: {
23
+ type: 'string',
24
+ description: `Connect to a running, debuggable Chrome instance (e.g. \`http://127.0.0.1:9222\`). For more details see: ${REPO_URL}#connecting-to-a-running-chrome-instance.`,
25
+ alias: 'u',
26
+ conflicts: ['wsEndpoint'],
27
+ coerce: (url) => {
28
+ if (!url) {
29
+ return;
30
+ }
31
+ try {
32
+ new URL(url);
33
+ }
34
+ catch {
35
+ throw new Error(`Provided browserUrl ${url} is not valid URL.`);
36
+ }
37
+ return url;
38
+ },
39
+ },
40
+ wsEndpoint: {
41
+ type: 'string',
42
+ description: 'WebSocket endpoint to connect to a running Chrome instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.',
43
+ alias: 'w',
44
+ conflicts: ['browserUrl'],
45
+ coerce: (url) => {
46
+ if (!url) {
47
+ return;
48
+ }
49
+ try {
50
+ const parsed = new URL(url);
51
+ if (parsed.protocol !== 'ws:' && parsed.protocol !== 'wss:') {
52
+ throw new Error(`Provided wsEndpoint ${url} must use ws:// or wss:// protocol.`);
53
+ }
54
+ return url;
55
+ }
56
+ catch (error) {
57
+ if (error.message.includes('ws://')) {
58
+ throw error;
59
+ }
60
+ throw new Error(`Provided wsEndpoint ${url} is not valid URL.`);
61
+ }
62
+ },
63
+ },
64
+ wsHeaders: {
65
+ type: 'string',
66
+ description: 'Custom headers for WebSocket connection in JSON format (e.g., \'{"Authorization":"Bearer token"}\'). Only works with --wsEndpoint.',
67
+ implies: 'wsEndpoint',
68
+ coerce: (val) => {
69
+ if (!val) {
70
+ return;
71
+ }
72
+ try {
73
+ const parsed = JSON.parse(val);
74
+ if (typeof parsed !== 'object' || Array.isArray(parsed)) {
75
+ throw new Error('Headers must be a JSON object');
76
+ }
77
+ return parsed;
78
+ }
79
+ catch (error) {
80
+ throw new Error(`Invalid JSON for wsHeaders: ${error.message}`);
81
+ }
82
+ },
83
+ },
84
+ headless: {
85
+ type: 'boolean',
86
+ description: 'Whether to run in headless (no UI) mode.',
87
+ default: false,
88
+ },
89
+ executablePath: {
90
+ type: 'string',
91
+ description: 'Path to custom Chrome executable.',
92
+ conflicts: ['browserUrl', 'wsEndpoint'],
93
+ alias: 'e',
94
+ },
95
+ isolated: {
96
+ type: 'boolean',
97
+ description: 'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to false.',
98
+ },
99
+ userDataDir: {
100
+ type: 'string',
101
+ description: `Path to the user data directory for Chrome. Default is $HOME/.cache/${CACHE_DIR_NAME}/chrome-profile$CHANNEL_SUFFIX_IF_NON_STABLE`,
102
+ conflicts: ['browserUrl', 'wsEndpoint', 'isolated'],
103
+ },
104
+ channel: {
105
+ type: 'string',
106
+ description: 'Specify a different Chrome channel that should be used. The default is the stable channel version.',
107
+ choices: ['canary', 'dev', 'beta', 'stable'],
108
+ conflicts: ['browserUrl', 'wsEndpoint', 'executablePath'],
109
+ },
110
+ proxyServer: {
111
+ type: 'string',
112
+ description: `Proxy server configuration for Chrome passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.`,
113
+ },
114
+ chromeArg: {
115
+ type: 'array',
116
+ describe: `Additional arguments for Chrome. Only applies when Chrome is launched by ${MCP_BIN_NAME}.`,
117
+ },
118
+ ignoreDefaultChromeArg: {
119
+ type: 'array',
120
+ describe: `Explicitly disable default arguments for Chrome. Only applies when Chrome is launched by ${MCP_BIN_NAME}.`,
121
+ },
122
+ };
123
+ export function getBrowserOptions() {
124
+ return browserOptions;
125
+ }
126
+ //# sourceMappingURL=browser-options.js.map
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ToolCategory } from '../tools/categories.js';
7
+ const categoryOverrides = {
8
+ [ToolCategory.INPUT]: {},
9
+ [ToolCategory.NAVIGATION]: {},
10
+ [ToolCategory.EMULATION]: {
11
+ hidden: false,
12
+ },
13
+ [ToolCategory.PERFORMANCE]: {
14
+ hidden: false,
15
+ },
16
+ [ToolCategory.NETWORK]: {
17
+ hidden: false,
18
+ },
19
+ [ToolCategory.DEBUGGING]: {},
20
+ [ToolCategory.MEMORY]: {},
21
+ [ToolCategory.WEBMCP]: {
22
+ describe: 'Set to true to enable debugging WebMCP tools. Requires Chrome 150+ with the following flag: `--enable-features=WebMCP`',
23
+ offByDefault: true,
24
+ },
25
+ [ToolCategory.EXTENSIONS]: {
26
+ describe: 'Set to true to include tools related to extensions. Note: This feature is currently only supported with a pipe connection. autoConnect, browserUrl, and wsEndpoint are not supported with this feature until 149 will be released.',
27
+ hidden: false,
28
+ offByDefault: true,
29
+ },
30
+ [ToolCategory.THIRD_PARTY]: {
31
+ describe: 'Set to true to enable third-party developer tools exposed by the inspected page itself',
32
+ hidden: false,
33
+ offByDefault: true,
34
+ },
35
+ [ToolCategory.PWA]: {
36
+ describe: 'Set to true to include tools for automating Progressive Web Apps (install, launch, uninstall, and OS state). This feature is only supported with a pipe connection; autoConnect, browserUrl, and wsEndpoint are not supported.',
37
+ conflicts: ['autoConnect', 'browserUrl', 'wsEndpoint'],
38
+ hidden: false,
39
+ offByDefault: true,
40
+ },
41
+ [ToolCategory.OPERA]: {},
42
+ };
43
+ function createOption(category) {
44
+ const overrides = categoryOverrides[category];
45
+ const describe = overrides.offByDefault
46
+ ? `Set to true to include tools related to ${category}.`
47
+ : `Set to false to exclude tools related to ${category}.`;
48
+ return {
49
+ type: 'boolean',
50
+ describe,
51
+ hidden: true,
52
+ ...overrides,
53
+ ...(overrides.offByDefault ? {} : { default: true }),
54
+ };
55
+ }
56
+ export function categoryToFlagName(category) {
57
+ return `category${category.charAt(0).toUpperCase()}${category.slice(1)}`;
58
+ }
59
+ export function getCategoryOptions() {
60
+ const options = {};
61
+ for (const category of Object.values(ToolCategory)) {
62
+ const flagName = categoryToFlagName(category);
63
+ options[flagName] = createOption(category);
64
+ }
65
+ return options;
66
+ }
67
+ export function isCategoryOffByDefault(category) {
68
+ const flagName = categoryToFlagName(category);
69
+ const option = getCategoryOptions()[flagName];
70
+ return !('default' in option) || option.default !== true;
71
+ }
72
+ export function getOffByDefaultCategories() {
73
+ const result = [];
74
+ for (const category of Object.values(ToolCategory)) {
75
+ if (isCategoryOffByDefault(category)) {
76
+ result.push(category);
77
+ }
78
+ }
79
+ return result;
80
+ }
81
+ //# sourceMappingURL=category-options.js.map