Skip to main content
Glama
workbackai

MCP NodeJS Debugger

by workbackai

get_console_output

Retrieve recent console logs from a debugged Node.js process to monitor output and identify issues during debugging sessions.

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 slices the most recent console outputs from inspector.consoleOutput based on the limit, formats them with timestamps and types, and returns them as text content.
    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 schema defining the optional 'limit' input parameter for the number of recent console entries to retrieve.
    {
      limit: z.number().optional().describe("Maximum number of console entries to return. Defaults to 20")
    },
  • Registration of the 'get_console_output' tool using server.tool(), including name, description, 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}`
            }]
          };
        }
      }
    );
  • Part of Inspector.handleEvent method that captures 'Runtime.consoleAPICalled' events, processes arguments into a message string, and stores them in this.consoleOutput array (global as inspector.consoleOutput), which is used by the tool.
    case 'Runtime.consoleAPICalled':
    	// Handle console logs from the debugged program
    	const args = event.params.args.map(arg => {
    		if (arg.type === 'string') return arg.value;
    		if (arg.type === 'number') return arg.value;
    		if (arg.type === 'boolean') return arg.value;
    		if (arg.type === 'object') {
    			if (arg.value) {
    				return JSON.stringify(arg.value, null, 2);
    			} else if (arg.objectId) {
    				// We'll try to get properties later as we can't do async here
    				return arg.description || `[${arg.subtype || arg.type}]`;
    			} else {
    				return arg.description || `[${arg.subtype || arg.type}]`;
    			}
    		}
    		return JSON.stringify(arg);
    	}).join(' ');
    	
    	// Store console logs to make them available to the MCP tools
    	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();
    	}
    	
    	break;
  • Initialization of the consoleOutput array on the inspector instance, providing the storage for captured console messages.
    // Initialize console output storage
    inspector.consoleOutput = [];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral context. It mentions 'most recent' output but doesn't specify format, whether output is streamed or batched, if there are rate limits, or what happens when no debugged process exists. The description doesn't contradict annotations since none exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a simple tool with one optional parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a debugging tool with no annotations and no output schema, the description is insufficient. It doesn't explain what format the console output returns (text, structured data), whether it includes timestamps, how 'most recent' is determined, or what happens when the debugged process isn't available.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with a single documented parameter ('limit'), so the baseline is 3. The description adds no parameter-specific information beyond what the schema already provides about returning console output.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Gets') and resource ('most recent console output from the debugged process'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'evaluate' or 'inspect_variables', but the focus on console output provides reasonable distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when console output is available, whether the process must be paused or running, or how this differs from other debugging tools like 'inspect_variables' or 'evaluate'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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