Sponsored by Deepsite.site

dap-mcp

Created By
KashunCheng9 months ago
Model Context Protocol (MCP) server that interacts with a Debugger
Content

dap-mcp

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.

Features

  • Debug Adapter Protocol Integration: Interact with debuggers using a standardized protocol.
  • MCP Framework: Leverage MCP to optimize context and enhance debugging workflows.
  • Rich Debugging Tools: Set, list, and remove breakpoints; control execution (continue, step in/out/next); evaluate expressions; change stack frames; and view source code.
  • Flexible Configuration: Customize debugger settings, source directories, and other parameters via a JSON configuration file.

Installation

Prerequisites

  • Python 3.10 or higher
  • uv (optional, for running the server)

Installing and Running the Server

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

Configuration

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:

  • The path to the debugger executable and its arguments.
  • The source directories for resolving file paths during breakpoint operations.
  • Other settings (such as module, working directory, and interpreter path) necessary for launching the debuggee.

Available Debugger Types

TypeExample PathExample Args
debugpy/usr/bin/python3["-m", "debugpy.adapter"]
lldb/usr/bin/lldb-dap[]

Available Tools

The project exposes several tools that can be invoked via the MCP framework:

  • launch: Launch the debuggee program.
  • set_breakpoint: Set a breakpoint at a specified file and line (with an optional condition).
  • remove_breakpoint: Remove a breakpoint from a specified file and line.
  • list_all_breakpoints: List all breakpoints currently set in the debugger.
  • continue_execution: Continue program execution after hitting a breakpoint.
  • step_in: Step into a function call.
  • step_out: Step out of the current function.
  • next: Step over to the next line of code.
  • evaluate: Evaluate an expression in the current debugging context.
  • change_frame: Switch to a different stack frame.
  • view_file_around_line: View source code around a specified line (using the last provided file if none is specified).
  • terminate: Terminate the debugging session.

These tools provide XML-rendered output for integration with MCP clients.

Extending with Other DAP Servers

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:

  • Define a unique type value (using a Literal) to act as a discriminator.
  • Include any additional fields or settings specific to that debugger.

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.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Write tests and ensure all checks pass.
  4. Submit a pull request.

Please follow the coding guidelines and include appropriate tests with your changes.

License

This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
ChatWiseThe second fastest AI chatbot™
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Tavily Mcp
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
DeepChatYour AI Partner on Desktop
Amap Maps高德地图官方 MCP Server
CursorThe AI Code Editor
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code