Skip to main content
Glama
workbackai
by workbackai

get_console_output

Retrieve the latest console output from a NodeJS debugged process to monitor and analyze application behavior, with customizable entry limits.

Instructions

Gets the most recent console output from the debugged process

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of console entries to return. Defaults to 20

Implementation Reference

  • The handler function for the 'get_console_output' tool. It retrieves the most recent console output entries from the inspector.consoleOutput array (up to the specified limit), formats them with timestamps and types, and returns them as MCP text content. Handles empty output and errors gracefully.
    async ({ limit = 20 }) => { try { if (!inspector.consoleOutput || inspector.consoleOutput.length === 0) { return { content: [{ type: "text", text: "No console output captured yet" }] }; } // Get the most recent console output entries const recentOutput = inspector.consoleOutput.slice(-limit); const formattedOutput = recentOutput.map(output => { const timestamp = new Date(output.timestamp).toISOString(); return `[${timestamp}] [${output.type}] ${output.message}`; }).join('\n'); return { content: [{ type: "text", text: `Console output (most recent ${recentOutput.length} entries):\n\n${formattedOutput}` }] }; } catch (err) { return { content: [{ type: "text", text: `Error getting console output: ${err.message}` }] }; } }
  • The registration of the 'get_console_output' tool using McpServer.tool(), specifying the name, description, input schema, and handler function.
    server.tool( "get_console_output", "Gets the most recent console output from the debugged process", { limit: z.number().optional().describe("Maximum number of console entries to return. Defaults to 20") }, async ({ limit = 20 }) => { try { if (!inspector.consoleOutput || inspector.consoleOutput.length === 0) { return { content: [{ type: "text", text: "No console output captured yet" }] }; } // Get the most recent console output entries const recentOutput = inspector.consoleOutput.slice(-limit); const formattedOutput = recentOutput.map(output => { const timestamp = new Date(output.timestamp).toISOString(); return `[${timestamp}] [${output.type}] ${output.message}`; }).join('\n'); return { content: [{ type: "text", text: `Console output (most recent ${recentOutput.length} entries):\n\n${formattedOutput}` }] }; } catch (err) { return { content: [{ type: "text", text: `Error getting console output: ${err.message}` }] }; } } );
  • Zod input schema for the tool, defining an optional 'limit' parameter to control the number of recent console entries returned.
    { limit: z.number().optional().describe("Maximum number of console entries to return. Defaults to 20") },
  • Helper code in Inspector.handleEvent for 'Runtime.consoleAPICalled' that captures console logs, formats them, stores in this.consoleOutput array (limited to 100 entries), which is used by the get_console_output tool.
    if (!this.consoleOutput) { this.consoleOutput = []; } this.consoleOutput.push({ type: event.params.type, message: args, timestamp: Date.now(), raw: event.params.args }); // Keep only the last 100 console messages to avoid memory issues if (this.consoleOutput.length > 100) { this.consoleOutput.shift(); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/workbackai/mcp-nodejs-debugger'

If you have feedback or need assistance with the MCP directory API, please join our Discord server