xdebug
v1.2.1MCP server for PHP Xdebug debugging with breakpoints, stepping, and variable inspection
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_sessions
List all active PHP debug sessions with their current state
get_session_state
Get detailed state of a specific debug session including current position and status
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID (uses active session if not specified) |
set_active_session
Set which debug session should be the active/default session for subsequent commands
| Parameter | Type | Description |
|---|---|---|
session_id * | string | Session ID to set as active |
close_session
Close and terminate a debug session
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID to close (uses active session if not specified) |
set_breakpoint
Set a breakpoint in PHP code. Supports line breakpoints and conditional breakpoints with hit counts. Can be set before a debug session starts - breakpoints will be applied when a session connects.
| Parameter | Type | Description |
|---|---|---|
file * | string | Full file path (use container path for Docker, e.g., /var/www/html/index.php) |
line * | integer | Line number for the breakpoint |
condition | string | Optional PHP condition expression (e.g., '$x > 10' or '$user !== null') |
hit_condition | string | Hit condition: >= (break when hits >= value), == (break on exact hit), % (break every N hits) |
hit_value | integer | Hit count value - break after this many hits |
session_id | string | Session ID (uses active session if not specified) |
set_exception_breakpoint
Set a breakpoint that triggers when a specific exception is thrown. Can be set before a debug session starts.
| Parameter | Type | Description |
|---|---|---|
exception | string | Exception class name to break on (use '*' for all exceptions, or specific like 'RuntimeException') |
session_id | string | Session ID |
set_call_breakpoint
Set a breakpoint that triggers when a specific function is called. Can be set before a debug session starts.
| Parameter | Type | Description |
|---|---|---|
function_name * | string | Function name to break on (e.g., 'myFunction' or 'MyClass::myMethod') |
session_id | string | Session ID |
remove_breakpoint
Remove a breakpoint by its ID. Works for both active session breakpoints and pending breakpoints.
| Parameter | Type | Description |
|---|---|---|
breakpoint_id * | string | The breakpoint ID to remove (session breakpoint ID or pending_* ID) |
session_id | string | Session ID |
update_breakpoint
Update a breakpoint (enable/disable or change hit conditions). Works for both active session and pending breakpoints.
| Parameter | Type | Description |
|---|---|---|
breakpoint_id * | string | The breakpoint ID to update |
hit_condition | string | New hit condition |
hit_value | integer | New hit count value |
session_id | string | Session ID |
state | string | Enable or disable the breakpoint |
list_breakpoints
List all breakpoints including both active session breakpoints and pending breakpoints
| Parameter | Type | Description |
|---|---|---|
include_pending | boolean | Include pending breakpoints in the list |
session_id | string | Session ID |
continue
Continue script execution until the next breakpoint or end of script
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
step_into
Step into the next function call, or to the next line if not a function call. This follows execution into called functions.
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
step_over
Step over to the next line in the current scope. Function calls are executed but not stepped into.
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
step_out
Step out of the current function. Execution continues until the current function returns.
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
stop
Stop the debug session and terminate script execution immediately
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
detach
Detach from the debug session and let the script continue running without debugging
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
get_stack_trace
Get the current call stack showing all function calls leading to the current position
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
get_contexts
Get available variable contexts (Local, Superglobals, User-defined constants) at the current position
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
stack_depth | integer | Stack frame depth (0 = current frame) |
get_variables
List all variables in scope with metadata (names, types, child counts). Use get_variable() to inspect specific variable values. Returns lightweight metadata for browsing the variable tree.
| Parameter | Type | Description |
|---|---|---|
context_id | integer | Context ID: 0=Local variables, 1=Superglobals, 2=User constants |
session_id | string | Session ID |
stack_depth | integer | Stack frame depth (0 = current frame) |
get_variable
Get a specific variable by name, including nested properties. Use PHP syntax for nested access (e.g., '$user->name', '$array[0]', '$obj->items[2]->value')
| Parameter | Type | Description |
|---|---|---|
name * | string | Variable name with $ prefix (e.g., '$user', '$data["key"]', '$obj->property') |
context_id | integer | Context ID |
max_depth | integer | Maximum depth for nested properties |
session_id | string | Session ID |
stack_depth | integer | Stack frame depth |
set_variable
Set the value of a variable in the current scope
| Parameter | Type | Description |
|---|---|---|
name * | string | Variable name (e.g., $x, $user->name) |
value * | string | New value as a PHP literal (e.g., 42, "hello", true, null) |
context_id | integer | Context ID |
session_id | string | Session ID |
stack_depth | integer | Stack frame depth |
evaluate
Evaluate a PHP expression in the current context. Returns the result of the expression. Use for calculations, method calls, or inspecting computed values.
| Parameter | Type | Description |
|---|---|---|
expression * | string | PHP expression to evaluate (e.g., '$x + $y', 'count($array)', '$user->getName()', 'array_keys($data)') |
session_id | string | Session ID |
stack_depth | integer | Stack frame depth |
get_source
Get the source code of a file or a specific line range
| Parameter | Type | Description |
|---|---|---|
file * | string | File path to get source from |
begin_line | integer | Starting line number |
end_line | integer | Ending line number |
session_id | string | Session ID |
add_watch
Add a watch expression that will be evaluated on each break. Watch expressions persist across steps.
| Parameter | Type | Description |
|---|---|---|
expression * | string | PHP expression to watch (e.g., '$user->id', 'count($items)') |
remove_watch
Remove a watch expression
| Parameter | Type | Description |
|---|---|---|
watch_id * | string | Watch ID to remove |
evaluate_watches
Evaluate all watch expressions and return their current values
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
list_watches
List all active watch expressions
add_logpoint
Add a logpoint that logs messages without stopping execution. Use {varName} placeholders for variables.
| Parameter | Type | Description |
|---|---|---|
file * | string | File path |
line * | integer | Line number |
message * | string | Message template with {var} placeholders (e.g., 'User {$userId} logged in') |
condition | string | Optional condition |
remove_logpoint
Remove a logpoint
| Parameter | Type | Description |
|---|---|---|
logpoint_id * | string | Logpoint ID |
get_logpoint_history
Get the log output history from logpoints
| Parameter | Type | Description |
|---|---|---|
limit | integer | Maximum entries to return |
logpoint_id | string | Specific logpoint ID (all if not specified) |
start_profiling
Start profiling to track memory usage and execution time
stop_profiling
Stop profiling and get the results
get_profile_stats
Get current profiling statistics
get_memory_timeline
Get memory usage timeline from profiling
capture_request_context
Capture the current HTTP request context ($_GET, $_POST, $_SESSION, $_COOKIE, headers)
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |
add_step_filter
Add a step filter to skip certain files/directories during stepping (e.g., vendor code)
| Parameter | Type | Description |
|---|---|---|
pattern * | string | Pattern to match (e.g., '/vendor/', '*.min.js', '/regex/') |
type * | string | include = step into, exclude = skip |
description | string | Description of the filter |
list_step_filters
List all step filter rules
get_function_history
Get the history of function calls made during debugging
| Parameter | Type | Description |
|---|---|---|
limit | integer | Maximum entries |
search | string | Search query to filter |
start_coverage
Start tracking code coverage during debugging
stop_coverage
Stop tracking code coverage and get the report
get_coverage_report
Get the current code coverage report
save_debug_profile
Save the current debug configuration (breakpoints, watches, filters) as a named profile
| Parameter | Type | Description |
|---|---|---|
name * | string | Profile name |
description | string | Profile description |
load_debug_profile
Load a saved debug profile
| Parameter | Type | Description |
|---|---|---|
name * | string | Profile name to load |
list_debug_profiles
List all saved debug profiles
export_session
Export the current debug session as a report
| Parameter | Type | Description |
|---|---|---|
format | string | Export format |
session_id | string | Session ID |
capture_snapshot
Capture a snapshot of the current debug state for the export report
| Parameter | Type | Description |
|---|---|---|
session_id | string | Session ID |