Node.js调试服务器

一个提供Node.js调试功能并支持AI代理进程管理的MCP服务器。

  • by qckfx
  • JavaScript
  • 本地部署
  • 16 星标
  • 更新于
在 GitHub 查看 qckfx/node-debugger-mcp

使用说明

Node.js调试器MCP服务器

一个MCP服务器,为AI代理提供Node.js调试功能和进程管理。

特性

  • 流程管理:在启用调试的情况下启动/停止Node.js进程
  • 调试工具:设置断点、遍历代码、计算表达式
  • 检查员集成:连接到Node.js Inspector API
  • AI代理友好:专为长时间运行的调试会话而设计

安装

  1. 构建服务器:

    npm install
    npm run build
    
  2. 用于项目特定用途:The .mcp.json 文件已在此项目中配置

  3. 供用户广泛使用:添加到全局Claude代码配置:

    claude mcp add --scope user debugger-mcp node /absolute/path/to/debugger-mcp/build/index.js
    
  4. 供全球使用:复制 .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 -管理流程列表

示例用法

  1. 启动Node.js进程:

    Use the start_node_process tool with script: "example-app.js"
    
  2. 附加调试器:

    Use attach_debugger tool with the port returned from step 1
    
  3. 设置断点并调试:

    # 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