Skip to main content
Glama
workbackai

MCP NodeJS Debugger

by workbackai

set_breakpoint

Set a breakpoint at a specific line in a Node.js file to pause execution for debugging.

Instructions

Sets a breakpoint at specified line and file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesFile path where to set breakpoint
lineYesLine number for breakpoint

Implementation Reference

  • The main handler function for the set_breakpoint tool. Converts the file path to a file URL, escapes it for regex, and sends a Debugger.setBreakpointByUrl command to the inspector with 0-based line number. Stores the breakpoint ID locally and returns success or error message.
    async ({ file, line }) => {
      try {
        // Ensure debugger is enabled
        if (!inspector.debuggerEnabled) {
          await inspector.enableDebugger();
        }
        
        // Convert file path to a URL-like format that the debugger can understand
        // For local files, typically file:///path/to/file.js
        let fileUrl = file;
        if (!file.startsWith('file://') && !file.startsWith('http://') && !file.startsWith('https://')) {
          fileUrl = `file://${file.startsWith('/') ? '' : '/'}${file}`;
        }
        
        const response = await inspector.send('Debugger.setBreakpointByUrl', {
          lineNumber: line - 1, // Chrome DevTools Protocol uses 0-based line numbers
          urlRegex: fileUrl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), // Escape special regex characters
          columnNumber: 0
        });
        
        // Store the breakpoint for future reference
        inspector.breakpoints.set(response.breakpointId, { file, line, id: response.breakpointId });
        
        return {
          content: [{
            type: "text",
            text: `Breakpoint set successfully. ID: ${response.breakpointId}`
          }]
        };
      } catch (err) {
        return {
          content: [{
            type: "text",
            text: `Error setting breakpoint: ${err.message}`
          }]
        };
      }
    }
  • Zod schema defining the input parameters: file (string) and line (number).
      file: z.string().describe("File path where to set breakpoint"),
      line: z.number().describe("Line number for breakpoint")
    },
  • Registers the set_breakpoint tool with the MCP server using server.tool(), providing name, description, input schema, and handler function.
    server.tool(
      "set_breakpoint",
      "Sets a breakpoint at specified line and file",
      {
        file: z.string().describe("File path where to set breakpoint"),
        line: z.number().describe("Line number for breakpoint")
      },
      async ({ file, line }) => {

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