mcp-debugpy
MCP 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.
README
mcp-debugpy
MCP server for AI-assisted Python debugging using debugpy and Debug Adapter Protocol.
Enable AI agents to debug your Python code through natural language. This MCP server provides:
- pytest JSON reports for machine-readable failures
- DAP (Debug Adapter Protocol) control of a live
debugpysession (breakpoints, continue, variables) - MCP server exposing tools: run tests, read JSON, and send DAP commands
Quick start
macOS/Linux:
git clone <this-folder>
cd mvp-agent-debug
./setup.sh
# Activate the venv and run demos/tests:
source .venv/bin/activate
python src/dap_stdio_direct.py # direct adapter walkthrough
python -m pytest tests/test_mcp_server.py # verify MCP tooling
Windows:
git clone <this-folder>
cd mvp-agent-debug
setup.bat
REM Activate the venv and run demos/tests:
.venv\Scripts\activate
python src\dap_stdio_direct.py
python -m pytest tests\test_mcp_server.py
Install (from source):
python -m pip install -e '.[dev]'
IMPORTANT: Install git hooks to run CI checks before every commit:
./scripts/install-hooks.sh
This prevents CI failures by automatically running ruff, black, mypy, and pytest before allowing commits.
Run the CLI after activating the project virtualenv:
mcp-debug-server --help
Then register the MCP server with VS Code and/or Claude so they can launch it automatically:
python scripts/configure_mcp_clients.py
Open your MCP-aware chat surface and invoke tools like run_tests_json or dap_launch (see docs/mcp_usage.md for a full walkthrough).
The sample app intentionally contains a bug to demonstrate failing tests and an interactive breakpoint.
Optional helper
Run python scripts/configure_mcp_clients.py to detect existing VS Code/Claude MCP entries, interactively add/update/remove them, and generate a Claude snippet. Works on macOS, Linux, and Windows.
Developer tooling
This repository uses pre-commit hooks and CI for linting, formatting, and typing checks.
Install hooks locally:
source .venv/bin/activate
pip install pre-commit
pre-commit install
pre-commit run --all-files
If you prefer to run hooks manually, the CI runs ruff, black --check, and mypy before pytest.
π For a step-by-step walkthrough of every MCP tool (including suggested agent workflows for VS Code and Claude), see docs/mcp_usage.md.
Using the MCP tooling
IMPORTANT: MCP servers are automatically managed by MCP clients. You do NOT need to manually start this server from the command line. Instead, configure it in your MCP client (VS Code or Claude Desktop) and it will automatically start when needed.
Configuration
VS Code
Add to your settings.json:
{
"mcp.servers.agentDebug": {
"command": "/path/to/your/project/.venv/bin/python",
"args": ["src/mcp_server.py"],
"cwd": "/path/to/your/project",
"env": {
"PYTHONPATH": "/path/to/your/project/src"
}
}
}
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"agentDebug": {
"command": "/path/to/your/project/.venv/bin/python",
"args": ["src/mcp_server.py"],
"cwd": "/path/to/your/project",
"env": {
"PYTHONPATH": "/path/to/your/project/src"
}
}
}
}
Manual Testing (Protocol Development Only)
In normal usage you should never run python src/mcp_server.py yourselfβMCP clients spawn and manage the process automatically. The notes below are only for developers building custom MCP clients or experimenting with raw protocol traffic.
Step 1 β Register the server with your MCP client
-
VS Code (AI Chat + MCP extension) β run the helper script (supports add/update/remove) or add the entry manually.
# Optional helper that updates VS Code settings and writes a Claude snippet python scripts/configure_mcp_clients.pyIf configuring by hand, add this to
settings.json:{ "mcp.servers.agentDebug": { "command": "${workspaceFolder}/.venv/bin/python", // Windows: ".venv\\Scripts\\python.exe" "args": ["src/mcp_server.py"], "cwd": "${workspaceFolder}" } }VS Code will spawn and manage the server automatically whenever you open the chat.
-
Claude Desktop β open Settings β Model Context Protocol β Add server and enter (or paste the generated snippet):
Command: /full/path/to/.venv/bin/python Arguments: src/mcp_server.py Working dir: /full/path/to/mvp-agent-debugClaude starts the process on demand and tears it down when idle.
-
Manual / CLI usage (protocol debugging only) β launching
python src/mcp_server.pydirectly will block your terminal waiting for MCP-framed JSON messages. Do this only if you are writing a custom MCP client and need a raw stdin/stdout endpoint.
Step 2 β Launch the sample app under debugpy
-
Example tool request:
{ "name": "dap_launch", "input": { "program": "src/sample_app/app.py", "cwd": ".", "breakpoints": [8], "wait_for_breakpoint": true } }
The response includes the initialize/launch payloads plus an eventual stoppedEvent once line 8 is hit. If you prefer to skip the terminal noise, remove or keep the [dap:event] β¦ debug prints in src/dap_stdio_client.pyβthey are purely diagnostic.
Step 3 β Inspect and resume
- Call
dap_localsto fetch the threads, stack frames, scopes, and locals. - Use
dap_continue(optionally with a specificthread_id) to resume execution. - Call
dap_shutdownwhen you are finished; it tears down the adapter process cleanly.
Step 4 β Run tests via MCP
-
Example tool request:
{ "name": "run_tests_json" }
Or focus on a subset with run_tests_focus.
Repository layout
src/sample_app/app.pyβ tiny app with a bug (drives sample failure)src/sample_app/tests/test_app.pyβ pytest suite covering the bugsrc/dap_stdio_client.pyβ stdio client talking todebugpy.adapter, handling reverse requestssrc/dap_stdio_direct.pyβ direct adapter walkthrough (initialize β breakpoints β configurationDone β launch β stepping)src/mcp_server.pyβ stdio MCP surface combining pytest helpers and DAP launch/inspect toolstests/test_mcp_server.pyβ unit tests that fake the adapter to verify retries and control flowexamples/β additional mini-projects with xfailed tests and detailed READMEsexamples/math_bugβ arithmetic bug demoexamples/async_workerβ async gather bug demoexamples/gui_counterβ Tkinter counter UI showcasing GUI debuggingexamples/web_flaskβ Flask endpoint for server-side walkthroughs
docs/testing.mdβ consolidated instructions for all automated testsSTATUS.md/FINAL_REPORT.mdβ project snapshot for maintainers
Requirements
requirements.txtβ runtime dependencies (MCP server, debugpy, Flask)requirements-dev.txtβ test-only dependencies (pytest, pytest-asyncio, JSON reporting)
Contributing
See CONTRIBUTING.md for local setup tips and testing guidance.
Security
Bind debug servers to 127.0.0.1 and use SSH tunnels for remote hosts.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.