You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+39-51Lines changed: 39 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,14 +90,15 @@ php -dxdebug.mode=debug tests/fixtures/debug_test.php # Run PHP script with X
90
90
91
91
### Core Components
92
92
93
-
-**McpServer.php**: Main MCP protocol handler that processes JSON-RPC requests and delegates to XdebugClient
93
+
-**McpServer.php**: Main MCP protocol handler that processes JSON-RPC requests and delegates to the debug/trace/profile/coverage components
94
94
- Implements multiple MCP tools across debugging, profiling, and coverage categories
95
95
- Handles JSON-RPC 2.0 protocol validation and routing
96
96
- Supports debug mode via MCP_DEBUG environment variable
97
-
-**XdebugClient.php**: Xdebug protocol client that communicates directly with Xdebug via sockets
98
-
- Socket-based communication with Xdebug daemon
97
+
-**DebugServer.php**: DBGp debug server that listens on a TCP socket and drives interactive step debugging with Xdebug
98
+
- Socket-based DBGp communication with Xdebug
99
99
- XML response parsing and transaction management
100
-
- Connection lifecycle and error handling
100
+
- Connection lifecycle and session management (see "Interactive Step Debugging Workflow" below)
101
+
-**XdebugRunner.php / XdebugTracer.php / XdebugProfiler.php**: Spawn PHP with the appropriate Xdebug mode (trace/profile/coverage) for the non-interactive CLI tools
101
102
-**bin/xdebug-mcp**: Executable entry point that instantiates and runs McpServer
102
103
- CLI interface with argument parsing
103
104
- Standard input/output handling for MCP protocol
@@ -136,8 +137,8 @@ The server exposes multiple tools via MCP across main categories:
136
137
137
138
### Architecture Flow
138
139
1. MCP client sends JSON-RPC requests to McpServer
139
-
2. McpServer validates and routes tool calls to XdebugClient methods
140
-
3.XdebugClient communicates with Xdebug via socket protocol
140
+
2. McpServer validates and routes tool calls to the relevant component (DebugServer for interactive debugging, XdebugRunner/Tracer/Profiler for trace/profile/coverage)
141
+
3.That component communicates with Xdebug (DBGp socket for debugging, or a spawned PHP process with Xdebug enabled for trace/profile/coverage)
141
142
4. Results are returned through MCP protocol back to client
142
143
143
144
### Testing Infrastructure
@@ -283,12 +284,11 @@ The Xdebug trace functionality enables AI assistants to analyze detailed executi
283
284
284
285
**Quick Trace Testing**
285
286
```bash
286
-
#Run comprehensive trace tests
287
-
./bin/xtrace
287
+
#Trace any PHP script (vendor code excluded by default)
@@ -479,7 +479,7 @@ When MCP tools exceed 10% of context, Claude Code's Tool Search feature dynamica
479
479
**For Interactive Step Debugging:**
480
480
- User: "Debug this code", "Set breakpoints", "Step through execution", "Inspect variables"
481
481
- AI automatically runs: `./bin/xstep path/to/file.php`
482
-
-**IMPORTANT**: Requires XdebugClient to be listening first (see Step Debugging Workflow below)
482
+
-**IMPORTANT**: `./bin/xstep` is a single command that internally builds a DebugServer and spawns the target, so no separate listener is required (see Step Debugging Workflow below)
483
483
484
484
**For Execution Flow Analysis:**
485
485
- User: "Trace execution", "Show function calls", "Analyze execution flow"
0 commit comments