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
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | File path where to set breakpoint | |
| line | Yes | Line number for breakpoint |
Implementation Reference
- src/mcp-server.js:482-519 (handler)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}` }] }; } }
- src/mcp-server.js:479-481 (schema)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") },
- src/mcp-server.js:475-482 (registration)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 }) => {