Skip to main content
Glama
workbackai
by workbackai

set_breakpoint

Set breakpoints in specific files and lines within a NodeJS server using the MCP NodeJS Debugger. Enables precise debugging by pausing execution to inspect variables and step through code.

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 handler function that implements the set_breakpoint tool logic. It converts the file path to a URL format, sends Debugger.setBreakpointByUrl command to the inspector, stores the breakpoint ID, 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}` }] }; } }
  • Input schema using Zod for validating the file path (string) and line number (number) parameters.
    { file: z.string().describe("File path where to set breakpoint"), line: z.number().describe("Line number for breakpoint") },
  • Registration of the set_breakpoint tool with the MCP server using server.tool(), including 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 }) => { 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}` }] }; } } );

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