Node.js调试器MCP服务器
一个MCP服务器,为AI代理提供Node.js调试功能和进程管理。
特性
- 流程管理:在启用调试的情况下启动/停止Node.js进程
- 调试工具:设置断点、遍历代码、计算表达式
- 检查员集成:连接到Node.js Inspector API
- AI代理友好:专为长时间运行的调试会话而设计
安装
- 构建服务器:
npm install
npm run build- 用于项目特定用途:The
.mcp.json文件已在此项目中配置
- 供用户广泛使用:添加到全局Claude代码配置:
claude mcp add --scope user debugger-mcp node /absolute/path/to/debugger-mcp/build/index.js- 供全球使用:复制
.mcp.json添加到您的项目或全局配置
使用Claude代码
配置后,您将可以在Claude Code中访问这些工具:
流程管理
start_node_process-启动Node.js脚本并进行调试kill_process-通过PID终止进程list_processes-显示所有管理流程
调试
attach_debugger-连接到调试端口set_breakpoint-使用可选条件设置断点
- 重要:使用完整 file:// 可靠断点点击的URL - 例子: file:///Users/you/project/script.js
step_debug-单步执行代码(下一步/步骤/继续/退出)pause_execution-手动暂停正在运行的进程evaluate_expression-在调试上下文中计算表达式
资源
debug://session-当前调试会话状态debug://processes-管理流程列表
示例用法
- 启动Node.js进程:
Use the start_node_process tool with script: "example-app.js"- 附加调试器:
Use attach_debugger tool with the port returned from step 1- 设置断点并调试:
# Set a breakpoint using full file URL
Use set_breakpoint tool with:
- file: "file:///absolute/path/to/example-app.js"
- line: 5
# Control execution
Use step_debug tool with action: "continue"主要特点
- 启动时自动暂停:用途
--inspect-brk在第一行暂停的标志 - 完整的Chrome DevTools协议:真正的调试,而不是模拟
- 可靠的断点:使用
file://一致断点点击的URL - 流程管理:跟踪和管理多个调试会话
测试
使用附带的示例应用程序进行测试:
node --inspect=9229 example-app.js然后使用MCP工具进行调试!
调试MCP服务器
npm run inspector