DAP Debug Adapter
STDIOMCP implementation for managing Debug Adapter Protocol sessions and enhancing debugging workflows.
MCP implementation for managing Debug Adapter Protocol sessions and enhancing debugging workflows.
dap-mcp is an implementation of the Model Context Protocol (MCP) tailored for managing Debug Adapter Protocol (DAP) sessions. MCP provides a standardized framework to optimize and extend the context window of large language models, and in this project, it is used to enhance and streamline debugging workflows.
Install dap-mcp and its dependencies:
pip install dap-mcp python -m dap_mcp --config config.json # Or, if you have uv installed uvx dap-mcp@latest --config config.json
The project uses a JSON configuration file (e.g., .config.json
) to specify debugger settings and source directories. An example configuration:
{ "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" }
This configuration informs the debugger about:
Type | Example Path | Example Args |
---|---|---|
debugpy | /usr/bin/python3 | ["-m", "debugpy.adapter"] |
lldb | /usr/bin/lldb-dap | [] |
The project exposes several tools that can be invoked via the MCP framework:
These tools provide XML-rendered output for integration with MCP clients.
To support additional DAP servers, you can simply add a new DAP-specific configuration class in the dap_mcp/config.py
file. All DAP configurations extend from the base DAPConfig
class. Each new subclass should:
type
value (using a Literal
) to act as a discriminator.For example, to add support for a hypothetical DAP server called "mydap", you might add:
class MyDAP(DAPConfig): type: Literal["mydap"] # Add any additional settings for MyDAP here customSetting: Optional[str] = Field( None, description="A custom setting for MyDAP." )
After creating your new configuration class, update the union type used for debugger-specific configurations by including your new class. For example:
DebuggerSpecificConfig = Annotated[Union[DebugPy, MyDAP], Field(..., discriminator="type")]
Now, when you supply a configuration JSON with "type": "mydap"
, it will be parsed and validated using your new MyDAP
class, and your DAP server extension will be fully integrated.
Contributions are welcome! To contribute:
Please follow the coding guidelines and include appropriate tests with your changes.
This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.