Node.js Debugger MCP是一个MCP服务器,它借助Chrome DevTools协议,为Node.js应用程序提供全面的调试功能。该服务器使AI助手能够对Node.js应用程序进行调试,可全面使用断点设置、单步执行、变量检查、调用栈分析、表达式求值以及源映射等功能。
此MCP服务器在需要AI协助调试Node.js应用程序时十分有用。它以编程方式提供了在Chrome DevTools或VS Code中能找到的所有调试功能,使AI助手可以帮助你设置断点、检查变量、逐行执行代码以及分析运行时行为。
this预览,并深入查看对象属性npm install devtools-debugger-mcp
将服务器添加到你的MCP设置配置中:
{
"devtools-debugger-mcp": {
"command": "node",
"args": ["path/to/devtools-debugger-mcp/dist/index.js"]
}
}
或者,如果是全局安装,可以使用CLI二进制文件:
{
"devtools-debugger-mcp": {
"command": "devtools-debugger-mcp"
}
}
该MCP服务器可以通过使用内置检查器(--inspect-brk=0)启动脚本并使用Chrome DevTools协议(CDP)来调试Node.js程序。
start_node_debug会启动node --inspect-brk=0 your-script.js,等待检查器WebSocket连接,进行连接,并返回初始暂停(第一行),同时附带pauseId和顶级调用帧。{ "tool": "start_node_debug", "params": { "scriptPath": "/absolute/path/to/app.js" } }
{ "tool": "set_breakpoint", "params": { "filePath": "/absolute/path/to/app.js", "line": 42 } }
{ "tool": "resume_execution", "params": { "includeConsole": true, "includeStack": true } }
{ "tool": "inspect_scopes", "params": { "maxProps": 15 } }
{ "tool": "evaluate_expression", "params": { "expr": "user.name" } }
{ "tool": "step_over" }
{ "tool": "step_into" }
{ "tool": "step_out" }
{ "tool": "stop_debug_session" }
start_node_debug({ scriptPath, format? }) — 使用检查器启动Node并返回初始暂停。set_breakpoint({ filePath, line }) — 通过文件路径设置断点(基于1的行号)。set_breakpoint_condition({ filePath?, urlRegex?, line, column?, condition, format? }) — 条件断点或通过URL正则表达式设置断点。add_logpoint({ filePath?, urlRegex?, line, column?, message, format? }) — 通过条件断点添加日志点,该日志点会记录日志并返回false。set_exception_breakpoints({ state }) — none | uncaught | all。blackbox_scripts({ patterns }) — 忽略匹配脚本URL的帧。list_scripts() / get_script_source({ scriptId? | url? }) — 发现并获取脚本源。continue_to_location({ filePath, line, column? }) — 运行到特定的源位置。restart_frame({ frameIndex, pauseId?, format? }) — 重新运行所选帧。resume_execution({ includeScopes?, includeStack?, includeConsole?, format? }) — 继续执行到下一个暂停点或退出。step_over|step_into|step_out({ includeScopes?, includeStack?, includeConsole?, format? }) — 单步执行,结果中可选包含上下文信息。evaluate_expression({ expr, pauseId?, frameIndex?, returnByValue?, format? }) — 在暂停帧中计算表达式;默认为顶级帧。inspect_scopes({ maxProps?, pauseId?, frameIndex?, includeThisPreview?, format? }) — 查看局部/闭包作用域和this摘要。get_object_properties({ objectId, maxProps?, format? }) — 深入查看对象预览。list_call_stack({ depth?, pauseId?, includeThis?, format? }) — 顶级N帧摘要。get_pause_info({ pauseId?, format? }) — 暂停原因/位置摘要。read_console({ format? }) — 自上次单步执行/继续执行以来的控制台消息。stop_debug_session() — 终止进程并断开连接。file:// URL以与CDP兼容。line是基于1的;CDP内部是基于0的。includeConsole或read_console获取。set_output_format({ format: 'text' | 'json' | 'both' })设置默认响应格式。此MCP服务器提供以下Node.js调试工具。所有工具都支持可选的format参数('text'或'json')来控制响应格式。
start_node_debug - 启动启用调试的Node.js脚本stop_debug_session - 终止调试会话并清理set_breakpoint - 在特定文件和行设置断点set_breakpoint_condition - 设置条件断点或通过URL正则表达式设置断点add_logpoint - 添加一个在命中时记录消息的日志点set_exception_breakpoints - 配置在异常时暂停的行为resume_execution - 继续执行到下一个断点或执行完成step_over - 单步跳过当前行step_into - 单步进入函数调用step_out - 单步跳出当前函数continue_to_location - 运行到特定位置restart_frame - 从特定调用帧重新开始执行inspect_scopes - 检查局部变量、闭包和this上下文evaluate_expression - 在当前上下文中计算JavaScript表达式get_object_properties - 深入查看对象属性list_call_stack - 查看当前调用栈get_pause_info - 获取当前暂停状态的信息list_scripts - 列出所有已加载的脚本get_script_source - 获取脚本的源代码blackbox_scripts - 配置在调试期间跳过的脚本read_console - 读取调试期间捕获的控制台输出有关详细的使用示例和参数描述,请参阅上面的“Node.js调试”部分。
MIT