A debugging toolkit that helps AI agents systematically investigate and fix bugs using runtime log instrumentation, inspired by Cursor's Debug Mode.
- Start the debug server from your project directory
- Add simple
fetch()calls to instrument suspicious code - Reproduce the bug → logs are captured
- Analyze logs to find root cause
- Fix and verify
# Navigate to YOUR project (logs will be saved here)
cd /path/to/your-project
# Start the debug server
python /path/to/debugging_mcp/src/server/debug_server.pyLogs are saved to ./logs/ in your current directory.
Just use fetch() directly in your code:
JavaScript/TypeScript:
await fetch('http://localhost:9876/log', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
timestamp: new Date().toISOString(),
level: 'debug',
message: 'Checking user permissions',
hypothesis: 'H1', // Tag with hypothesis ID
context: { userId: 123, role: user.role }
})
});Python:
import requests
requests.post('http://localhost:9876/log', json={
'level': 'debug',
'message': 'Checking user permissions',
'hypothesis': 'H1',
'context': {'user_id': 123, 'role': user.role}
}, timeout=1)# View logs
cat ./logs/debug_session_*.jsonl
# Or use the analysis tools
python /path/to/debugging_mcp/src/cli.py analyze- Hypothesize - Generate 3-5 hypotheses (H1, H2, H3...) about root cause
- Instrument - Add debug logs tagged with hypothesis IDs
- Reproduce - User triggers the bug
- Analyze - Review logs to validate/invalidate hypotheses
- Fix - Make minimal, targeted fix
- Verify - Confirm bug is resolved
- Cleanup - Remove debug instrumentation
| Endpoint | Method | Description |
|---|---|---|
/log |
POST | Submit a log entry |
/status |
GET | Server status |
/logs |
GET | Get all logs |
/clear |
POST | Clear all logs |
Each log entry (JSON):
{
"timestamp": "2024-12-13T10:30:00.000Z",
"level": "debug",
"message": "User authentication check",
"hypothesis": "H1",
"context": { "user_id": 123 }
}debugging_mcp/
├── src/
│ ├── server/debug_server.py # HTTP server for receiving logs
│ ├── analysis/ # Log parsing tools
│ └── cli.py # CLI helper
└── .agent/workflows/
└── debug-mode.md # AI agent workflow guide
To automatically start the debug server when opening your project in VSCode, Cursor, or Antigravity:
Add to your project's .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Debug Server",
"type": "shell",
"command": "python",
"args": ["/path/to/debugging_mcp/src/server/debug_server.py"],
"isBackground": true,
"problemMatcher": [],
"presentation": {
"reveal": "silent",
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}Important: Update the path to where you cloned debugging_mcp.
Add to your ~/.zshrc or ~/.bashrc:
alias debug-server="python /path/to/debugging_mcp/src/server/debug_server.py"Then just run debug-server in your project directory.
MIT