get_console_logs
Retrieve browser console logs for debugging web applications. Filter logs by type (log, error, warning, info) and optionally clear logs after retrieval to maintain clean debugging sessions.
Instructions
Recupera todos os logs do console capturados desde a última navegação
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No | Limpar logs após recuperação | |
| filterType | No | Filtrar por tipo de log | all |
Input Schema (JSON Schema)
{
"properties": {
"clear": {
"default": false,
"description": "Limpar logs após recuperação",
"type": "boolean"
},
"filterType": {
"default": "all",
"description": "Filtrar por tipo de log",
"enum": [
"all",
"log",
"error",
"warning",
"info"
],
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/browserTools.ts:266-292 (handler)The main handler function that implements the get_console_logs tool logic. It retrieves console logs from browserState, applies optional filtering by type, optionally clears the logs, and returns a JSON-formatted response.export async function handleGetConsoleLogs(args: unknown): Promise<ToolResponse> { const typedArgs = args as unknown as GetConsoleLogsArgs; const { filterType = 'all', clear = false } = typedArgs; let logs = browserState.consoleLogs; if (filterType !== 'all') { logs = logs.filter((log) => log.type === filterType); } const result = { count: logs.length, logs: logs, }; if (clear) { clearConsoleLogs(); } return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/types.ts:55-58 (schema)TypeScript interface defining the input parameters for the get_console_logs tool.export interface GetConsoleLogsArgs { filterType?: 'all' | 'log' | 'error' | 'warning' | 'info'; clear?: boolean; }
- src/tools.ts:107-125 (schema)MCP tool definition including the name, description, and inputSchema used for tool listing and validation.name: 'get_console_logs', description: 'Recupera todos os logs do console capturados desde a última navegação', inputSchema: { type: 'object', properties: { filterType: { type: 'string', enum: ['all', 'log', 'error', 'warning', 'info'], description: 'Filtrar por tipo de log', default: 'all', }, clear: { type: 'boolean', description: 'Limpar logs após recuperação', default: false, }, }, }, },
- src/index.ts:87-88 (registration)Dispatch case in the main tool execution handler that routes calls to the get_console_logs handler function.case 'get_console_logs': return await handleGetConsoleLogs(args);
- src/types.ts:3-8 (helper)Type definition for individual console log entries used by the handler.export interface ConsoleLog { type: string; text: string; stack?: string; timestamp: string; }