MCPcopy
hub / github.com/AgentDeskAI/browser-tools-mcp / sendToBrowserConnector

Function sendToBrowserConnector

chrome-extension/devtools.js:242–351  ·  view source on GitHub ↗
(logData)

Source from the content-addressed store, hash-verified

240
241// Helper to send logs to browser-connector
242async function sendToBrowserConnector(logData) {
243 if (!logData) {
244 console.error("No log data provided to sendToBrowserConnector");
245 return;
246 }
247
248 // First, ensure we're connecting to the right server
249 if (!(await validateServerIdentity())) {
250 console.error(
251 "Cannot send logs: Not connected to a valid browser tools server"
252 );
253 return;
254 }
255
256 console.log("Sending log data to browser connector:", {
257 type: logData.type,
258 timestamp: logData.timestamp,
259 });
260
261 // Process any string fields that might contain JSON
262 const processedData = { ...logData };
263
264 if (logData.type === "network-request") {
265 console.log("Processing network request");
266 if (processedData.requestBody) {
267 console.log(
268 "Request body size before:",
269 processedData.requestBody.length
270 );
271 processedData.requestBody = processJsonString(
272 processedData.requestBody,
273 settings.stringSizeLimit
274 );
275 console.log("Request body size after:", processedData.requestBody.length);
276 }
277 if (processedData.responseBody) {
278 console.log(
279 "Response body size before:",
280 processedData.responseBody.length
281 );
282 processedData.responseBody = processJsonString(
283 processedData.responseBody,
284 settings.stringSizeLimit
285 );
286 console.log(
287 "Response body size after:",
288 processedData.responseBody.length
289 );
290 }
291 } else if (
292 logData.type === "console-log" ||
293 logData.type === "console-error"
294 ) {
295 console.log("Processing console message");
296 if (processedData.message) {
297 console.log("Message size before:", processedData.message.length);
298 processedData.message = processJsonString(
299 processedData.message,

Callers 3

devtools.jsFile · 0.85
consoleMessageListenerFunction · 0.85
captureAndSendElementFunction · 0.85

Calls 2

validateServerIdentityFunction · 0.70
processJsonStringFunction · 0.70

Tested by

no test coverage detected