Fix browser-info timeout y clipboard en Windows

- Agregar case 'getClientInfo' faltante en websocket-server switch
- Clipboard: usar execSync input en vez de embeber token en shell string
This commit is contained in:
2026-02-13 01:13:59 -06:00
parent ba1f00b2a0
commit 6f3479b3b5
4 changed files with 40 additions and 7 deletions

View File

@@ -25058,10 +25058,10 @@ mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === "_webmcp_get-token") { if (request.params.name === "_webmcp_get-token") {
const token = await generateNewRegistrationToken(); const token = await generateNewRegistrationToken();
try { try {
execSync(`printf '%s' '${token}' | clip.exe`, { stdio: "ignore" }); execSync("clip.exe", { input: token, stdio: ["pipe", "ignore", "ignore"] });
} catch (e) { } catch (e) {
try { try {
execSync(`printf '%s' '${token}' | xclip -selection clipboard`, { stdio: "ignore" }); execSync("xclip -selection clipboard", { input: token, stdio: ["pipe", "ignore", "ignore"] });
} catch (e2) { } catch (e2) {
} }
} }
@@ -25735,6 +25735,9 @@ wss.on("connection", (ws, req) => {
case "clientInfoResponse": case "clientInfoResponse":
handleToolResponse(data); handleToolResponse(data);
break; break;
case "getClientInfo":
handleGetClientInfo(ws, clientChannel, data);
break;
case "clearRegistry": case "clearRegistry":
handleClearRegistry(ws, data); handleClearRegistry(ws, data);
break; break;
@@ -26094,6 +26097,32 @@ function handleClientInfo(ws, data) {
clientMetadata.set(ws, { userAgent, url: url2, hostname: hostname3, language, screenWidth, screenHeight, timestamp }); clientMetadata.set(ws, { userAgent, url: url2, hostname: hostname3, language, screenWidth, screenHeight, timestamp });
console.error(`Client info stored for ${hostname3}: ${url2}`); console.error(`Client info stored for ${hostname3}: ${url2}`);
} }
function handleGetClientInfo(ws, callerChannel, data) {
const { id } = data;
const clients = [];
for (const [channelPath, channelClients] of Object.entries(channels)) {
if (channelPath === MCP_PATH2 || channelPath === REGISTER_PATH) continue;
for (const clientWs of channelClients) {
const meta3 = clientMetadata.get(clientWs) || {};
clients.push({
channel: channelPath,
userAgent: meta3.userAgent || "unknown",
url: meta3.url || "unknown",
hostname: meta3.hostname || "unknown",
language: meta3.language || "unknown",
screenWidth: meta3.screenWidth || 0,
screenHeight: meta3.screenHeight || 0,
connectedSince: meta3.timestamp || 0
});
}
}
const text = clients.length > 0 ? JSON.stringify(clients, null, 2) : "No hay navegadores conectados";
ws.send(JSON.stringify({
id,
type: "toolResponse",
result: { content: [{ type: "text", text }] }
}));
}
function handleClearRegistry(ws, data) { function handleClearRegistry(ws, data) {
const { id } = data; const { id } = data;
let toolCount = Object.keys(toolsRegistry).length; let toolCount = Object.keys(toolsRegistry).length;

File diff suppressed because one or more lines are too long

View File

@@ -251,10 +251,10 @@ mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
// Copiar token al portapapeles del sistema // Copiar token al portapapeles del sistema
try { try {
execSync(`printf '%s' '${token}' | clip.exe`, { stdio: 'ignore' }); execSync('clip.exe', { input: token, stdio: ['pipe', 'ignore', 'ignore'] });
} catch (e) { } catch (e) {
try { try {
execSync(`printf '%s' '${token}' | xclip -selection clipboard`, { stdio: 'ignore' }); execSync('xclip -selection clipboard', { input: token, stdio: ['pipe', 'ignore', 'ignore'] });
} catch (e2) { } catch (e2) {
// No hay clipboard disponible // No hay clipboard disponible
} }

View File

@@ -367,6 +367,10 @@ wss.on('connection', (ws, req) => {
handleToolResponse(data); handleToolResponse(data);
break; break;
case 'getClientInfo':
handleGetClientInfo(ws, clientChannel, data);
break;
case 'clearRegistry': case 'clearRegistry':
handleClearRegistry(ws, data); handleClearRegistry(ws, data);
break; break;