dap-mcp
dap-mcp
dap-mcp是模型上下文协议 (MCP)的实现,专为管理调试适配器协议 (DAP) 会话而定制。MCP 提供了一个标准化框架来优化和扩展大型语言模型的上下文窗口,在本项目中,它用于增强和简化调试工作流程。
特征
**调试适配器协议集成:**使用标准化协议与调试器交互。
**MCP 框架:**利用 MCP 优化上下文并增强调试工作流程。
**丰富的调试工具:**设置、列出和删除断点;控制执行(继续、步入/步出/下一步);评估表达式;更改堆栈框架;以及查看源代码。
**灵活的配置:**通过 JSON 配置文件自定义调试器设置、源目录和其他参数。
Related MCP server: Debug-MCP
安装
先决条件
Python 3.10 或更高版本
uv (可选,用于运行服务器)
安装并运行服务器
安装dap-mcp及其依赖项:
pip install dap-mcp
python -m dap_mcp --config config.json
# Or, if you have uv installed
uvx dap-mcp@latest --config config.json配置
该项目使用 JSON 配置文件(例如.config.json )来指定调试器设置和源码目录。以下是示例配置:
{
"type": "debugpy",
"debuggerPath": "/path/to/python/with/debugpy",
"debuggerArgs": [
"-m",
"debugpy.adapter"
],
// source directories for resolving file paths
// if you always use absolute paths, you can omit this
"sourceDirs": [
"/path/to/source/code"
],
// debugger-specific settings start here
// configurations for debugpy can be found at
// https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings
// you can use "program" instead of "module" to specify the program to debug
"module": "pytest",
// the python executable to use to run the debuggee
"python": ["/path/to/python"],
"cwd": "/path/to/working/directory"
}此配置告知调试器:
调试器可执行文件及其参数的路径。
断点操作期间解析文件路径的源目录。
启动调试器所需的其他设置(例如模块、工作目录和解释器路径)。
可用的调试器类型
类型 | 示例路径 | 示例参数 |
调试 |
|
|
lldb |
|
|
可用工具
该项目公开了几个可以通过 MCP 框架调用的工具:
**启动:**启动被调试程序。
**set_breakpoint:**在指定的文件和行设置断点(可选条件)。
**remove_breakpoint:**从指定文件和行中删除断点。
**list_all_breakpoints:**列出调试器中当前设置的所有断点。
**continue_execution:**到达断点后继续程序执行。
**step_in:**进入函数调用。
**step_out:**跳出当前函数。
**next:**跳到下一行代码。
**评估:**在当前调试上下文中评估表达式。
**change_frame:**切换到不同的堆栈帧。
**view_file_around_line:**查看指定行周围的源代码(如果未指定,则使用最后提供的文件)。
**终止:**终止调试会话。
这些工具提供 XML 呈现的输出以便与 MCP 客户端集成。
使用其他 DAP 服务器进行扩展
要支持其他 DAP 服务器,您只需在dap_mcp/config.py文件中添加一个新的 DAP 专用配置类即可。所有 DAP 配置均从基类DAPConfig扩展而来。每个新的子类都应该:
定义一个唯一
type值(使用Literal)作为鉴别器。包括特定于该调试器的任何其他字段或设置。
例如,要添加对名为“mydap”的假设 DAP 服务器的支持,您可以添加:
class MyDAP(DAPConfig):
type: Literal["mydap"]
# Add any additional settings for MyDAP here
customSetting: Optional[str] = Field(
None, description="A custom setting for MyDAP."
)创建新的配置类后,通过添加新类来更新用于调试器特定配置的联合类型。例如:
DebuggerSpecificConfig = Annotated[Union[DebugPy, MyDAP], Field(..., discriminator="type")]现在,当您提供带有"type": "mydap"的配置 JSON 时,它将使用新的MyDAP类进行解析和验证,并且您的 DAP 服务器扩展将完全集成。
贡献
欢迎贡献!贡献方式:
分叉存储库。
为您的功能或错误修复创建一个新的分支。
编写测试并确保所有检查都通过。
提交拉取请求。
请遵循编码指南并在更改中包含适当的测试。
执照
本项目采用 AGPL-3.0 许可证。详情请参阅许可证文件。
This server cannot be deployed
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA VSCode extension that enables AI agents to programmatically control VSCode's debugging features through the Model Context Protocol (MCP).-
- AlicenseAqualityDmaintenanceEnables AI assistants to perform interactive Python debugging with breakpoints, step execution, and variable inspection using the Debug Adapter Protocol (DAP) through an MCP server interface.81MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for AI-assisted Python debugging using debugpy and Debug Adapter Protocol, enabling AI agents to run tests, set breakpoints, and inspect variables via natural language.8MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to inspect debug state, control execution, and set breakpoints in VS Code by exposing the Debug Adapter Protocol as an MCP server.Apache 2.0