xdebug

v1.2.1
io.github.kpanuragh/xdebug Checked 3 hours ago Published 8 months ago

MCP 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

ParameterTypeDescription
session_idstringSession ID (uses active session if not specified)

set_active_session

Set which debug session should be the active/default session for subsequent commands

ParameterTypeDescription
session_id *stringSession ID to set as active

close_session

Close and terminate a debug session

ParameterTypeDescription
session_idstringSession 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.

ParameterTypeDescription
file *stringFull file path (use container path for Docker, e.g., /var/www/html/index.php)
line *integerLine number for the breakpoint
conditionstringOptional PHP condition expression (e.g., '$x > 10' or '$user !== null')
hit_conditionstringHit condition: >= (break when hits >= value), == (break on exact hit), % (break every N hits)
hit_valueintegerHit count value - break after this many hits
session_idstringSession 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.

ParameterTypeDescription
exceptionstringException class name to break on (use '*' for all exceptions, or specific like 'RuntimeException')
session_idstringSession ID

set_call_breakpoint

Set a breakpoint that triggers when a specific function is called. Can be set before a debug session starts.

ParameterTypeDescription
function_name *stringFunction name to break on (e.g., 'myFunction' or 'MyClass::myMethod')
session_idstringSession ID

remove_breakpoint

Remove a breakpoint by its ID. Works for both active session breakpoints and pending breakpoints.

ParameterTypeDescription
breakpoint_id *stringThe breakpoint ID to remove (session breakpoint ID or pending_* ID)
session_idstringSession ID

update_breakpoint

Update a breakpoint (enable/disable or change hit conditions). Works for both active session and pending breakpoints.

ParameterTypeDescription
breakpoint_id *stringThe breakpoint ID to update
hit_conditionstringNew hit condition
hit_valueintegerNew hit count value
session_idstringSession ID
statestringEnable or disable the breakpoint

list_breakpoints

List all breakpoints including both active session breakpoints and pending breakpoints

ParameterTypeDescription
include_pendingbooleanInclude pending breakpoints in the list
session_idstringSession ID

continue

Continue script execution until the next breakpoint or end of script

ParameterTypeDescription
session_idstringSession 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.

ParameterTypeDescription
session_idstringSession ID

step_over

Step over to the next line in the current scope. Function calls are executed but not stepped into.

ParameterTypeDescription
session_idstringSession ID

step_out

Step out of the current function. Execution continues until the current function returns.

ParameterTypeDescription
session_idstringSession ID

stop

Stop the debug session and terminate script execution immediately

ParameterTypeDescription
session_idstringSession ID

detach

Detach from the debug session and let the script continue running without debugging

ParameterTypeDescription
session_idstringSession ID

get_stack_trace

Get the current call stack showing all function calls leading to the current position

ParameterTypeDescription
session_idstringSession ID

get_contexts

Get available variable contexts (Local, Superglobals, User-defined constants) at the current position

ParameterTypeDescription
session_idstringSession ID
stack_depthintegerStack 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.

ParameterTypeDescription
context_idintegerContext ID: 0=Local variables, 1=Superglobals, 2=User constants
session_idstringSession ID
stack_depthintegerStack 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')

ParameterTypeDescription
name *stringVariable name with $ prefix (e.g., '$user', '$data["key"]', '$obj->property')
context_idintegerContext ID
max_depthintegerMaximum depth for nested properties
session_idstringSession ID
stack_depthintegerStack frame depth

set_variable

Set the value of a variable in the current scope

ParameterTypeDescription
name *stringVariable name (e.g., $x, $user->name)
value *stringNew value as a PHP literal (e.g., 42, "hello", true, null)
context_idintegerContext ID
session_idstringSession ID
stack_depthintegerStack 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.

ParameterTypeDescription
expression *stringPHP expression to evaluate (e.g., '$x + $y', 'count($array)', '$user->getName()', 'array_keys($data)')
session_idstringSession ID
stack_depthintegerStack frame depth

get_source

Get the source code of a file or a specific line range

ParameterTypeDescription
file *stringFile path to get source from
begin_lineintegerStarting line number
end_lineintegerEnding line number
session_idstringSession ID

add_watch

Add a watch expression that will be evaluated on each break. Watch expressions persist across steps.

ParameterTypeDescription
expression *stringPHP expression to watch (e.g., '$user->id', 'count($items)')

remove_watch

Remove a watch expression

ParameterTypeDescription
watch_id *stringWatch ID to remove

evaluate_watches

Evaluate all watch expressions and return their current values

ParameterTypeDescription
session_idstringSession ID

list_watches

List all active watch expressions

add_logpoint

Add a logpoint that logs messages without stopping execution. Use {varName} placeholders for variables.

ParameterTypeDescription
file *stringFile path
line *integerLine number
message *stringMessage template with {var} placeholders (e.g., 'User {$userId} logged in')
conditionstringOptional condition

remove_logpoint

Remove a logpoint

ParameterTypeDescription
logpoint_id *stringLogpoint ID

get_logpoint_history

Get the log output history from logpoints

ParameterTypeDescription
limitintegerMaximum entries to return
logpoint_idstringSpecific 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)

ParameterTypeDescription
session_idstringSession ID

add_step_filter

Add a step filter to skip certain files/directories during stepping (e.g., vendor code)

ParameterTypeDescription
pattern *stringPattern to match (e.g., '/vendor/', '*.min.js', '/regex/')
type *stringinclude = step into, exclude = skip
descriptionstringDescription of the filter

list_step_filters

List all step filter rules

get_function_history

Get the history of function calls made during debugging

ParameterTypeDescription
limitintegerMaximum entries
searchstringSearch 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

ParameterTypeDescription
name *stringProfile name
descriptionstringProfile description

load_debug_profile

Load a saved debug profile

ParameterTypeDescription
name *stringProfile name to load

list_debug_profiles

List all saved debug profiles

export_session

Export the current debug session as a report

ParameterTypeDescription
formatstringExport format
session_idstringSession ID

capture_snapshot

Capture a snapshot of the current debug state for the export report

ParameterTypeDescription
session_idstringSession ID