browser-console-mcp 1.0.1 → 1.0.4
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/bin/copy-html2canvas.js +26 -2
- package/dist/browser/index.js +1 -1
- package/dist/client/browser-console-mcp.js +1 -1
- package/dist/client/index.js +13 -13
- package/dist/server/index.js +9 -9
- package/dist/server/static-server.js +4 -4
- package/package.json +10 -2
- package/readme.md +110 -196
- package/dist/browser/index.js.map +0 -1
- package/dist/client/browser-console-mcp.js.map +0 -1
- package/rollup.browser.config.js +0 -23
- package/rollup.config.js +0 -22
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var BrowserConsoleMCP=function(){"use strict";const e=new class{constructor(e="ws://localhost:7898/browser"){this.ws=null,this.connected=!1,this.commandHistory=[],this.historyIndex=-1,this.serverUrl=e}connect(){try{this.loadHtml2Canvas().then((()=>{this.ws=new WebSocket(this.serverUrl),this.ws.onopen=()=>{this.connected=!0,console.
|
|
1
|
+
var BrowserConsoleMCP=function(){"use strict";const e=new class{constructor(e="ws://localhost:7898/browser"){this.ws=null,this.connected=!1,this.commandHistory=[],this.historyIndex=-1,this.serverUrl=e}connect(){try{this.loadHtml2Canvas().then((()=>{this.ws=new WebSocket(this.serverUrl),this.ws.onopen=()=>{this.connected=!0,console.log("%c[MCP Client] Connected to server","color: green"),this.registerConsoleCommands()},this.ws.onmessage=e=>{try{const t=JSON.parse(e.data);this.handleServerMessage(t)}catch(e){console.error("[MCP Client] Message parsing error:",e)}},this.ws.onclose=()=>{this.connected=!1,console.log("%c[MCP Client] Disconnected from server","color: orange")},this.ws.onerror=e=>{console.error("[MCP Client] WebSocket error:",e)}})).catch((e=>{console.error("[MCP Client] Failed to load html2canvas:",e)}))}catch(e){console.error("[MCP Client] Connection error:",e)}}loadHtml2Canvas(){return new Promise(((e,t)=>{if(void 0!==window.html2canvas)return console.log("[MCP Client] html2canvas already loaded"),void e(!0);console.log("[MCP Client] Loading html2canvas...");const n=document.createElement("script");n.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",n.onload=()=>{console.log("[MCP Client] html2canvas loaded from CDN"),e(!0)},n.onerror=()=>{console.log("[MCP Client] Trying local path for html2canvas...");const n=document.createElement("script");n.src="/html2canvas.min.js",n.onload=()=>{console.log("[MCP Client] html2canvas loaded from local path"),e(!0)},n.onerror=n=>{console.log("[MCP Client] Trying unpkg CDN for html2canvas...");const o=document.createElement("script");o.src="https://unpkg.com/html2canvas/dist/html2canvas.min.js",o.onload=()=>{console.log("[MCP Client] html2canvas loaded from unpkg CDN"),e(!0)},o.onerror=e=>{console.error("[MCP Client] Failed to load html2canvas:",e),t(new Error("Unable to load html2canvas library, please ensure your network connection is working"))},document.head.appendChild(o)},document.head.appendChild(n)},document.head.appendChild(n)}))}handleServerMessage(e){if("get_page_html"!==e.type)if("execute_js"!==e.type)if("get_page_title"!==e.type)if("get_elements"!==e.type)if("capture_screenshot"!==e.type)if("get_page_url"!==e.type)if("click_element"!==e.type)if("input_text"!==e.type)switch(e.type){case"command_result":console.log(`%c[MCP Server] ${e.payload?.result}`,"color: blue");break;case"error":console.error(`[MCP Server] Error: ${e.payload?.error}`);break;case"connection_status":console.log(`%c[MCP Server] ${e.message}`,"color: green");break;default:console.log(`[MCP Server] Received message type: ${e.type}`)}else{const t=e.requestId,n=e.selector,o=e.text;try{const e=document.querySelector(n);if(!e)return void this.sendError(t,`Input field not found: ${n}`);if("INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName)return void this.sendError(t,`Selected element is not an input field: ${e.tagName}`);e.value=o,e.dispatchEvent(new Event("input",{bubbles:!0})),this.sendResponse(t,{success:!0,message:`Successfully input text to: ${n}`})}catch(e){this.sendError(t,`Error inputting text: ${e.message}`)}}else{const t=e.requestId,n=e.selector;try{const e=document.querySelector(n);if(!e)return void this.sendError(t,`Element not found: ${n}`);e.click(),this.sendResponse(t,{success:!0,message:`Successfully clicked element: ${n}`})}catch(e){this.sendError(t,`Error clicking element: ${e.message}`)}}else{const t=e.requestId;try{const e=window.location.href;this.sendResponse(t,{url:e})}catch(e){this.sendError(t,`Error getting URL: ${e.message}`)}}else{const t=e.requestId,n=e.selector||"body";(async()=>{try{await this.loadHtml2Canvas();const e=document.querySelector(n);if(!e)return void this.sendError(t,`Element not found: ${n}`);const o={allowTaint:!0,useCORS:!0,logging:!1,scale:window.devicePixelRatio||1,backgroundColor:null,removeContainer:!0,x:0,y:0,scrollX:0,scrollY:0,width:e.offsetWidth,height:e.offsetHeight},s=window.html2canvas;if(!s)return void this.sendError(t,"html2canvas library not properly loaded");let r=await s(e,o);if(!r)return void this.sendError(t,"Screenshot failed: unable to create canvas");const c=r.getContext("2d");if(c){const e=c.getImageData(0,0,r.width,r.height),t=this.getContentBounds(e);if(t){const e=document.createElement("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n&&(n.drawImage(r,t.left,t.top,t.width,t.height,0,0,t.width,t.height),r=e)}}const i=r.toDataURL("image/png");this.sendResponse(t,{imageDataUrl:i})}catch(e){console.error("[MCP Client] Screenshot error:",e),this.sendError(t,`Screenshot error: ${e.message}`)}})()}else{const t=e.requestId,n=e.selector;try{const e=[...document.querySelectorAll(n)].map((e=>({tagName:e.tagName,id:e.id,className:e.className,textContent:e.textContent?.trim().substring(0,500)||"",attributes:[...e.attributes].reduce(((e,t)=>(e[t.name]=t.value,e)),{})})));this.sendResponse(t,{elements:e})}catch(e){this.sendError(t,`Error getting elements: ${e.message}`)}}else{const t=e.requestId;try{const e=document.title;this.sendResponse(t,{title:e})}catch(e){this.sendError(t,`Error getting title: ${e.message}`)}}else{const t=e.requestId,n=e.code;try{const e=new Function(n)();let o;try{o=JSON.stringify(e)}catch(t){o=String(e)}const s={requestId:t,result:o};this.ws?.send(JSON.stringify(s))}catch(e){console.error("[MCP Client] Error executing JavaScript:",e),this.sendError(t,`Error executing JavaScript: ${e.message}`)}}else{const t=e.requestId;try{const e=document.documentElement.outerHTML;this.sendResponse(t,{html:e})}catch(e){this.sendError(t,`Error getting HTML: ${e.message}`)}}}sendResponse(e,t){if(!this.connected||!this.ws)return void console.error("[MCP Client] Not connected to server, cannot send response");const n={requestId:e,...t};this.ws.send(JSON.stringify(n))}sendError(e,t){if(!this.connected||!this.ws)return void console.error("[MCP Client] Not connected to server, cannot send error response");const n={requestId:e,error:t};this.ws.send(JSON.stringify(n))}sendCommand(e){if(!this.connected||!this.ws)return void console.error("[MCP Client] Not connected to server");const t={type:"command",payload:{command:e}};this.ws.send(JSON.stringify(t)),this.commandHistory.push(e),this.historyIndex=this.commandHistory.length}registerConsoleCommands(){window.mcp={exec:e=>(this.sendCommand(e),"Command sent"),disconnect:()=>(this.ws&&(this.ws.close(),this.ws=null),"Disconnected"),reconnect:()=>(this.connect(),"Reconnecting..."),help:()=>"\nMCP Client Commands:\n mcp.exec(command) - Execute a command\n mcp.disconnect() - Disconnect from server\n mcp.reconnect() - Reconnect to server\n mcp.help() - Show help information\n "},console.log("%c[MCP Client] Console commands registered, use mcp.help() to see available commands","color: green")}getContentBounds(e){const{width:t,height:n,data:o}=e;let s=t,r=n,c=0,i=0,a=!1;for(let e=0;e<n;e++)for(let n=0;n<t;n++){o[4*(e*t+n)+3]>10&&(a=!0,s=Math.min(s,n),r=Math.min(r,e),c=Math.max(c,n),i=Math.max(i,e))}if(!a)return null;return s=Math.max(0,s-10),r=Math.max(0,r-10),c=Math.min(t-1,c+10),i=Math.min(n-1,i+10),{left:s,top:r,width:c-s+1,height:i-r+1}}};return e.connect(),e}();
|
|
2
2
|
//# sourceMappingURL=browser-console-mcp.js.map
|
package/dist/client/index.js
CHANGED
|
@@ -22,7 +22,7 @@ class BrowserConsoleMCP {
|
|
|
22
22
|
this.ws = new WebSocket(this.serverUrl);
|
|
23
23
|
this.ws.onopen = () => {
|
|
24
24
|
this.connected = true;
|
|
25
|
-
console.
|
|
25
|
+
console.log("%c[MCP Client] Connected to server", "color: green");
|
|
26
26
|
this.registerConsoleCommands();
|
|
27
27
|
};
|
|
28
28
|
this.ws.onmessage = (event) => {
|
|
@@ -36,7 +36,7 @@ class BrowserConsoleMCP {
|
|
|
36
36
|
};
|
|
37
37
|
this.ws.onclose = () => {
|
|
38
38
|
this.connected = false;
|
|
39
|
-
console.
|
|
39
|
+
console.log("%c[MCP Client] Disconnected from server", "color: orange");
|
|
40
40
|
};
|
|
41
41
|
this.ws.onerror = (error) => {
|
|
42
42
|
console.error("[MCP Client] WebSocket error:", error);
|
|
@@ -56,35 +56,35 @@ class BrowserConsoleMCP {
|
|
|
56
56
|
loadHtml2Canvas() {
|
|
57
57
|
return new Promise((resolve, reject) => {
|
|
58
58
|
if (typeof window.html2canvas !== "undefined") {
|
|
59
|
-
console.
|
|
59
|
+
console.log("[MCP Client] html2canvas already loaded");
|
|
60
60
|
resolve(true);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
console.
|
|
63
|
+
console.log("[MCP Client] Loading html2canvas...");
|
|
64
64
|
// Prioritize loading html2canvas from CDN
|
|
65
65
|
const script = document.createElement("script");
|
|
66
66
|
script.src = "https://html2canvas.hertzen.com/dist/html2canvas.min.js";
|
|
67
67
|
script.onload = () => {
|
|
68
|
-
console.
|
|
68
|
+
console.log("[MCP Client] html2canvas loaded from CDN");
|
|
69
69
|
resolve(true);
|
|
70
70
|
};
|
|
71
71
|
script.onerror = () => {
|
|
72
72
|
// If CDN fails, try local path
|
|
73
|
-
console.
|
|
73
|
+
console.log("[MCP Client] Trying local path for html2canvas...");
|
|
74
74
|
const localScript = document.createElement("script");
|
|
75
75
|
localScript.src = "/html2canvas.min.js";
|
|
76
76
|
localScript.onload = () => {
|
|
77
|
-
console.
|
|
77
|
+
console.log("[MCP Client] html2canvas loaded from local path");
|
|
78
78
|
resolve(true);
|
|
79
79
|
};
|
|
80
80
|
localScript.onerror = (err) => {
|
|
81
81
|
// Try using unpkg CDN
|
|
82
|
-
console.
|
|
82
|
+
console.log("[MCP Client] Trying unpkg CDN for html2canvas...");
|
|
83
83
|
const unpkgScript = document.createElement("script");
|
|
84
84
|
unpkgScript.src =
|
|
85
85
|
"https://unpkg.com/html2canvas/dist/html2canvas.min.js";
|
|
86
86
|
unpkgScript.onload = () => {
|
|
87
|
-
console.
|
|
87
|
+
console.log("[MCP Client] html2canvas loaded from unpkg CDN");
|
|
88
88
|
resolve(true);
|
|
89
89
|
};
|
|
90
90
|
unpkgScript.onerror = (err) => {
|
|
@@ -313,17 +313,17 @@ class BrowserConsoleMCP {
|
|
|
313
313
|
// Handle other message types
|
|
314
314
|
switch (message.type) {
|
|
315
315
|
case "command_result":
|
|
316
|
-
console.
|
|
316
|
+
console.log(`%c[MCP Server] ${message.payload?.result}`, "color: blue");
|
|
317
317
|
break;
|
|
318
318
|
case "error":
|
|
319
319
|
console.error(`[MCP Server] Error: ${message.payload?.error}`);
|
|
320
320
|
break;
|
|
321
321
|
case "connection_status":
|
|
322
|
-
console.
|
|
322
|
+
console.log(`%c[MCP Server] ${message.message}`, "color: green");
|
|
323
323
|
break;
|
|
324
324
|
default:
|
|
325
325
|
// Only log message type, not full message content
|
|
326
|
-
console.
|
|
326
|
+
console.log(`[MCP Server] Received message type: ${message.type}`);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
/**
|
|
@@ -401,7 +401,7 @@ MCP Client Commands:
|
|
|
401
401
|
`;
|
|
402
402
|
},
|
|
403
403
|
};
|
|
404
|
-
console.
|
|
404
|
+
console.log("%c[MCP Client] Console commands registered, use mcp.help() to see available commands", "color: green");
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
407
407
|
* Get image content boundaries, remove excess whitespace
|
package/dist/server/index.js
CHANGED
|
@@ -35,9 +35,9 @@ class BrowserConsoleMCPServer {
|
|
|
35
35
|
this.staticServer.start();
|
|
36
36
|
// Start HTTP server
|
|
37
37
|
this.httpServer.listen(this.port, () => {
|
|
38
|
-
console.
|
|
39
|
-
console.
|
|
40
|
-
console.
|
|
38
|
+
console.log(`[MCP Server] HTTP server started on port ${this.port}`);
|
|
39
|
+
console.log(`[MCP Server] WebSocket server path: ws://localhost:${this.port}/ws`);
|
|
40
|
+
console.log(`[MCP Server] Static files will be redirected to port ${this.staticServer.getPort()}`);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -47,7 +47,7 @@ class BrowserConsoleMCPServer {
|
|
|
47
47
|
this.wss.on("connection", (ws) => {
|
|
48
48
|
const clientId = this.generateClientId();
|
|
49
49
|
this.clients.set(clientId, { id: clientId, ws });
|
|
50
|
-
console.
|
|
50
|
+
console.log(`[MCP Server] Client ${clientId} connected`);
|
|
51
51
|
ws.on("message", (data) => {
|
|
52
52
|
try {
|
|
53
53
|
const message = JSON.parse(data.toString());
|
|
@@ -59,7 +59,7 @@ class BrowserConsoleMCPServer {
|
|
|
59
59
|
});
|
|
60
60
|
ws.on("close", () => {
|
|
61
61
|
this.clients.delete(clientId);
|
|
62
|
-
console.
|
|
62
|
+
console.log(`[MCP Server] Client ${clientId} disconnected`);
|
|
63
63
|
});
|
|
64
64
|
ws.on("error", (error) => {
|
|
65
65
|
console.error(`[MCP Server] WebSocket error (client ${clientId}):`, error);
|
|
@@ -79,7 +79,7 @@ class BrowserConsoleMCPServer {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
// Only log message type, not the full message content
|
|
82
|
-
console.
|
|
82
|
+
console.log(`[MCP Server] Received message type ${message.type} from client ${clientId}`);
|
|
83
83
|
switch (message.type) {
|
|
84
84
|
case "command":
|
|
85
85
|
this.executeCommand(client, message.payload?.command);
|
|
@@ -96,7 +96,7 @@ class BrowserConsoleMCPServer {
|
|
|
96
96
|
this.sendErrorToClient(client, "Command is empty");
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
console.
|
|
99
|
+
console.log(`[MCP Server] Executing command: ${command}`);
|
|
100
100
|
exec(command, (error, stdout, stderr) => {
|
|
101
101
|
if (error) {
|
|
102
102
|
this.sendErrorToClient(client, `Command execution error: ${error.message}`);
|
|
@@ -139,7 +139,7 @@ class BrowserConsoleMCPServer {
|
|
|
139
139
|
this.httpServer.close();
|
|
140
140
|
this.wss.close();
|
|
141
141
|
this.staticServer.stop();
|
|
142
|
-
console.
|
|
142
|
+
console.log("[MCP Server] Server closed");
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
// Create and start server instance
|
|
@@ -147,7 +147,7 @@ const server = new BrowserConsoleMCPServer();
|
|
|
147
147
|
server.start();
|
|
148
148
|
// Handle process exit
|
|
149
149
|
process.on("SIGINT", () => {
|
|
150
|
-
console.
|
|
150
|
+
console.log("[MCP Server] Shutting down server...");
|
|
151
151
|
server.stop();
|
|
152
152
|
process.exit(0);
|
|
153
153
|
});
|
|
@@ -141,7 +141,7 @@ mcp.reconnect();</code></pre>
|
|
|
141
141
|
Expires: "0",
|
|
142
142
|
});
|
|
143
143
|
res.end(fileContent);
|
|
144
|
-
console.
|
|
144
|
+
console.log(`[Static Server] Successfully served static file: ${filePath}`);
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
147
|
console.error(`[Static Server] Static file not found: ${filePath}`);
|
|
@@ -160,8 +160,8 @@ mcp.reconnect();</code></pre>
|
|
|
160
160
|
*/
|
|
161
161
|
start() {
|
|
162
162
|
this.server.listen(this.port, () => {
|
|
163
|
-
console.
|
|
164
|
-
console.
|
|
163
|
+
console.log(`[Static Server] Server started, listening on port ${this.port}`);
|
|
164
|
+
console.log(`[Static Server] Client JS file URL: http://localhost:${this.port}/browser-console-mcp.js`);
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
@@ -169,7 +169,7 @@ mcp.reconnect();</code></pre>
|
|
|
169
169
|
*/
|
|
170
170
|
stop() {
|
|
171
171
|
this.server.close(() => {
|
|
172
|
-
console.
|
|
172
|
+
console.log("[Static Server] Server closed");
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-console-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "MCP client for browser console and server for Cursor",
|
|
5
5
|
"main": "dist/server/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
37
37
|
"@types/node": "^20.17.46",
|
|
38
38
|
"@types/ws": "^8.18.1",
|
|
39
|
+
"html2canvas": "^1.4.1",
|
|
39
40
|
"rollup": "^4.12.1",
|
|
40
41
|
"rollup-plugin-terser": "^7.0.2",
|
|
41
42
|
"tslib": "^2.8.1",
|
|
@@ -43,10 +44,17 @@
|
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@modelcontextprotocol/sdk": "^1.5.0",
|
|
46
|
-
"html2canvas": "^1.4.1",
|
|
47
47
|
"ws": "^8.16.0",
|
|
48
48
|
"zod": "^3.24.4"
|
|
49
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"html2canvas": "^1.4.1"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"html2canvas": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
50
58
|
"scripts": {
|
|
51
59
|
"build": "tsc",
|
|
52
60
|
"build:client": "rollup -c",
|
package/readme.md
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Browser console MCP client and Cursor MCP server. Let your AI assistant control the browser!
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
<summary>English (Default)</summary>
|
|
5
|
+
**Language**: [English](#english) | [中文](#中文) | [日本語](#日本語) | [한국어](#한국어)
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## English
|
|
8
|
+
|
|
9
|
+
### Introduction
|
|
9
10
|
|
|
10
11
|
Browser Console MCP is a tool that allows Cursor's Claude AI assistant to interact with the browser through the MCP (Model Context Protocol) protocol. It provides a browser client and an MCP server, enabling the AI assistant to perform the following operations:
|
|
11
12
|
|
|
@@ -17,44 +18,40 @@ Browser Console MCP is a tool that allows Cursor's Claude AI assistant to intera
|
|
|
17
18
|
- Click page elements
|
|
18
19
|
- Input text into form fields
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### Global Installation
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pnpm add -g browser-console-mcp
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Local Installation
|
|
21
|
+
### Usage
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
pnpm add browser-console-mcp
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Usage
|
|
35
|
-
|
|
36
|
-
### Start MCP Server
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
# If installed globally
|
|
40
|
-
browser-console-mcp start
|
|
41
|
-
|
|
42
|
-
# If installed locally
|
|
43
|
-
pnpx browser-console-mcp start
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Inject MCP Client in Browser
|
|
23
|
+
#### Inject MCP Client in Browser
|
|
47
24
|
|
|
48
25
|
Execute the following code in your browser console:
|
|
49
26
|
|
|
50
27
|
```javascript
|
|
51
|
-
// Inject MCP server
|
|
28
|
+
// ======== IMPORTANT: Inject MCP server ========
|
|
52
29
|
var s = document.createElement('script');
|
|
53
30
|
s.src = 'http://localhost:7898/browser-inject.js';
|
|
54
31
|
document.head.appendChild(s);
|
|
32
|
+
// ==============================================
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### MCP Configuration
|
|
36
|
+
|
|
37
|
+
Create a `.cursor/mcp.json` file in your home directory:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"browser-mcp": {
|
|
43
|
+
"command": "pnpx",
|
|
44
|
+
"enable": true,
|
|
45
|
+
"args": ["-y", "browser-console-mcp"],
|
|
46
|
+
"env": {
|
|
47
|
+
"PORT": "7898"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
55
52
|
```
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
#### Using in Cursor
|
|
58
55
|
|
|
59
56
|
In Cursor, your AI assistant can now use the following tools:
|
|
60
57
|
|
|
@@ -67,32 +64,13 @@ In Cursor, your AI assistant can now use the following tools:
|
|
|
67
64
|
- `mcp_browser-mcp_clickElement`: Click page elements
|
|
68
65
|
- `mcp_browser-mcp_inputText`: Input text into form fields
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# Install dependencies
|
|
74
|
-
pnpm install
|
|
75
|
-
|
|
76
|
-
# Build project
|
|
77
|
-
pnpm build:all
|
|
78
|
-
|
|
79
|
-
# Start development mode
|
|
80
|
-
pnpm dev
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## License
|
|
67
|
+
### License
|
|
84
68
|
|
|
85
69
|
MIT
|
|
86
|
-
</details>
|
|
87
70
|
|
|
88
|
-
|
|
89
|
-
<summary>中文</summary>
|
|
90
|
-
|
|
91
|
-
# Browser Console MCP
|
|
71
|
+
## 中文
|
|
92
72
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## 简介
|
|
73
|
+
### 简介
|
|
96
74
|
|
|
97
75
|
Browser Console MCP 是一个工具,允许 Cursor 的 Claude AI 助手通过 MCP(Model Context Protocol)协议与浏览器进行交互。它提供了一个浏览器客户端和一个 MCP 服务器,使 AI 助手能够执行以下操作:
|
|
98
76
|
|
|
@@ -104,44 +82,40 @@ Browser Console MCP 是一个工具,允许 Cursor 的 Claude AI 助手通过 M
|
|
|
104
82
|
- 点击页面元素
|
|
105
83
|
- 向输入框填入文本
|
|
106
84
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
### 全局安装
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
pnpm add -g browser-console-mcp
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### 本地安装
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
pnpm add browser-console-mcp
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## 使用方法
|
|
122
|
-
|
|
123
|
-
### 启动 MCP 服务器
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# 全局安装的情况
|
|
127
|
-
browser-console-mcp start
|
|
85
|
+
### 使用方法
|
|
128
86
|
|
|
129
|
-
|
|
130
|
-
pnpx browser-console-mcp start
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### 在浏览器中注入 MCP 客户端
|
|
87
|
+
#### 在浏览器中注入 MCP 客户端
|
|
134
88
|
|
|
135
89
|
在浏览器控制台中执行以下代码:
|
|
136
90
|
|
|
137
91
|
```javascript
|
|
138
|
-
// 注入MCP服务器
|
|
92
|
+
// ======== 重要: 注入MCP服务器 ========
|
|
139
93
|
var s = document.createElement('script');
|
|
140
94
|
s.src = 'http://localhost:7898/browser-inject.js';
|
|
141
95
|
document.head.appendChild(s);
|
|
96
|
+
// ====================================
|
|
142
97
|
```
|
|
143
98
|
|
|
144
|
-
|
|
99
|
+
#### MCP 配置
|
|
100
|
+
|
|
101
|
+
在您的主目录中创建 `.cursor/mcp.json` 文件:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"browser-mcp": {
|
|
107
|
+
"command": "pnpx",
|
|
108
|
+
"enable": true,
|
|
109
|
+
"args": ["-y", "browser-console-mcp"],
|
|
110
|
+
"env": {
|
|
111
|
+
"PORT": "7898"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### 在 Cursor 中使用
|
|
145
119
|
|
|
146
120
|
在 Cursor 中,你的 AI 助手现在可以使用以下工具:
|
|
147
121
|
|
|
@@ -154,32 +128,13 @@ document.head.appendChild(s);
|
|
|
154
128
|
- `mcp_browser-mcp_clickElement`: 点击页面元素
|
|
155
129
|
- `mcp_browser-mcp_inputText`: 向输入框填入文本
|
|
156
130
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
# 安装依赖
|
|
161
|
-
pnpm install
|
|
162
|
-
|
|
163
|
-
# 构建项目
|
|
164
|
-
pnpm build:all
|
|
165
|
-
|
|
166
|
-
# 启动开发模式
|
|
167
|
-
pnpm dev
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## 许可证
|
|
131
|
+
### 许可证
|
|
171
132
|
|
|
172
133
|
MIT
|
|
173
|
-
</details>
|
|
174
|
-
|
|
175
|
-
<details>
|
|
176
|
-
<summary>日本語</summary>
|
|
177
134
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
ブラウザコンソールのMCPクライアントとCursorのMCPサーバー。AIアシスタントにブラウザを制御させましょう!
|
|
135
|
+
## 日本語
|
|
181
136
|
|
|
182
|
-
|
|
137
|
+
### はじめに
|
|
183
138
|
|
|
184
139
|
Browser Console MCPは、CursorのClaude AIアシスタントがMCP(Model Context Protocol)プロトコルを通じてブラウザと対話できるようにするツールです。ブラウザクライアントとMCPサーバーを提供し、AIアシスタントが以下の操作を実行できるようにします:
|
|
185
140
|
|
|
@@ -191,44 +146,40 @@ Browser Console MCPは、CursorのClaude AIアシスタントがMCP(Model Cont
|
|
|
191
146
|
- ページ要素のクリック
|
|
192
147
|
- 入力フィールドへのテキスト入力
|
|
193
148
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
### グローバルインストール
|
|
149
|
+
### 使用方法
|
|
197
150
|
|
|
198
|
-
|
|
199
|
-
pnpm add -g browser-console-mcp
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### ローカルインストール
|
|
203
|
-
|
|
204
|
-
```bash
|
|
205
|
-
pnpm add browser-console-mcp
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
## 使用方法
|
|
209
|
-
|
|
210
|
-
### MCPサーバーの起動
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
# グローバルインストールの場合
|
|
214
|
-
browser-console-mcp start
|
|
215
|
-
|
|
216
|
-
# ローカルインストールの場合
|
|
217
|
-
pnpx browser-console-mcp start
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### ブラウザにMCPクライアントを注入
|
|
151
|
+
#### ブラウザにMCPクライアントを注入
|
|
221
152
|
|
|
222
153
|
ブラウザのコンソールで以下のコードを実行します:
|
|
223
154
|
|
|
224
155
|
```javascript
|
|
225
|
-
// MCPサーバーを注入
|
|
156
|
+
// ======== 重要: MCPサーバーを注入 ========
|
|
226
157
|
var s = document.createElement('script');
|
|
227
158
|
s.src = 'http://localhost:7898/browser-inject.js';
|
|
228
159
|
document.head.appendChild(s);
|
|
160
|
+
// ========================================
|
|
229
161
|
```
|
|
230
162
|
|
|
231
|
-
|
|
163
|
+
#### MCP設定
|
|
164
|
+
|
|
165
|
+
ホームディレクトリに `.cursor/mcp.json` ファイルを作成します:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"mcpServers": {
|
|
170
|
+
"browser-mcp": {
|
|
171
|
+
"command": "pnpx",
|
|
172
|
+
"enable": true,
|
|
173
|
+
"args": ["-y", "browser-console-mcp"],
|
|
174
|
+
"env": {
|
|
175
|
+
"PORT": "7898"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Cursorでの使用
|
|
232
183
|
|
|
233
184
|
Cursorでは、AIアシスタントが以下のツールを使用できるようになります:
|
|
234
185
|
|
|
@@ -241,32 +192,13 @@ Cursorでは、AIアシスタントが以下のツールを使用できるよう
|
|
|
241
192
|
- `mcp_browser-mcp_clickElement`: ページ要素をクリック
|
|
242
193
|
- `mcp_browser-mcp_inputText`: 入力フィールドにテキストを入力
|
|
243
194
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
# 依存関係のインストール
|
|
248
|
-
pnpm install
|
|
249
|
-
|
|
250
|
-
# プロジェクトのビルド
|
|
251
|
-
pnpm build:all
|
|
252
|
-
|
|
253
|
-
# 開発モードの起動
|
|
254
|
-
pnpm dev
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
## ライセンス
|
|
195
|
+
### ライセンス
|
|
258
196
|
|
|
259
197
|
MIT
|
|
260
|
-
</details>
|
|
261
198
|
|
|
262
|
-
|
|
263
|
-
<summary>한국어</summary>
|
|
199
|
+
## 한국어
|
|
264
200
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
브라우저 콘솔용 MCP 클라이언트와 Cursor용 MCP 서버. AI 어시스턴트가 브라우저를 제어할 수 있게 해보세요!
|
|
268
|
-
|
|
269
|
-
## 소개
|
|
201
|
+
### 소개
|
|
270
202
|
|
|
271
203
|
Browser Console MCP는 Cursor의 Claude AI 어시스턴트가 MCP(Model Context Protocol) 프로토콜을 통해 브라우저와 상호작용할 수 있게 해주는 도구입니다. 브라우저 클라이언트와 MCP 서버를 제공하여 AI 어시스턴트가 다음 작업을 수행할 수 있도록 합니다:
|
|
272
204
|
|
|
@@ -278,44 +210,40 @@ Browser Console MCP는 Cursor의 Claude AI 어시스턴트가 MCP(Model Context
|
|
|
278
210
|
- 페이지 요소 클릭하기
|
|
279
211
|
- 입력 필드에 텍스트 입력하기
|
|
280
212
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
### 전역 설치
|
|
284
|
-
|
|
285
|
-
```bash
|
|
286
|
-
pnpm add -g browser-console-mcp
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### 로컬 설치
|
|
290
|
-
|
|
291
|
-
```bash
|
|
292
|
-
pnpm add browser-console-mcp
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
## 사용 방법
|
|
296
|
-
|
|
297
|
-
### MCP 서버 시작하기
|
|
213
|
+
### 사용 방법
|
|
298
214
|
|
|
299
|
-
|
|
300
|
-
# 전역 설치한 경우
|
|
301
|
-
browser-console-mcp start
|
|
302
|
-
|
|
303
|
-
# 로컬 설치한 경우
|
|
304
|
-
pnpx browser-console-mcp start
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### 브라우저에 MCP 클라이언트 주입하기
|
|
215
|
+
#### 브라우저에 MCP 클라이언트 주입하기
|
|
308
216
|
|
|
309
217
|
브라우저 콘솔에서 다음 코드를 실행하세요:
|
|
310
218
|
|
|
311
219
|
```javascript
|
|
312
|
-
// MCP 서버 주입
|
|
220
|
+
// ======== 중요: MCP 서버 주입 ========
|
|
313
221
|
var s = document.createElement('script');
|
|
314
222
|
s.src = 'http://localhost:7898/browser-inject.js';
|
|
315
223
|
document.head.appendChild(s);
|
|
224
|
+
// ===================================
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### MCP 구성
|
|
228
|
+
|
|
229
|
+
홈 디렉토리에 `.cursor/mcp.json` 파일을 생성하세요:
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"mcpServers": {
|
|
234
|
+
"browser-mcp": {
|
|
235
|
+
"command": "pnpx",
|
|
236
|
+
"enable": true,
|
|
237
|
+
"args": ["-y", "browser-console-mcp"],
|
|
238
|
+
"env": {
|
|
239
|
+
"PORT": "7898"
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
316
244
|
```
|
|
317
245
|
|
|
318
|
-
|
|
246
|
+
#### Cursor에서 사용하기
|
|
319
247
|
|
|
320
248
|
Cursor에서 AI 어시스턴트는 이제 다음 도구들을 사용할 수 있습니다:
|
|
321
249
|
|
|
@@ -328,20 +256,6 @@ Cursor에서 AI 어시스턴트는 이제 다음 도구들을 사용할 수 있
|
|
|
328
256
|
- `mcp_browser-mcp_clickElement`: 페이지 요소 클릭하기
|
|
329
257
|
- `mcp_browser-mcp_inputText`: 입력 필드에 텍스트 입력하기
|
|
330
258
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
```bash
|
|
334
|
-
# 의존성 설치
|
|
335
|
-
pnpm install
|
|
336
|
-
|
|
337
|
-
# 프로젝트 빌드
|
|
338
|
-
pnpm build:all
|
|
339
|
-
|
|
340
|
-
# 개발 모드 시작
|
|
341
|
-
pnpm dev
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
## 라이선스
|
|
259
|
+
### 라이선스
|
|
345
260
|
|
|
346
261
|
MIT
|
|
347
|
-
</details>
|