browser-ipc-cdp 1.8.1 → 1.8.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/lib/mcp.js +58 -2
- package/package.json +1 -1
package/lib/mcp.js
CHANGED
|
@@ -46,6 +46,53 @@ function getWslHostIp() {
|
|
|
46
46
|
return '127.0.0.1';
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
function updateClaudeUserConfig(wrapperPath) {
|
|
50
|
+
// Registra el MCP "brave" en scope user (~/.claude.json top-level mcpServers)
|
|
51
|
+
// para que aparezca en /mcp desde cualquier directorio, sin depender del cwd.
|
|
52
|
+
const braveEntry = {
|
|
53
|
+
type: 'stdio',
|
|
54
|
+
command: 'node',
|
|
55
|
+
args: [wrapperPath],
|
|
56
|
+
env: {},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const candidates = new Set();
|
|
60
|
+
if (process.env.HOME) candidates.add(path.join(process.env.HOME, '.claude.json'));
|
|
61
|
+
if (process.env.USERPROFILE) candidates.add(path.join(process.env.USERPROFILE, '.claude.json'));
|
|
62
|
+
|
|
63
|
+
// Desde WSL: buscar tambien en /mnt/c/Users/*/.claude.json
|
|
64
|
+
try {
|
|
65
|
+
if (fs.existsSync('/mnt/c/Users')) {
|
|
66
|
+
for (const user of fs.readdirSync('/mnt/c/Users')) {
|
|
67
|
+
const candidate = `/mnt/c/Users/${user}/.claude.json`;
|
|
68
|
+
if (fs.existsSync(candidate)) candidates.add(candidate);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (e) {}
|
|
72
|
+
|
|
73
|
+
let updated = 0;
|
|
74
|
+
for (const p of candidates) {
|
|
75
|
+
try {
|
|
76
|
+
// Solo modificar si Claude Code ya creo el archivo.
|
|
77
|
+
// No bootstrap-eamos .claude.json para no chocar con first-run setup.
|
|
78
|
+
if (!fs.existsSync(p)) continue;
|
|
79
|
+
const data = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
80
|
+
if (!data.mcpServers) data.mcpServers = {};
|
|
81
|
+
data.mcpServers.brave = braveEntry;
|
|
82
|
+
|
|
83
|
+
// Write atomico: tmp + rename (evita corromper si Claude Code lee a medias)
|
|
84
|
+
const tmp = p + '.tmp';
|
|
85
|
+
fs.writeFileSync(tmp, JSON.stringify(data, null, 2));
|
|
86
|
+
fs.renameSync(tmp, p);
|
|
87
|
+
updated++;
|
|
88
|
+
log(` -> ${p} (user scope)`);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
warn(`No se pudo actualizar ${p}: ${e.message}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return updated;
|
|
94
|
+
}
|
|
95
|
+
|
|
49
96
|
function updateMcpJson(port, wslIp) {
|
|
50
97
|
// Estrategia: apuntar al wrapper Node dinamico.
|
|
51
98
|
// El wrapper lee cdp_info.json en cada invocacion -> puerto siempre fresco.
|
|
@@ -115,7 +162,16 @@ function updateMcpJson(port, wslIp) {
|
|
|
115
162
|
}
|
|
116
163
|
|
|
117
164
|
success(`.mcp.json actualizado (${updated} archivos): brave -> ${wslIp}:${port}`);
|
|
118
|
-
|
|
165
|
+
|
|
166
|
+
// Tambien registrar en scope user (~/.claude.json) para que /mcp lo vea desde cualquier cwd
|
|
167
|
+
const userUpdated = updateClaudeUserConfig(wrapperPath);
|
|
168
|
+
if (userUpdated > 0) {
|
|
169
|
+
success(`.claude.json actualizado (${userUpdated} archivos, scope user): brave registrado`);
|
|
170
|
+
} else {
|
|
171
|
+
warn('No se encontro .claude.json para registrar en scope user. Reinicia Claude Code una vez para que se cree, luego re-ejecuta este comando.');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return (updated + userUpdated) > 0;
|
|
119
175
|
}
|
|
120
176
|
|
|
121
|
-
module.exports = { getWslHostIp, updateMcpJson };
|
|
177
|
+
module.exports = { getWslHostIp, updateMcpJson, updateClaudeUserConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-ipc-cdp",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Control remoto de navegadores Chromium (Brave, Chrome, Edge) via IPC + CDP dinamico. Un comando para conectar Claude Code a tu navegador real.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"browser-ipc-cdp": "bin/cli.js"
|