cdp-toolkit 1.11.0 → 2.1.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/CHANGELOG.md +71 -0
- package/README.md +76 -7
- package/dist/cli.js +331 -299
- package/dist/index.js +11 -11
- package/dist/mcp.js +1002 -336
- package/package.json +3 -2
- package/src/bidi/driver.ts +29 -1
- package/src/bidi/launch.ts +51 -1
- package/src/manifest.ts +297 -297
- package/src/mcp.ts +187 -55
- package/src/toolDocs.ts +468 -0
- package/src/toolGroups.ts +81 -0
- package/src/tools/navigation.ts +4 -2
- package/src/version.ts +9 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const TOOL_GROUPS = [
|
|
2
|
+
"core", "input", "cookies", "network", "console", "mocking",
|
|
3
|
+
"emulation", "performance", "recording", "leases", "permissions",
|
|
4
|
+
"dialogs", "downloads",
|
|
5
|
+
] as const;
|
|
6
|
+
|
|
7
|
+
export type ToolGroup = (typeof TOOL_GROUPS)[number];
|
|
8
|
+
|
|
9
|
+
export const GROUP_TOOLS: Record<ToolGroup, readonly string[]> = {
|
|
10
|
+
core: [
|
|
11
|
+
"list_pages", "new_page", "close_page", "select_page", "navigate_page",
|
|
12
|
+
"wait_for", "take_snapshot", "click", "fill", "type_text",
|
|
13
|
+
"evaluate_script", "take_screenshot",
|
|
14
|
+
],
|
|
15
|
+
input: [
|
|
16
|
+
"hover", "drag", "scroll", "dispatch_mouse", "press_key", "fill_form",
|
|
17
|
+
"upload_file",
|
|
18
|
+
],
|
|
19
|
+
cookies: ["list_cookies", "set_cookie", "delete_cookies"],
|
|
20
|
+
network: ["list_network_requests", "get_network_request"],
|
|
21
|
+
console: ["list_console_messages", "get_console_message"],
|
|
22
|
+
mocking: ["mock_request", "list_mocks", "clear_mocks"],
|
|
23
|
+
emulation: ["emulate", "resize_page"],
|
|
24
|
+
performance: [
|
|
25
|
+
"performance_start_trace", "performance_stop_trace",
|
|
26
|
+
"performance_analyze_insight", "performance_trace", "take_heapsnapshot",
|
|
27
|
+
"lighthouse_audit",
|
|
28
|
+
],
|
|
29
|
+
recording: ["start_screen_recording", "stop_screen_recording"],
|
|
30
|
+
leases: ["claim_page", "release_page", "list_leases"],
|
|
31
|
+
permissions: ["grant_permissions"],
|
|
32
|
+
dialogs: ["handle_dialog"],
|
|
33
|
+
downloads: ["wait_for_download"],
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
export const TOOL_GROUP: Record<string, ToolGroup> = {};
|
|
37
|
+
|
|
38
|
+
for (const group of TOOL_GROUPS) {
|
|
39
|
+
for (const tool of GROUP_TOOLS[group]) {
|
|
40
|
+
TOOL_GROUP[tool] = group;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const PROFILES = {
|
|
45
|
+
core: ["core"],
|
|
46
|
+
full: [...TOOL_GROUPS],
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
export type ProfileName = keyof typeof PROFILES;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Resolve CDP_TOOL_PROFILE into the set of groups whose tools tools/list advertises.
|
|
53
|
+
*
|
|
54
|
+
* The profile is a STARTUP filter, read once: the listing it selects is fixed for the
|
|
55
|
+
* life of the process (2.1 dropped the runtime `browser_tools` toggle, so the tool set
|
|
56
|
+
* can never change as a side effect of another request — a spec MUST). Accepted
|
|
57
|
+
* spellings: unset/empty or "full" (everything), "core" (the lean everyday set), or a
|
|
58
|
+
* comma-separated list of group names. `core` is always included, so a list can never
|
|
59
|
+
* strand the basics.
|
|
60
|
+
*/
|
|
61
|
+
export function resolveProfile(spec: string | undefined): { groups: ReadonlySet<ToolGroup>; label: string } {
|
|
62
|
+
const all = (): { groups: ReadonlySet<ToolGroup>; label: string } => ({ groups: new Set(TOOL_GROUPS), label: "full" });
|
|
63
|
+
const raw = (spec ?? "").trim();
|
|
64
|
+
if (raw === "" || raw.toLowerCase() === "full") return all();
|
|
65
|
+
|
|
66
|
+
const tokens = raw.split(",").map((t) => t.trim().toLowerCase()).filter((t) => t !== "");
|
|
67
|
+
if (tokens.includes("full")) return all();
|
|
68
|
+
|
|
69
|
+
const known = new Set<string>(TOOL_GROUPS);
|
|
70
|
+
const picked = new Set<ToolGroup>(["core"]);
|
|
71
|
+
for (const token of tokens) {
|
|
72
|
+
if (!known.has(token)) {
|
|
73
|
+
throw new Error(`CDP_TOOL_PROFILE: unknown tool group '${token}'. Known: full, core, ${TOOL_GROUPS.filter((g) => g !== "core").join(", ")}`);
|
|
74
|
+
}
|
|
75
|
+
picked.add(token as ToolGroup);
|
|
76
|
+
}
|
|
77
|
+
if (picked.size === TOOL_GROUPS.length) return all();
|
|
78
|
+
// Canonical label: TOOL_GROUPS order, not the order the caller typed, so the ready
|
|
79
|
+
// line and the catalog header read the same for every equivalent spelling.
|
|
80
|
+
return { groups: picked, label: TOOL_GROUPS.filter((g) => picked.has(g)).join(",") };
|
|
81
|
+
}
|
package/src/tools/navigation.ts
CHANGED
|
@@ -25,7 +25,9 @@ export interface NavigatePageArgs {
|
|
|
25
25
|
/**
|
|
26
26
|
* When reloading, bypass the HTTP cache (hard reload) so freshly-deployed,
|
|
27
27
|
* non-content-hashed bundles are refetched instead of served stale. Ignored
|
|
28
|
-
* unless `reload` is true.
|
|
28
|
+
* unless `reload` is true. Chrome only: Firefox's BiDi server rejects the
|
|
29
|
+
* ignoreCache argument outright (even `false`), so the Firefox driver omits
|
|
30
|
+
* the key on plain reloads and throws a clear unsupported error when true.
|
|
29
31
|
*/
|
|
30
32
|
ignoreCache?: boolean;
|
|
31
33
|
/** Which load milestone to wait for. Defaults to 'load'. */
|
|
@@ -197,6 +199,6 @@ function delay(ms: number): Promise<void> {
|
|
|
197
199
|
* - Runtime.evaluate (poll document.body.innerText)
|
|
198
200
|
*
|
|
199
201
|
* Parity gaps vs chrome-devtools-mcp:
|
|
200
|
-
* - navigate_page: no automatic "snapshot of the new page" return; we return {url,frameId,waitedFor}. waitUntil supports 'load'|'domcontentloaded' only (no 'networkidle'). reload:true (+ignoreCache for a hard reload) covers the MCP's reload navigation type.
|
|
202
|
+
* - navigate_page: no automatic "snapshot of the new page" return; we return {url,frameId,waitedFor}. waitUntil supports 'load'|'domcontentloaded' only (no 'networkidle'). reload:true (+ignoreCache for a hard reload, Chrome only — Firefox rejects the argument outright) covers the MCP's reload navigation type.
|
|
201
203
|
* - wait_for: only text-substring waiting (innerText.includes); no aria/role/selector or "wait for event" variants. Throws on timeout rather than returning {found:false}.
|
|
202
204
|
*/
|
package/src/version.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the package version string.
|
|
3
|
+
*
|
|
4
|
+
* mcp.ts reports it in the MCP `serverInfo` (and thus in the 2026-07-28
|
|
5
|
+
* `_meta['io.modelcontextprotocol/serverInfo']` envelope) and on its stderr
|
|
6
|
+
* ready line; keeping it in its own module means a release bump touches one
|
|
7
|
+
* line here plus package.json, not a const buried in the server.
|
|
8
|
+
*/
|
|
9
|
+
export const VERSION = "2.1.0";
|