Skip to main content
Glama
qckfx

Node.js Debugger MCP Server

by qckfx

set_breakpoint

Pause Node.js code execution at specific lines to inspect variables and debug issues by setting conditional or unconditional breakpoints in files.

Instructions

Set a breakpoint in the debugged process. Use full file:// URLs for reliable breakpoint hits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesFile URL or path (use file:///absolute/path/to/file.js for best results)
lineYesLine number (1-based)
conditionNoOptional condition for the breakpoint

Implementation Reference

  • The handler function for the 'set_breakpoint' tool. It checks for an active debug session, then uses the Chrome DevTools Protocol (CDP) Debugger.setBreakpointByUrl to set a breakpoint at the specified file URL and line number (converting to 0-based), optionally with a condition. Stores the breakpoint ID and returns success or error.
    private async setBreakpoint(args: { file: string; line: number; condition?: string }) {
      if (!this.debugSession.connected || !this.debugSession.client) {
        return {
          content: [
            {
              type: "text",
              text: "No active debug session. Please attach debugger first.",
            },
          ],
          isError: true,
        };
      }
    
      try {
        const { Debugger } = this.debugSession.client;
        
        // Use CDP to set the breakpoint
        const result = await Debugger.setBreakpointByUrl({
          lineNumber: args.line - 1, // CDP uses 0-based line numbers
          url: args.file,
          condition: args.condition
        });
    
        if (result.breakpointId) {
          // Store the breakpoint mapping
          const breakpointKey = `${args.file}:${args.line}`;
          this.debugSession.breakpoints!.set(breakpointKey, result.breakpointId);
    
          return {
            content: [
              {
                type: "text",
                text: `Set breakpoint at ${args.file}:${args.line}${args.condition ? ` (condition: ${args.condition})` : ""} - ID: ${result.breakpointId}`,
              },
            ],
          };
        } else {
          return {
            content: [
              {
                type: "text", 
                text: `Failed to set breakpoint at ${args.file}:${args.line}`,
              },
            ],
            isError: true,
          };
        }
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error setting breakpoint: ${error}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Tool registration including name, description, and input schema definition for 'set_breakpoint'.
    {
      name: "set_breakpoint",
      description: "Set a breakpoint in the debugged process. Use full file:// URLs for reliable breakpoint hits.",
      inputSchema: {
        type: "object",
        properties: {
          file: { 
            type: "string", 
            description: "File URL or path (use file:///absolute/path/to/file.js for best results)" 
          },
          line: { type: "number", description: "Line number (1-based)" },
          condition: { type: "string", description: "Optional condition for the breakpoint" }
        },
        required: ["file", "line"],
      },
    },
  • src/index.ts:256-257 (registration)
    Registration of the tool handler dispatch in the CallToolRequest switch statement.
    case "set_breakpoint":
      return await this.setBreakpoint(args as { file: string; line: number; condition?: string });

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