mcp调试单元
MCP服务器,使编码代理能够调试Node.js 和 Python脚本,无需修改源代码。
发布于npm mcp-debug-unit (以前 nodejs-debug-mcp).旧版CLI别名仍可用于向后兼容性。
为什么要安装这个
您的编码代理(Claude、Cursor等)可以在不修改代码的情况下检查运行时值。而不是要求代理添加 console.log 语句,它可以调用 debug-script 查看执行过程中任何一行发生了什么。
对于调试单元测试和通过了解运行时实际存在的值来帮助代理编写测试特别有用。
运作原理
代理人指定:
- 要运行的Node.js命令
- 断点位置(文件和行)
- 要计算的表达式
该工具运行脚本,每次执行时暂停在该行,计算表达式,并在脚本完成时返回所有值。
参数
- 命令: 要运行的可调试命令。对于Node.js pass
--inspect-brk,对于Python运行debugpy随着--listen+--wait-for-client. - 断点:
{ file: string, line: number } - 表达式: 表达式用于计算何时命中断点。适用于两种运行时。
- 超时: 最大执行时间(毫秒)
- 包括堆叠: (可选)在结果中包含调用堆栈帧
- 运行时: (可选)
'node'(默认)或'python'
设置
克劳德代码
claude mcp add --scope user --transport stdio mcp-debug-unit -- npx -y mcp-debug-unitCodex CLI
codex mcp add mcp-debug-unit -- npx -y mcp-debug-unit光标
添加到MCP设置配置文件中:
{
"mcpServers": {
"mcp-debug-unit": {
"command": "npx",
"args": ["-y", "mcp-debug-unit"]
}
}
}发展
npx tsc # Build
node --test test/e2e.test.js # TestPython运行时要求
- 安装
debugpy(例如。python3 -m pip install debugpy) - MCP服务器引导程序
debugpy自动进入您的用户缓存(例如。~/.cache/mcp-debug-unit/debugpy/或%LOCALAPPDATA%\mcp-debug-unit\cache\debugpy\)如果命令中引用的解释器无法导入它。请通过以下方式覆盖存储位置MCP_DEBUG_UNIT_DEBUGPY_DIR(或遗产NODEJS_DEBUG_MCP_DEBUGPY_DIR). - 通过以下方式启动脚本
python3 -m debugpy --listen 127.0.0.1:5678 --wait-for-client ./script.py - 呼叫
debug-script随着runtime: "python"同样的listen主机:端口command - 使用绝对或相对路径
breakpoint.file(它们将自动解决)
看 SPECIFICATION.md 了解实施细节。
发布
要将新版本发布到npm:
# Patch version (0.1.2 → 0.1.3)
npm version patch && git push --follow-tags
# Minor version (0.1.2 → 0.2.0)
npm version minor && git push --follow-tags
# Major version (0.1.2 → 1.0.0)
npm version major && git push --follow-tags这会自动:
- 更新package.json版本
- 创建git commit和标签
- 推送到GitHub
- 触发发布工作流
许可证
麻省理工学院
