chrome-devtools-mcp 1.8.0 → 1.10.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.
- package/README.md +20 -908
- package/build/src/BrowserManager.js +401 -0
- package/build/src/McpContext.js +43 -26
- package/build/src/McpPage.js +112 -4
- package/build/src/McpResponse.js +68 -3
- package/build/src/ToolHandler.js +184 -160
- package/build/src/bin/chrome-devtools-mcp-main.js +12 -7
- package/build/src/bin/chrome-devtools.js +6 -12
- package/build/src/collectors/PageCollector.js +66 -3
- package/build/src/config/browser-options.js +125 -0
- package/build/src/config/category-options.js +89 -0
- package/build/src/config/cli-commands.js +26 -0
- package/build/src/config/cli-options.js +34 -2
- package/build/src/config/mcp-options.js +86 -147
- package/build/src/daemon/utils.js +6 -0
- package/build/src/devtools/DevToolsCommentBridge.js +91 -0
- package/build/src/devtools/DevtoolsUtils.js +27 -21
- package/build/src/formatters/CommentFormatter.js +82 -0
- package/build/src/formatters/CssFormatter.js +812 -0
- package/build/src/formatters/NetworkFormatter.js +5 -2
- package/build/src/index.js +175 -128
- package/build/src/processors/ChunkedTraceParser.js +361 -0
- package/build/src/processors/PerformanceTrace.js +60 -13
- package/build/src/telemetry/ClearcutLogger.js +95 -37
- package/build/src/telemetry/metricsRegistry.js +3 -0
- package/build/src/telemetry/persistence.js +17 -7
- package/build/src/telemetry/transformation.js +53 -4
- package/build/src/telemetry/types.js +1 -0
- package/build/src/third_party/THIRD_PARTY_NOTICES +687 -133
- package/build/src/third_party/bundled-packages.json +6 -3
- package/build/src/third_party/devtools-formatter-worker.js +158 -5
- package/build/src/third_party/devtools-heap-snapshot-worker.js +589 -6
- package/build/src/third_party/index.js +59173 -38013
- package/build/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
- package/build/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
- package/build/src/tools/ToolDefinition.js +28 -21
- package/build/src/tools/categories.js +0 -6
- package/build/src/tools/comments.js +169 -0
- package/build/src/tools/console.js +3 -3
- package/build/src/tools/css.js +45 -0
- package/build/src/tools/emulation.js +5 -5
- package/build/src/tools/extensions.js +10 -10
- package/build/src/tools/input.js +159 -87
- package/build/src/tools/lighthouse.js +18 -7
- package/build/src/tools/memory.js +26 -26
- package/build/src/tools/network.js +5 -5
- package/build/src/tools/pages.js +34 -19
- package/build/src/tools/performance.js +7 -6
- package/build/src/tools/pwa.js +8 -8
- package/build/src/tools/screencast.js +5 -4
- package/build/src/tools/screenshot.js +2 -2
- package/build/src/tools/script.js +8 -7
- package/build/src/tools/slim/tools.js +45 -37
- package/build/src/tools/snapshot.js +4 -4
- package/build/src/tools/thirdPartyDeveloper.js +4 -4
- package/build/src/tools/tools.js +6 -9
- package/build/src/tools/webmcp.js +4 -4
- package/build/src/types.js +4 -1
- package/build/src/utils/WaitForHelper.js +26 -9
- package/build/src/utils/logger.js +7 -6
- package/build/src/utils/url.js +73 -0
- package/build/src/version.js +1 -1
- package/package.json +9 -6
- package/skills/chrome-devtools/SKILL.md +2 -1
- package/skills/chrome-devtools-cli/SKILL.md +3 -7
- package/skills/cookie-debugging/SKILL.md +149 -0
- package/skills/memory-leak-debugging/SKILL.md +4 -0
- package/build/src/browser.js +0 -244
- package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +0 -4
|
@@ -42,6 +42,9 @@ export function applyToExisting(existing, update) {
|
|
|
42
42
|
if (!updatedNames.has(entry.name)) {
|
|
43
43
|
toAdd.isDeprecated = true;
|
|
44
44
|
}
|
|
45
|
+
else {
|
|
46
|
+
delete toAdd.isDeprecated;
|
|
47
|
+
}
|
|
45
48
|
result.push(toAdd);
|
|
46
49
|
}
|
|
47
50
|
// New entries must be added to the very back of the list.
|
|
@@ -10,6 +10,18 @@ import process from 'node:process';
|
|
|
10
10
|
import { logger } from '../utils/logger.js';
|
|
11
11
|
import { ClearcutLogger } from './ClearcutLogger.js';
|
|
12
12
|
import { ErrorCode } from './errors.js';
|
|
13
|
+
function isValidTime(time) {
|
|
14
|
+
if (time === undefined) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
if (typeof time !== 'string' || time === '') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return !Number.isNaN(new Date(time).getTime());
|
|
21
|
+
}
|
|
22
|
+
function isContextValid(state) {
|
|
23
|
+
return isValidTime(state.lastActive) && isValidTime(state.lastToolCall);
|
|
24
|
+
}
|
|
13
25
|
const STATE_FILE_NAME = 'telemetry_state.json';
|
|
14
26
|
function getDataFolder() {
|
|
15
27
|
const homedir = os.homedir();
|
|
@@ -36,23 +48,21 @@ export class FilePersistence {
|
|
|
36
48
|
}
|
|
37
49
|
catch {
|
|
38
50
|
// File doesn't exist. Not an error because new users do not have the state file.
|
|
39
|
-
return {
|
|
40
|
-
lastActive: '',
|
|
41
|
-
};
|
|
51
|
+
return {};
|
|
42
52
|
}
|
|
53
|
+
let state;
|
|
43
54
|
try {
|
|
44
55
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
45
|
-
|
|
56
|
+
state = JSON.parse(content);
|
|
46
57
|
}
|
|
47
58
|
catch (error) {
|
|
48
59
|
logger?.(`Failed to read telemetry state from ${filePath}:`, error);
|
|
49
60
|
void ClearcutLogger.get()?.logServerError({
|
|
50
61
|
errorCode: ErrorCode.ERROR_CODE_PERSISTENCE_FILE_READ_FAILED,
|
|
51
62
|
});
|
|
52
|
-
return {
|
|
53
|
-
lastActive: '',
|
|
54
|
-
};
|
|
63
|
+
return {};
|
|
55
64
|
}
|
|
65
|
+
return isContextValid(state) ? state : {};
|
|
56
66
|
}
|
|
57
67
|
async saveState(state) {
|
|
58
68
|
const filePath = path.join(this.#dataFolder, STATE_FILE_NAME);
|
|
@@ -13,6 +13,21 @@ export function bucketizeLatency(latencyMs) {
|
|
|
13
13
|
}
|
|
14
14
|
return LATENCY_BUCKETS[LATENCY_BUCKETS.length - 1];
|
|
15
15
|
}
|
|
16
|
+
export const MAX_ACTIVE_DAYS = 31;
|
|
17
|
+
export function bucketizeDaysSince(days) {
|
|
18
|
+
return Math.min(days, MAX_ACTIVE_DAYS);
|
|
19
|
+
}
|
|
20
|
+
export const REDACTED_CLIENT_NAME = '<redacted>';
|
|
21
|
+
const VALID_CLIENT_NAME_REGEX = /^[a-zA-Z0-9_-]+$/;
|
|
22
|
+
const MAX_CLIENT_NAME_LENGTH = 32;
|
|
23
|
+
export function sanitizeClientName(clientName) {
|
|
24
|
+
if (clientName.length > 0 &&
|
|
25
|
+
clientName.length < MAX_CLIENT_NAME_LENGTH &&
|
|
26
|
+
VALID_CLIENT_NAME_REGEX.test(clientName)) {
|
|
27
|
+
return clientName;
|
|
28
|
+
}
|
|
29
|
+
return REDACTED_CLIENT_NAME;
|
|
30
|
+
}
|
|
16
31
|
export const PARAM_BLOCKLIST = new Set(['uid', 'reqid', 'msgid']);
|
|
17
32
|
const SUPPORTED_ZOD_TYPES = [
|
|
18
33
|
'ZodString',
|
|
@@ -21,12 +36,21 @@ const SUPPORTED_ZOD_TYPES = [
|
|
|
21
36
|
'ZodArray',
|
|
22
37
|
'ZodEnum',
|
|
23
38
|
];
|
|
39
|
+
function isObjectWithDef(val) {
|
|
40
|
+
return typeof val === 'object' && val !== null && '_def' in val;
|
|
41
|
+
}
|
|
24
42
|
function isZodType(type) {
|
|
25
43
|
return SUPPORTED_ZOD_TYPES.includes(type);
|
|
26
44
|
}
|
|
27
45
|
export function getZodType(zodType) {
|
|
46
|
+
if (!isObjectWithDef(zodType)) {
|
|
47
|
+
throw new Error('Invalid zod schema');
|
|
48
|
+
}
|
|
28
49
|
const def = zodType._def;
|
|
29
|
-
|
|
50
|
+
let typeName = def.typeName;
|
|
51
|
+
if (!typeName && def.type) {
|
|
52
|
+
typeName = 'Zod' + def.type.charAt(0).toUpperCase() + def.type.slice(1);
|
|
53
|
+
}
|
|
30
54
|
if (typeName === 'ZodOptional' ||
|
|
31
55
|
typeName === 'ZodDefault' ||
|
|
32
56
|
typeName === 'ZodNullable') {
|
|
@@ -35,7 +59,14 @@ export function getZodType(zodType) {
|
|
|
35
59
|
if (typeName === 'ZodEffects') {
|
|
36
60
|
return getZodType(def.schema);
|
|
37
61
|
}
|
|
38
|
-
if (
|
|
62
|
+
if (typeName === 'ZodPipeline' || typeName === 'ZodPipe') {
|
|
63
|
+
return getZodType(isObjectWithDef(def.in) &&
|
|
64
|
+
(def.in._def.type === 'transform' ||
|
|
65
|
+
def.in._def.typeName === 'ZodTransform')
|
|
66
|
+
? def.out
|
|
67
|
+
: def.in);
|
|
68
|
+
}
|
|
69
|
+
if (typeName && isZodType(typeName)) {
|
|
39
70
|
return typeName;
|
|
40
71
|
}
|
|
41
72
|
throw new Error(`Unsupported zod type for tool parameter: ${typeName}`);
|
|
@@ -45,8 +76,14 @@ export function getZodType(zodType) {
|
|
|
45
76
|
* nullable/effects wrappers (in any order), mirroring {@link getZodType}.
|
|
46
77
|
*/
|
|
47
78
|
export function getEnumValues(zodType) {
|
|
79
|
+
if (!isObjectWithDef(zodType)) {
|
|
80
|
+
throw new Error('Invalid zod schema');
|
|
81
|
+
}
|
|
48
82
|
const def = zodType._def;
|
|
49
|
-
|
|
83
|
+
let typeName = def.typeName;
|
|
84
|
+
if (!typeName && def.type) {
|
|
85
|
+
typeName = 'Zod' + def.type.charAt(0).toUpperCase() + def.type.slice(1);
|
|
86
|
+
}
|
|
50
87
|
if (typeName === 'ZodOptional' ||
|
|
51
88
|
typeName === 'ZodDefault' ||
|
|
52
89
|
typeName === 'ZodNullable') {
|
|
@@ -55,8 +92,20 @@ export function getEnumValues(zodType) {
|
|
|
55
92
|
if (typeName === 'ZodEffects') {
|
|
56
93
|
return getEnumValues(def.schema);
|
|
57
94
|
}
|
|
95
|
+
if (typeName === 'ZodPipeline' || typeName === 'ZodPipe') {
|
|
96
|
+
return getEnumValues(isObjectWithDef(def.in) &&
|
|
97
|
+
(def.in._def.type === 'transform' ||
|
|
98
|
+
def.in._def.typeName === 'ZodTransform')
|
|
99
|
+
? def.out
|
|
100
|
+
: def.in);
|
|
101
|
+
}
|
|
58
102
|
if (typeName === 'ZodEnum') {
|
|
59
|
-
|
|
103
|
+
if (def.values) {
|
|
104
|
+
return def.values;
|
|
105
|
+
}
|
|
106
|
+
if (def.entries) {
|
|
107
|
+
return Object.values(def.entries);
|
|
108
|
+
}
|
|
60
109
|
}
|
|
61
110
|
throw new Error(`Cannot resolve enum values for zod type: ${typeName}`);
|
|
62
111
|
}
|
|
@@ -24,6 +24,7 @@ export var McpClient;
|
|
|
24
24
|
McpClient[McpClient["MCP_CLIENT_OPENCODE"] = 9] = "MCP_CLIENT_OPENCODE";
|
|
25
25
|
McpClient[McpClient["MCP_CLIENT_CLAUDE_DESKTOP"] = 10] = "MCP_CLIENT_CLAUDE_DESKTOP";
|
|
26
26
|
McpClient[McpClient["MCP_CLIENT_GITHUB_COPILOT"] = 11] = "MCP_CLIENT_GITHUB_COPILOT";
|
|
27
|
+
McpClient[McpClient["MCP_CLIENT_HERMES"] = 12] = "MCP_CLIENT_HERMES";
|
|
27
28
|
McpClient[McpClient["MCP_CLIENT_OTHER"] = 3] = "MCP_CLIENT_OTHER";
|
|
28
29
|
})(McpClient || (McpClient = {}));
|
|
29
30
|
// IPC types for messages between the main process and the
|