@eddym06/custom-chrome-mcp 1.0.2
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/.npmrc.example +2 -0
- package/CHANGELOG.md +87 -0
- package/INSTALL.md +148 -0
- package/LICENSE +21 -0
- package/README.md +403 -0
- package/dist/chrome-connector.d.ts +116 -0
- package/dist/chrome-connector.d.ts.map +1 -0
- package/dist/chrome-connector.js +452 -0
- package/dist/chrome-connector.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +211 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/anti-detection.d.ts +22 -0
- package/dist/tools/anti-detection.d.ts.map +1 -0
- package/dist/tools/anti-detection.js +220 -0
- package/dist/tools/anti-detection.js.map +1 -0
- package/dist/tools/capture.d.ts +130 -0
- package/dist/tools/capture.d.ts.map +1 -0
- package/dist/tools/capture.js +164 -0
- package/dist/tools/capture.js.map +1 -0
- package/dist/tools/interaction.d.ts +173 -0
- package/dist/tools/interaction.d.ts.map +1 -0
- package/dist/tools/interaction.js +274 -0
- package/dist/tools/interaction.js.map +1 -0
- package/dist/tools/navigation.d.ts +82 -0
- package/dist/tools/navigation.d.ts.map +1 -0
- package/dist/tools/navigation.js +196 -0
- package/dist/tools/navigation.js.map +1 -0
- package/dist/tools/playwright-launcher.d.ts +53 -0
- package/dist/tools/playwright-launcher.d.ts.map +1 -0
- package/dist/tools/playwright-launcher.js +117 -0
- package/dist/tools/playwright-launcher.js.map +1 -0
- package/dist/tools/service-worker.d.ts +128 -0
- package/dist/tools/service-worker.d.ts.map +1 -0
- package/dist/tools/service-worker.js +355 -0
- package/dist/tools/service-worker.js.map +1 -0
- package/dist/tools/session.d.ts +54 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +311 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/system.d.ts +159 -0
- package/dist/tools/system.d.ts.map +1 -0
- package/dist/tools/system.js +252 -0
- package/dist/tools/system.js.map +1 -0
- package/dist/types/index.d.ts +75 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/helpers.d.ts +53 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +122 -0
- package/dist/utils/helpers.js.map +1 -0
- package/mcp-config-example.json +12 -0
- package/package.json +61 -0
- package/test-playwright.js +57 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-level Chrome Tools
|
|
3
|
+
* For extensions, background workers, etc.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import CDP from 'chrome-remote-interface';
|
|
7
|
+
export function createSystemTools(connector) {
|
|
8
|
+
return [
|
|
9
|
+
// List all Chrome targets (including extension service workers)
|
|
10
|
+
{
|
|
11
|
+
name: 'list_all_targets',
|
|
12
|
+
description: 'List all Chrome targets including extension service workers, background pages, and more',
|
|
13
|
+
inputSchema: z.object({
|
|
14
|
+
filterType: z.enum(['all', 'service_worker', 'background_page', 'page', 'iframe', 'worker']).optional().describe('Filter by target type')
|
|
15
|
+
}),
|
|
16
|
+
handler: async ({ filterType }) => {
|
|
17
|
+
const port = connector.getPort();
|
|
18
|
+
const targets = await CDP.List({ port });
|
|
19
|
+
// Apply filter if specified
|
|
20
|
+
const filteredTargets = filterType && filterType !== 'all'
|
|
21
|
+
? targets.filter((t) => t.type === filterType)
|
|
22
|
+
: targets;
|
|
23
|
+
// Categorize targets
|
|
24
|
+
const pages = filteredTargets.filter((t) => t.type === 'page');
|
|
25
|
+
const serviceWorkers = filteredTargets.filter((t) => t.type === 'service_worker');
|
|
26
|
+
const backgroundPages = filteredTargets.filter((t) => t.type === 'background_page');
|
|
27
|
+
const iframes = filteredTargets.filter((t) => t.type === 'iframe');
|
|
28
|
+
const workers = filteredTargets.filter((t) => t.type === 'worker');
|
|
29
|
+
const others = filteredTargets.filter((t) => !['page', 'service_worker', 'background_page', 'iframe', 'worker'].includes(t.type));
|
|
30
|
+
// Separate extension service workers from web service workers
|
|
31
|
+
const extensionSWs = serviceWorkers.filter((t) => t.url.startsWith('chrome-extension://'));
|
|
32
|
+
const webSWs = serviceWorkers.filter((t) => !t.url.startsWith('chrome-extension://'));
|
|
33
|
+
return {
|
|
34
|
+
success: true,
|
|
35
|
+
total: filteredTargets.length,
|
|
36
|
+
breakdown: {
|
|
37
|
+
pages: pages.length,
|
|
38
|
+
serviceWorkers: serviceWorkers.length,
|
|
39
|
+
extensionServiceWorkers: extensionSWs.length,
|
|
40
|
+
webServiceWorkers: webSWs.length,
|
|
41
|
+
backgroundPages: backgroundPages.length,
|
|
42
|
+
iframes: iframes.length,
|
|
43
|
+
workers: workers.length,
|
|
44
|
+
others: others.length
|
|
45
|
+
},
|
|
46
|
+
targets: {
|
|
47
|
+
extensionServiceWorkers: extensionSWs.map((t) => ({
|
|
48
|
+
id: t.id,
|
|
49
|
+
title: t.title,
|
|
50
|
+
url: t.url,
|
|
51
|
+
extensionId: t.url.match(/chrome-extension:\/\/([^\/]+)/)?.[1] || 'unknown',
|
|
52
|
+
scriptPath: t.url.split('/').pop() || 'unknown',
|
|
53
|
+
description: t.description,
|
|
54
|
+
webSocketDebuggerUrl: t.webSocketDebuggerUrl
|
|
55
|
+
})),
|
|
56
|
+
webServiceWorkers: webSWs.map((t) => ({
|
|
57
|
+
id: t.id,
|
|
58
|
+
title: t.title,
|
|
59
|
+
url: t.url,
|
|
60
|
+
description: t.description,
|
|
61
|
+
webSocketDebuggerUrl: t.webSocketDebuggerUrl
|
|
62
|
+
})),
|
|
63
|
+
backgroundPages: backgroundPages.map((t) => ({
|
|
64
|
+
id: t.id,
|
|
65
|
+
title: t.title,
|
|
66
|
+
url: t.url,
|
|
67
|
+
extensionId: t.url.match(/chrome-extension:\/\/([^\/]+)/)?.[1],
|
|
68
|
+
type: t.type
|
|
69
|
+
})),
|
|
70
|
+
pages: pages.slice(0, 10).map((t) => ({
|
|
71
|
+
id: t.id,
|
|
72
|
+
title: t.title?.substring(0, 80) || 'No title',
|
|
73
|
+
url: t.url?.substring(0, 100) || 'No URL'
|
|
74
|
+
})),
|
|
75
|
+
iframes: iframes.length > 0 ? `${iframes.length} iframes found` : [],
|
|
76
|
+
workers: workers.length > 0 ? `${workers.length} workers found` : [],
|
|
77
|
+
others: others.length > 0 ? `${others.length} other targets found` : []
|
|
78
|
+
},
|
|
79
|
+
message: filterType ? `Filtered by: ${filterType}` : 'Showing all targets'
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
// Connect to a specific target (like extension service worker)
|
|
84
|
+
{
|
|
85
|
+
name: 'connect_to_target',
|
|
86
|
+
description: 'Connect to a specific Chrome target by ID (useful for extension service workers)',
|
|
87
|
+
inputSchema: z.object({
|
|
88
|
+
targetId: z.string().describe('Target ID to connect to')
|
|
89
|
+
}),
|
|
90
|
+
handler: async ({ targetId }) => {
|
|
91
|
+
const port = connector.getPort();
|
|
92
|
+
// Use a finder function to safely identify the target
|
|
93
|
+
const client = await CDP({
|
|
94
|
+
port,
|
|
95
|
+
target: (targets) => targets.find((t) => t.id === targetId)
|
|
96
|
+
});
|
|
97
|
+
if (!client) {
|
|
98
|
+
throw new Error(`Failed to connect to target ${targetId}`);
|
|
99
|
+
}
|
|
100
|
+
const { Runtime } = client;
|
|
101
|
+
await Runtime.enable();
|
|
102
|
+
// Get some info about the target
|
|
103
|
+
const result = await Runtime.evaluate({
|
|
104
|
+
expression: 'typeof self + " - " + (self.location ? self.location.href : "no location")',
|
|
105
|
+
returnByValue: true
|
|
106
|
+
});
|
|
107
|
+
await client.close();
|
|
108
|
+
return {
|
|
109
|
+
success: true,
|
|
110
|
+
targetId,
|
|
111
|
+
context: result.result.value,
|
|
112
|
+
message: 'Successfully connected to target'
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
// Execute code in a specific target
|
|
117
|
+
{
|
|
118
|
+
name: 'execute_in_target',
|
|
119
|
+
description: 'Execute JavaScript code in a specific target (extension service worker, etc.)',
|
|
120
|
+
inputSchema: z.object({
|
|
121
|
+
targetId: z.string().describe('Target ID'),
|
|
122
|
+
script: z.string().describe('JavaScript code to execute'),
|
|
123
|
+
awaitPromise: z.boolean().optional().default(false).describe('Wait for promise')
|
|
124
|
+
}),
|
|
125
|
+
handler: async ({ targetId, script, awaitPromise }) => {
|
|
126
|
+
const port = connector.getPort();
|
|
127
|
+
// Use a finder function to safely identify the target
|
|
128
|
+
const client = await CDP({
|
|
129
|
+
port,
|
|
130
|
+
target: (targets) => targets.find((t) => t.id === targetId)
|
|
131
|
+
});
|
|
132
|
+
if (!client) {
|
|
133
|
+
throw new Error(`Failed to connect to target ${targetId}`);
|
|
134
|
+
}
|
|
135
|
+
const { Runtime } = client;
|
|
136
|
+
await Runtime.enable();
|
|
137
|
+
const result = await Runtime.evaluate({
|
|
138
|
+
expression: script,
|
|
139
|
+
awaitPromise,
|
|
140
|
+
returnByValue: true
|
|
141
|
+
});
|
|
142
|
+
await client.close();
|
|
143
|
+
if (result.exceptionDetails) {
|
|
144
|
+
throw new Error(`Script execution failed: ${result.exceptionDetails.text}`);
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
result: result.result.value,
|
|
149
|
+
type: result.result.type
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
// Get extension service worker details
|
|
154
|
+
{
|
|
155
|
+
name: 'get_extension_service_workers',
|
|
156
|
+
description: 'Get all extension service workers with detailed information and runtime access',
|
|
157
|
+
inputSchema: z.object({
|
|
158
|
+
executeTest: z.boolean().optional().default(false).describe('Execute a test script to verify chrome.runtime access')
|
|
159
|
+
}),
|
|
160
|
+
handler: async ({ executeTest }) => {
|
|
161
|
+
const port = connector.getPort();
|
|
162
|
+
const targets = await CDP.List({ port });
|
|
163
|
+
const serviceWorkers = targets.filter((t) => t.type === 'service_worker' && t.url.startsWith('chrome-extension://'));
|
|
164
|
+
if (serviceWorkers.length === 0) {
|
|
165
|
+
return {
|
|
166
|
+
success: true,
|
|
167
|
+
count: 0,
|
|
168
|
+
message: 'No extension service workers found. Make sure Chrome/Edge is opened with extensions enabled.',
|
|
169
|
+
serviceWorkers: []
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const details = await Promise.all(serviceWorkers.map(async (sw) => {
|
|
173
|
+
try {
|
|
174
|
+
// Connect using finder function
|
|
175
|
+
const client = await CDP({
|
|
176
|
+
port,
|
|
177
|
+
target: (targets) => targets.find((t) => t.id === sw.id)
|
|
178
|
+
});
|
|
179
|
+
if (!client)
|
|
180
|
+
throw new Error("Could not connect");
|
|
181
|
+
const { Runtime } = client;
|
|
182
|
+
await Runtime.enable();
|
|
183
|
+
// Get comprehensive extension info
|
|
184
|
+
const infoScript = `
|
|
185
|
+
JSON.stringify({
|
|
186
|
+
hasChrome: typeof chrome !== 'undefined',
|
|
187
|
+
hasRuntime: typeof chrome !== 'undefined' && typeof chrome.runtime !== 'undefined',
|
|
188
|
+
extensionId: typeof chrome !== 'undefined' && chrome.runtime ? chrome.runtime.id : null,
|
|
189
|
+
manifest: typeof chrome !== 'undefined' && chrome.runtime ? chrome.runtime.getManifest() : null,
|
|
190
|
+
contextType: typeof ServiceWorkerGlobalScope !== 'undefined' ? 'ServiceWorker' : typeof self !== 'undefined' ? 'Worker' : 'Unknown'
|
|
191
|
+
})
|
|
192
|
+
`;
|
|
193
|
+
const info = await Runtime.evaluate({
|
|
194
|
+
expression: infoScript,
|
|
195
|
+
returnByValue: true,
|
|
196
|
+
awaitPromise: false
|
|
197
|
+
});
|
|
198
|
+
let testResult = null;
|
|
199
|
+
if (executeTest) {
|
|
200
|
+
const test = await Runtime.evaluate({
|
|
201
|
+
expression: 'typeof chrome !== "undefined" ? "Chrome API Available" : "No Chrome API"',
|
|
202
|
+
returnByValue: true
|
|
203
|
+
});
|
|
204
|
+
testResult = test.result.value;
|
|
205
|
+
}
|
|
206
|
+
await client.close();
|
|
207
|
+
const extInfo = JSON.parse(info.result.value || '{}');
|
|
208
|
+
const extensionId = sw.url.match(/chrome-extension:\/\/([^\/]+)/)?.[1];
|
|
209
|
+
return {
|
|
210
|
+
id: sw.id,
|
|
211
|
+
title: sw.title,
|
|
212
|
+
url: sw.url,
|
|
213
|
+
extensionId: extensionId,
|
|
214
|
+
scriptFile: sw.url.split('/').pop(),
|
|
215
|
+
description: sw.description,
|
|
216
|
+
webSocketDebuggerUrl: sw.webSocketDebuggerUrl,
|
|
217
|
+
runtimeInfo: {
|
|
218
|
+
hasChrome: extInfo.hasChrome,
|
|
219
|
+
hasRuntime: extInfo.hasRuntime,
|
|
220
|
+
contextType: extInfo.contextType,
|
|
221
|
+
manifestName: extInfo.manifest?.name,
|
|
222
|
+
manifestVersion: extInfo.manifest?.version,
|
|
223
|
+
permissions: extInfo.manifest?.permissions?.slice(0, 5)
|
|
224
|
+
},
|
|
225
|
+
testResult: executeTest ? testResult : undefined
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
return {
|
|
230
|
+
id: sw.id,
|
|
231
|
+
title: sw.title,
|
|
232
|
+
url: sw.url,
|
|
233
|
+
extensionId: sw.url.match(/chrome-extension:\/\/([^\/]+)/)?.[1],
|
|
234
|
+
error: error.message
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}));
|
|
238
|
+
return {
|
|
239
|
+
success: true,
|
|
240
|
+
count: details.length,
|
|
241
|
+
serviceWorkers: details,
|
|
242
|
+
summary: {
|
|
243
|
+
total: details.length,
|
|
244
|
+
successful: details.filter(d => !d.error).length,
|
|
245
|
+
failed: details.filter(d => d.error).length
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
];
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;yBACjD,CAAC;oBACJ,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO;4BACL,EAAE,EAAE,EAAE,CAAC,EAAE;4BACT,KAAK,EAAE,EAAE,CAAC,KAAK;4BACf,GAAG,EAAE,EAAE,CAAC,GAAG;4BACX,WAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAC,CAAC;4BAC/D,KAAK,EAAG,KAAe,CAAC,OAAO;yBAChC,CAAC;oBACJ,CAAC;gBACH,CAAC,CAAC,CACH,CAAC;gBAEF,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,OAAO,CAAC,MAAM;oBACrB,cAAc,EAAE,OAAO;oBACvB,OAAO,EAAE;wBACP,KAAK,EAAE,OAAO,CAAC,MAAM;wBACrB,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM;wBAChD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM;qBAC5C;iBACF,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Custom Chrome MCP
|
|
3
|
+
*/
|
|
4
|
+
export interface ChromeConnection {
|
|
5
|
+
client: any;
|
|
6
|
+
connected: boolean;
|
|
7
|
+
port: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TabInfo {
|
|
10
|
+
id: string;
|
|
11
|
+
type: string;
|
|
12
|
+
title: string;
|
|
13
|
+
url: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ServiceWorkerInfo {
|
|
17
|
+
registrationId: string;
|
|
18
|
+
scopeURL: string;
|
|
19
|
+
scriptURL: string;
|
|
20
|
+
status: string;
|
|
21
|
+
versionId: string;
|
|
22
|
+
runningStatus?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CaptureOptions {
|
|
25
|
+
format?: 'png' | 'jpeg';
|
|
26
|
+
quality?: number;
|
|
27
|
+
fullPage?: boolean;
|
|
28
|
+
clip?: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface NetworkRequest {
|
|
36
|
+
requestId: string;
|
|
37
|
+
url: string;
|
|
38
|
+
method: string;
|
|
39
|
+
status?: number;
|
|
40
|
+
statusText?: string;
|
|
41
|
+
headers: Record<string, string>;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
}
|
|
44
|
+
export interface ConsoleMessage {
|
|
45
|
+
type: 'log' | 'warning' | 'error' | 'info' | 'debug';
|
|
46
|
+
text: string;
|
|
47
|
+
timestamp: number;
|
|
48
|
+
url?: string;
|
|
49
|
+
lineNumber?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface Cookie {
|
|
52
|
+
name: string;
|
|
53
|
+
value: string;
|
|
54
|
+
domain: string;
|
|
55
|
+
path: string;
|
|
56
|
+
expires?: number;
|
|
57
|
+
httpOnly?: boolean;
|
|
58
|
+
secure?: boolean;
|
|
59
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
60
|
+
}
|
|
61
|
+
export interface SessionData {
|
|
62
|
+
cookies: Cookie[];
|
|
63
|
+
localStorage: Record<string, string>;
|
|
64
|
+
sessionStorage: Record<string, string>;
|
|
65
|
+
timestamp: number;
|
|
66
|
+
}
|
|
67
|
+
export interface PerformanceMetrics {
|
|
68
|
+
firstContentfulPaint?: number;
|
|
69
|
+
largestContentfulPaint?: number;
|
|
70
|
+
timeToInteractive?: number;
|
|
71
|
+
totalBlockingTime?: number;
|
|
72
|
+
cumulativeLayoutShift?: number;
|
|
73
|
+
timestamp: number;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,GAAG,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE;QACL,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC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@@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for Custom Chrome MCP
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Add random human-like delay
|
|
6
|
+
*/
|
|
7
|
+
export declare function humanDelay(min?: number, max?: number): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Generate random mouse movement path
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateMousePath(from: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}, to: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}, steps?: number): Array<{
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Wait for condition with timeout
|
|
23
|
+
*/
|
|
24
|
+
export declare function waitFor(condition: () => Promise<boolean> | boolean, timeout?: number, interval?: number): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Retry function with exponential backoff
|
|
27
|
+
*/
|
|
28
|
+
export declare function retry<T>(fn: () => Promise<T>, maxRetries?: number, baseDelay?: number): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Parse CSS selector to CDP selector
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseSelectorToCDP(selector: string): any;
|
|
33
|
+
/**
|
|
34
|
+
* Format bytes to human readable
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatBytes(bytes: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Generate unique ID
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateId(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Deep clone object
|
|
43
|
+
*/
|
|
44
|
+
export declare function deepClone<T>(obj: T): T;
|
|
45
|
+
/**
|
|
46
|
+
* Check if URL is valid
|
|
47
|
+
*/
|
|
48
|
+
export declare function isValidUrl(url: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Extract domain from URL
|
|
51
|
+
*/
|
|
52
|
+
export declare function extractDomain(url: string): string;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GAAG,CAAC,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO/C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOjD"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for Custom Chrome MCP
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Add random human-like delay
|
|
6
|
+
*/
|
|
7
|
+
export async function humanDelay(min = 100, max = 500) {
|
|
8
|
+
const delay = Math.random() * (max - min) + min;
|
|
9
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generate random mouse movement path
|
|
13
|
+
*/
|
|
14
|
+
export function generateMousePath(from, to, steps = 10) {
|
|
15
|
+
const path = [];
|
|
16
|
+
for (let i = 0; i <= steps; i++) {
|
|
17
|
+
const t = i / steps;
|
|
18
|
+
// Add some randomness to make it more human-like
|
|
19
|
+
const noise = (Math.random() - 0.5) * 2;
|
|
20
|
+
path.push({
|
|
21
|
+
x: from.x + (to.x - from.x) * t + noise,
|
|
22
|
+
y: from.y + (to.y - from.y) * t + noise
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return path;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wait for condition with timeout
|
|
29
|
+
*/
|
|
30
|
+
export async function waitFor(condition, timeout = 30000, interval = 100) {
|
|
31
|
+
const startTime = Date.now();
|
|
32
|
+
while (Date.now() - startTime < timeout) {
|
|
33
|
+
try {
|
|
34
|
+
if (await condition()) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
// Continue waiting
|
|
40
|
+
}
|
|
41
|
+
await new Promise(resolve => setTimeout(resolve, interval));
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retry function with exponential backoff
|
|
47
|
+
*/
|
|
48
|
+
export async function retry(fn, maxRetries = 3, baseDelay = 1000) {
|
|
49
|
+
let lastError;
|
|
50
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
51
|
+
try {
|
|
52
|
+
return await fn();
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
lastError = error;
|
|
56
|
+
if (i < maxRetries - 1) {
|
|
57
|
+
const delay = baseDelay * Math.pow(2, i);
|
|
58
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw lastError;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parse CSS selector to CDP selector
|
|
66
|
+
*/
|
|
67
|
+
export function parseSelectorToCDP(selector) {
|
|
68
|
+
// Simple CSS to CDP selector conversion
|
|
69
|
+
// This is a basic implementation, can be enhanced
|
|
70
|
+
return {
|
|
71
|
+
type: 'css',
|
|
72
|
+
value: selector
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Format bytes to human readable
|
|
77
|
+
*/
|
|
78
|
+
export function formatBytes(bytes) {
|
|
79
|
+
if (bytes === 0)
|
|
80
|
+
return '0 Bytes';
|
|
81
|
+
const k = 1024;
|
|
82
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
83
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
84
|
+
return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generate unique ID
|
|
88
|
+
*/
|
|
89
|
+
export function generateId() {
|
|
90
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Deep clone object
|
|
94
|
+
*/
|
|
95
|
+
export function deepClone(obj) {
|
|
96
|
+
return JSON.parse(JSON.stringify(obj));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if URL is valid
|
|
100
|
+
*/
|
|
101
|
+
export function isValidUrl(url) {
|
|
102
|
+
try {
|
|
103
|
+
new URL(url);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Extract domain from URL
|
|
112
|
+
*/
|
|
113
|
+
export function extractDomain(url) {
|
|
114
|
+
try {
|
|
115
|
+
const urlObj = new URL(url);
|
|
116
|
+
return urlObj.hostname;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc,GAAG,EAAE,MAAc,GAAG;IACnE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IAChD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAA8B,EAC9B,EAA4B,EAC5B,QAAgB,EAAE;IAElB,MAAM,IAAI,GAAoC,EAAE,CAAC;IAEjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,iDAAiD;QACjD,MAAM,KAAK,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CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAI,GAAM;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eddym06/custom-chrome-mcp",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Cross-platform Chrome MCP with enhanced features: connect to existing Chrome, anti-detection, service workers, session management, Shadow Profile system, and more. Works on Windows, Mac, and Linux.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"custom-chrome-mcp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"prepare": "npm run build",
|
|
14
|
+
"start": "node dist/index.js",
|
|
15
|
+
"lint": "eslint src --ext .ts",
|
|
16
|
+
"format": "prettier --write \"src/**/*.ts\""
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"mcp",
|
|
20
|
+
"chrome",
|
|
21
|
+
"devtools",
|
|
22
|
+
"automation",
|
|
23
|
+
"cdp",
|
|
24
|
+
"service-worker",
|
|
25
|
+
"anti-detection",
|
|
26
|
+
"model-context-protocol",
|
|
27
|
+
"cross-platform",
|
|
28
|
+
"windows",
|
|
29
|
+
"mac",
|
|
30
|
+
"linux",
|
|
31
|
+
"playwright",
|
|
32
|
+
"browser-automation"
|
|
33
|
+
],
|
|
34
|
+
"author": "Eddy M",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
38
|
+
"chrome-remote-interface": "^0.33.2",
|
|
39
|
+
"playwright": "^1.57.0",
|
|
40
|
+
"playwright-core": "^1.57.0",
|
|
41
|
+
"zod": "^3.23.8"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.10.5",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
46
|
+
"@typescript-eslint/parser": "^8.19.1",
|
|
47
|
+
"eslint": "^9.18.0",
|
|
48
|
+
"prettier": "^3.4.2",
|
|
49
|
+
"typescript": "^5.7.2"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=18.0.0"
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/Eddym06/devTools-Advance-mcp.git"
|
|
57
|
+
},
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/Eddym06/devTools-Advance-mcp/issues"
|
|
60
|
+
}
|
|
61
|
+
}
|