Skip to main content
Glama
qckfx

Node.js Debugger MCP Server

by qckfx

attach_debugger

Connect a debugger to an active Node.js process for debugging by specifying the debug port. This enables code inspection and troubleshooting of running applications.

Instructions

Attach debugger to a running Node.js process

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYesDebug port to connect to

Implementation Reference

  • Core handler function implementing the attach_debugger tool. Connects to Node.js debug port using Chrome DevTools Protocol (CDP), sets up event listeners for pause/resume/execution context, enables Debugger and Runtime domains, initializes debug session state, handles --inspect-brk waiting state, and returns success/error messages.
    private async attachDebugger(args: { port: number }) {
      try {
        // Close existing connection if any
        if (this.debugSession.client) {
          await this.debugSession.client.close();
        }
    
        // Connect to the Node.js inspector using Chrome DevTools Protocol
        const client = await CDP({ port: args.port });
        
        const { Debugger, Runtime } = client;
        
        // Set up event handlers first
        Debugger.paused((params: any) => {
          this.debugSession.callStack = params.callFrames;
          this.debugSession.isPaused = true;
        });
    
        Debugger.resumed(() => {
          this.debugSession.isPaused = false;
          this.debugSession.callStack = [];
        });
    
        Runtime.executionContextCreated((params: any) => {
          this.debugSession.currentExecutionContext = params.context.id;
        });
    
        // Enable debugging domains
        await Debugger.enable();
        await Runtime.enable();
    
        // Initialize session
        this.debugSession = {
          connected: true,
          port: args.port,
          client,
          callStack: [],
          variables: {},
          breakpoints: new Map(),
          isPaused: false,
          currentExecutionContext: undefined
        };
    
        // For --inspect-brk, the runtime is waiting for debugger
        // We need to handle this special case
        try {
          // First, let's try to pause to ensure we're in a debuggable state
          await Debugger.pause();
          // Small delay for pause event
          await new Promise(resolve => setTimeout(resolve, 100));
        } catch (error) {
          // Process might already be paused or not yet ready
        }
    
        // Now handle the waiting for debugger state
        try {
          // This will allow execution to continue from the initial --inspect-brk pause
          // But since we called pause() above, it should remain paused
          await Runtime.runIfWaitingForDebugger();
        } catch (error) {
          // If this fails, the process might not be waiting
        }
    
        // Small delay to allow all events to fire
        await new Promise(resolve => setTimeout(resolve, 200));
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully attached debugger to port ${args.port}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error attaching debugger: ${error}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:176-186 (registration)
    Tool registration in ListToolsRequestSchema response, defining the tool name, description, and input schema for the MCP protocol.
    {
      name: "attach_debugger",
      description: "Attach debugger to a running Node.js process",
      inputSchema: {
        type: "object",
        properties: {
          port: { type: "number", description: "Debug port to connect to" }
        },
        required: ["port"],
      },
    },
  • JSON schema defining the input parameters for the attach_debugger tool: requires a 'port' number.
    inputSchema: {
      type: "object",
      properties: {
        port: { type: "number", description: "Debug port to connect to" }
      },
      required: ["port"],
    },
  • src/index.ts:253-254 (registration)
    Dispatcher switch case in CallToolRequestSchema handler that routes calls to the attachDebugger method.
    case "attach_debugger":
      return await this.attachDebugger(args as { port: number });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe how it behaves: it doesn't mention whether this requires specific permissions, what happens after attachment (e.g., pauses execution, allows debugging), potential side effects, or error conditions. The description is minimal and lacks operational context.

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 with zero waste. It's front-loaded with the core action and target, making it easy to parse. Every word earns its place, and there's no redundant or verbose language.

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?

Given the complexity of debugging operations and the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'attach' entails (e.g., control flow, debugging capabilities), what the tool returns, or how it interacts with other debugger tools. For a tool with no structured behavioral data, this minimal description leaves significant gaps.

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 the single parameter 'port' documented as 'Debug port to connect to'. The description adds no additional parameter semantics beyond what the schema provides. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, though the description doesn't compensate or enhance parameter understanding.

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 action ('Attach debugger') and target ('to a running Node.js process'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'set_breakpoint' or 'step_debug' which are also debugger-related operations, so it doesn't fully distinguish itself within the tool family.

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 prerequisites (e.g., needing a running Node.js process), exclusions, or relationships to sibling tools like 'start_node_process' (to create a process) or 'list_processes' (to identify processes). Usage context is implied but not explicit.

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/qckfx/node-debugger-mcp'

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