Skip to content

v0.2.0: Comprehensive Web App Debugging Support

Choose a tag to compare

@markomanninen markomanninen released this 31 Oct 13:44
· 22 commits to main since this release

Release v0.2.0: Comprehensive Web App Debugging Support

🎉 Major Features

Full Web Application Debugging

  • HTTP-triggered breakpoints for Flask, Django, and FastAPI applications
  • Launch web servers under debugger control with dap_launch
  • Pause execution on HTTP requests and inspect request handlers interactively
  • Complete automated test suite demonstrating the workflow

New Examples & Documentation

  • examples/web_flask/run_flask.py - Flask app launcher for debugging
  • tests/test_web_app_debug.py - Comprehensive automated tests (2 tests, both passing)
  • docs/DEBUGGING_WEB_APPS.md - Complete guide for web app debugging
  • Enhanced AI agent instructions in agent_instructions.md

⚠️ Breaking Changes

Removed dap_attach()

The dap_attach approach was investigated but does not work with debugpy. When you run python -m debugpy --listen, debugpy does not respond to DAP attach requests. This is a fundamental limitation of debugpy's architecture.

Migration: Use dap_launch for ALL debugging scenarios:

  • ✅ Web servers (Flask/Django/FastAPI)
  • ✅ GUI applications
  • ✅ Command-line scripts
  • ✅ Long-running processes

✨ What's New

Files Added

  • examples/web_flask/run_flask.py - Flask debugging launcher
  • examples/gui_counter/run_counter_debug.py - GUI counter launcher
  • tests/test_web_app_debug.py - Automated web app debugging tests
  • docs/DEBUGGING_WEB_APPS.md - Comprehensive debugging guide
  • .envrc - Auto-activate venv with direnv

Documentation Updates

  • agent_instructions.md: Added "Debugging Web Applications" section with step-by-step workflow
  • docs/mcp_usage.md: Updated with web app debugging examples
  • examples/web_flask/README.md: Complete rewrite with correct dap_launch workflow
  • examples/gui_counter/README.md: Added GUI debugging instructions

🔧 Improvements

Code Quality

  • Removed 187 lines of non-functional dap_attach code
  • Removed DirectDAPClient class and all attach mode logic
  • Fixed all ruff, black, and mypy linting issues
  • Added types-aiofiles for proper type checking
  • Better error handling and type safety

Testing

  • 9/9 tests passing (up from 7)
  • 2 new web app debugging tests
  • Tests verify HTTP-triggered breakpoints and loop iteration debugging

Developer Experience

  • .envrc for automatic venv activation with direnv
  • VSCode settings configured to use .venv by default
  • Improved pre-commit hooks (exclude examples from mypy)

📊 Test Results

tests/test_cli.py::test_cli_help_returns_zero PASSED
tests/test_mcp_end_to_end.py::test_mcp_end_to_end PASSED  
tests/test_mcp_server.py::test_dap_launch_handles_late_initialized PASSED
tests/test_mcp_server.py::test_dap_set_breakpoints_reuses_session PASSED
tests/test_mcp_server.py::test_dap_locals_and_continue PASSED
tests/test_mcp_server.py::test_dap_shutdown_closes_session PASSED
tests/test_mcp_server.py::test_dap_launch_breakpoints_by_source_retry_after_stop PASSED
tests/test_web_app_debug.py::test_flask_app_debugging_with_http_breakpoint PASSED
tests/test_web_app_debug.py::test_flask_breakpoint_hit_twice_in_loop PASSED

============================== 9 passed in 45.57s ==============================

🚀 Getting Started with Web App Debugging

  1. Launch your Flask app under debugger control:
from mcp_server import dap_launch

await dap_launch(
    program="examples/web_flask/run_flask.py",
    breakpoints_by_source={
        "examples/web_flask/inventory.py": [18]
    },
    wait_for_breakpoint=False
)
  1. Trigger the breakpoint:
curl http://127.0.0.1:5001/total
  1. Inspect variables and step through code:
await dap_wait_for_event("stopped")
locals_result = await dap_locals()
await dap_step_over()
await dap_continue()

See docs/DEBUGGING_WEB_APPS.md for complete details!

🙏 Acknowledgments

This release represents a major step forward in making Python debugging more accessible to AI agents and developers. Special thanks to the debugpy and MCP communities!


Full Changelog: v0.1.1...v0.2.0