A comprehensive REST API and MCP server for remote Python debugging using pdb.
- Remote Debugging: Debug Python applications via REST API calls
- AI-Assisted Debugging: MCP server integration for Claude Code
- Session Management: Multiple concurrent debugging sessions
- Comprehensive Logging: Complete audit trail of debugging operations
- Multiple Breakpoint Types: Regular, conditional, and temporary breakpoints
- Variable Inspection: Real-time inspection of variables and expressions
- Step-by-Step Execution: Programmatic control over code execution flow
- Claude Code can automatically set breakpoints at suspicious code locations
- AI can step through execution to understand program flow
- Intelligent variable inspection to identify data corruption or logic errors
- Automated debugging reports with root cause analysis
- Debug production systems without direct server access
- Collaborative debugging with multiple developers
- Automated debugging pipelines integrated into CI/CD
- Cloud-native debugging for containerized applications
pdb-debug/ βββ pdb-rest-gateway/ # Main PDB Gateway implementation β βββ src/pdb_gateway/ # Core library code β β βββ api/ # REST API endpoints β β βββ core/ # Debugging engine and session management β β βββ mcp/ # MCP server implementation β β βββ schemas/ # Request/response schemas β βββ simple_server.py # Standalone REST API server β βββ mcp_server.py # MCP server for Claude Code β βββ requirements.txt # Python dependencies β βββ *.py # Test and demo scripts βββ breakpoint-simulation/ # Test applications and demos β βββ data_processor.py # Sample data processing pipeline (295 lines) β βββ test_*.py # Comprehensive test suites β βββ *.md # Testing documentation βββ CLAUDE.md # Complete integration guide βββ README.md # This file
# REST API server (port 8002) cd pdb-rest-gateway python3 simple_server.py # OR MCP server for Claude Code integration python3 mcp_server.py
# Run comprehensive debugging tests python3 breakpoint-simulation/test_with_logging.py # Test real debugging scenarios python3 breakpoint-simulation/test_debugging.py # Analyze debugging logs python3 pdb-rest-gateway/view_logs.py
# Create debug session via REST API curl -X POST http://localhost:8002/debug/sessions \ -H "Content-Type: application/json" \ -d '{"target_file": "your_script.py"}' # Set breakpoint curl -X POST http://localhost:8002/debug/sessions/{session_id}/breakpoint \ -H "Content-Type: application/json" \ -d '{"filename": "your_script.py", "line_number": 25}' # Step through execution curl -X POST http://localhost:8002/debug/sessions/{session_id}/step \ -H "Content-Type: application/json" \ -d '{"step_type": "continue"}'
Method | Endpoint | Description |
---|---|---|
POST | /debug/sessions | Create new debugging session |
GET | /debug/sessions | List active sessions |
GET | /debug/sessions/{id} | Get session information |
DELETE | /debug/sessions/{id} | Terminate session |
POST | /debug/sessions/{id}/breakpoint | Set/remove breakpoint |
POST | /debug/sessions/{id}/step | Step through execution |
POST | /debug/sessions/{id}/inspect | Inspect variables |
POST | /debug/sessions/{id}/execute | Execute PDB commands |
GET | /debug/sessions/{id}/output | Get debug output |
When configured as an MCP server, provides these tools for Claude Code:
pdb_start_session
- Initialize debugging sessionpdb_set_breakpoint
- Set/remove breakpointspdb_step
- Step through code executionpdb_inspect
- Inspect variables and expressionspdb_execute
- Execute arbitrary PDB commandspdb_list_sessions
- List active sessionspdb_terminate_session
- End debugging sessions
Our comprehensive testing demonstrates:
- 47 operations executed in 0.817 seconds (57.5 ops/sec)
- 10 breakpoints set (regular, conditional, temporary)
- 8 step operations (next, continue, step with counts)
- 14 variable inspections (simple vars, complex expressions)
- 13 command executions (list, where, args, locals, etc.)
- Complete logging with 29.8 KB audit trail
- Interactive debugging of complex applications
- Root cause analysis of production issues
- Code behavior understanding and documentation
- Performance bottleneck identification
- Automated bug detection and analysis
- Intelligent code review and suggestions
- Educational code walkthroughs
- Debugging knowledge capture and sharing
- Audit compliance with complete operation logging
- Security monitoring of debugging activities
- Collaborative debugging across teams
- Integration with CI/CD pipelines
- Python 3.7+
- Standard library modules (pdb, threading, json, etc.)
- Optional: FastAPI for REST server
- Optional: MCP library for Claude Code integration
All debugging operations are logged with:
- Timestamp tracking for all operations
- Success/failure status for each operation
- Complete parameter values and results
- Session duration and performance metrics
- Error tracking and debugging information
View logs with:
python3 pdb-rest-gateway/view_logs.py tail -f pdb-rest-gateway/pdb_gateway.log
- Predictive debugging - AI predicts where bugs will occur
- Self-healing code - Systems that debug and fix themselves
- Intelligent monitoring - Continuous debugging of live systems
- Code optimization - AI suggests improvements based on execution analysis
See CLAUDE.md
for complete integration guide including:
- ETL system integration examples
- Natural language debugging commands
- Comprehensive API documentation
- Troubleshooting and best practices
π― This tool revolutionizes Python debugging by making it programmable, remote, intelligent, and scalable!