PHP debugging and analysis tools using Xdebug. Use when asked to trace, debug, profile, or analyze coverage of PHP code.
View on GitHubSelect agents to install to:
npx add-skill https://github.com/koriym/xdebug-mcp/blob/main/skills/xdebug/SKILL.md -a claude-code --skill xdebugInstallation paths:
.claude/skills/xdebug/# Xdebug MCP Tools
Non-invasive PHP debugging and analysis tools. No var_dump() or code modification needed.
## Tool Paths
Tools are installed globally via composer. Use absolute paths:
| Tool | Path |
|------|------|
| xtrace | `~/.composer/vendor/bin/xtrace` |
| xstep | `~/.composer/vendor/bin/xstep` |
| xprofile | `~/.composer/vendor/bin/xprofile` |
| xcoverage | `~/.composer/vendor/bin/xcoverage` |
| xback | `~/.composer/vendor/bin/xback` |
## Tool Selection Guide
| User Request | Tool |
|--------------|------|
| Trace, execution flow, show function calls | xtrace |
| Step debugging, breakpoints, inspect variables, track variable changes | xstep |
| Profile, performance, bottlenecks, slow code | xprofile |
| Coverage, test coverage, which lines tested | xcoverage |
| Backtrace, call stack, how did we get here | xback |
### "Trace" Ambiguity
The word "trace" can mean different things:
- **Forward Trace** → `xtrace` (records execution from start to finish)
- **Backtrace / Stack Trace** → `xback` (shows call stack at a point)
- **Step through / Debug** → `xstep` (interactive with breakpoints)
---
## xtrace - Forward Trace (Full)
Trace execution forward from start to finish. Captures complete execution flow, function calls, parameters, and timing data.
**Output**: JSON with `$schema` URL for semantic details and AI analysis strategies.
**Key fields**: `{lines, functions, max_depth, db_queries}`
```bash
~/.composer/vendor/bin/xtrace [--json] [--context=TEXT] [--include-vendor=PATTERNS] -- command
```
### Examples
```bash
~/.composer/vendor/bin/xtrace --context="Debug login" -- php login.php
~/.composer/vendor/bin/xtrace --context="Test analysis" -- vendor/bin/phpunit tests/UserTest.php
~/.composer/vendor/bin/xtrace --include-vendor="bear/*" -- php app.php
```
### When to Use
- "Trace this code"
- "Show execution flow"
- "What functions are called?"
- General PHP debugging (default choice)
---
## xstep - Forward Trace (Step-by-Step)
Stop at breakpo