-
Notifications
You must be signed in to change notification settings - Fork 7
Configuration Reference
Complete reference for configuring the Xdebug MCP Server and PHP Xdebug.
Configure the MCP Server via environment variables:
# TCP Configuration
XDEBUG_HOST=0.0.0.0 # Bind address
XDEBUG_PORT=9003 # Listen port
# Unix Socket Configuration
XDEBUG_SOCKET_PATH=/tmp/xdebug.sock # Socket path
# Logging
DEBUG=xdebug-mcp # Enable debug outputTCP Mode (Default):
xdebug-mcp
# or explicit
XDEBUG_HOST=0.0.0.0 XDEBUG_PORT=9003 xdebug-mcpUnix Socket Mode:
XDEBUG_SOCKET_PATH=/tmp/xdebug.sock xdebug-mcpCustom Port:
XDEBUG_PORT=9004 xdebug-mcpDebug Logging:
DEBUG=xdebug-mcp xdebug-mcpAdd these settings to your php.ini file:
[xdebug]
; Load extension
zend_extension=xdebug
; Enable debug mode
xdebug.mode=debug
; Connection settings
xdebug.client_host=localhost
xdebug.client_port=9003
; IDE Key (optional)
xdebug.idekey=xdebug-mcp[xdebug]
; Core Settings
zend_extension=xdebug
xdebug.mode=debug ; debug, profile, trace, coverage, gcstats
xdebug.max_nesting_level=256 ; Stack depth limit
; Client Connection (TCP)
xdebug.client_host=localhost
xdebug.client_port=9003
xdebug.discover_client_host=true
xdebug.client_discovery_header=HTTP_X_FORWARDED_FOR
; Client Connection (Unix Socket)
; xdebug.client_host=/tmp/xdebug.sock
; xdebug.client_port=0
; Debug Control
xdebug.break_on_first_line=true ; Break at script start
xdebug.trigger_value=debug ; Trigger value for selective debug
xdebug.trigger=GET ; Which superglobal to trigger on
; Logging
xdebug.log=/tmp/xdebug.log
xdebug.log_level=10
; IDE Key
xdebug.idekey=xdebug-mcp
; Additional
xdebug.var_display_max_depth=5
xdebug.var_display_max_data=10000
xdebug.var_display_max_children=100Values: off, debug, profile, trace, coverage, gcstats, or combinations
Examples:
; Single mode
xdebug.mode=debug
; Multiple modes
xdebug.mode=debug,profile
; Disable Xdebug
xdebug.mode=offMode Descriptions:
| Mode | Purpose | Overhead |
|---|---|---|
| debug | Interactive debugging (breakpoints, stepping) | 5-10x |
| profile | Performance analysis | 2-5x |
| trace | Function call logging | 10-20x |
| coverage | Code coverage analysis | 3-8x |
| gcstats | Garbage collector stats | Low |
Values: IP address, hostname, or socket path
Examples:
; localhost
xdebug.client_host=localhost
xdebug.client_host=127.0.0.1
; Network
xdebug.client_host=192.168.1.100
xdebug.client_host=debugger.example.com
; Unix socket
xdebug.client_host=/tmp/xdebug.sockValues: Port number (0-65535), or 0 for Unix socket
Default: 9003
Examples:
; Standard port
xdebug.client_port=9003
; Custom port
xdebug.client_port=9004
; Unix socket (port must be 0)
xdebug.client_host=/tmp/xdebug.sock
xdebug.client_port=0Values: String identifier
Default: Based on environment
Examples:
; Standard
xdebug.idekey=xdebug-mcp
; IDE-specific
xdebug.idekey=vscode
xdebug.idekey=phpstorm
xdebug.idekey=netbeans
; Custom
xdebug.idekey=my-debuggerValues: true/false
Default: false
Purpose: Break at script's first line before execution
Example:
xdebug.break_on_first_line=trueValues: String or empty
Purpose: Value to trigger debugging when present
Examples:
; Trigger on specific value
xdebug.trigger_value=debug
; Then use: php script.php?debug=1
; Trigger on any value
xdebug.trigger_value=
; Different identifier
xdebug.trigger_value=xdebug
; Then use: php script.php?xdebug=anythingValues: GET, POST, COOKIE, or empty
Purpose: Which superglobal contains trigger value
Examples:
; Trigger via GET parameter
xdebug.trigger=GET
; Trigger via POST
xdebug.trigger=POST
; Trigger via COOKIE
xdebug.trigger=COOKIE
; Trigger via any method
xdebug.trigger=Values: File path
Purpose: Where to write Xdebug debug log
Examples:
; Linux/macOS
xdebug.log=/tmp/xdebug.log
; Windows
xdebug.log=C:\temp\xdebug.log
; Relative (in PHP ini dir)
xdebug.log=xdebug.logValues: 0-10 (verbosity level)
Default: 5
Levels:
- 0 = No logging
- 5 = Normal logging
- 10 = Very verbose
Example:
xdebug.log_level=10 ; Maximum verbosityValues: Integer (stack depth)
Default: 256
Purpose: Maximum recursion depth before stopping
Example:
xdebug.max_nesting_level=512Values: true/false
Default: false
Purpose: Auto-detect client host from HTTP headers
Example:
xdebug.discover_client_host=true
xdebug.client_discovery_header=HTTP_X_FORWARDED_FORValues: Integer (nesting depth)
Default: 5
Purpose: Maximum depth when displaying variables
Example:
xdebug.var_display_max_depth=10Values: Integer (bytes)
Default: 65536
Purpose: Maximum data size for variable display
Example:
xdebug.var_display_max_data=100000Values: Integer (number of elements)
Default: 100
Purpose: Maximum array/object elements to show
Example:
xdebug.var_display_max_children=500Debian/Ubuntu:
# Install
sudo apt-get install php-xdebug
# php.ini location
/etc/php/X.Y/cli/php.ini
/etc/php/X.Y/fpm/php.ini
/etc/php/X.Y/apache2/php.iniCentOS/RHEL:
# Install
sudo yum install php-pecl-xdebug
# php.ini location
/etc/php.iniHomebrew:
# Install Xdebug
brew install php-xdebug
# php.ini location
/usr/local/etc/php/X.Y/php.iniXAMPP:
C:\xampp\php\php.ini
WAMP:
C:\wamp\bin\php\phpX.Y.Z\php.ini
FROM php:8.1-cli
RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.idekey=xdebug-mcp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.iniversion: '3'
services:
app:
build: .
environment:
XDEBUG_MODE: debug
XDEBUG_CLIENT_HOST: debugger
XDEBUG_CLIENT_PORT: 9003
XDEBUG_IDE_KEY: xdebug-mcp
debugger:
image: node:18
command: npm install -g xdebug-mcp && xdebug-mcp
ports:
- "9003:9003"[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9003
xdebug.idekey=xdebug-mcp
xdebug.log=/tmp/xdebug.log[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=/tmp/xdebug.sock
xdebug.client_port=0
xdebug.idekey=xdebug-mcp
xdebug.log=/tmp/xdebug.log[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=192.168.1.100 ; Your machine IP
xdebug.client_port=9003
xdebug.discover_client_host=true
xdebug.idekey=xdebug-mcp[xdebug]
zend_extension=xdebug
xdebug.mode=profile
xdebug.profiler_output_dir=/tmp
xdebug.profiler_enable=1[xdebug]
zend_extension=xdebug
xdebug.mode=coverage[xdebug]
xdebug.mode=off
; Or don't load extension
; zend_extension=xdebug# Show all Xdebug settings
php -i | grep -A 30 "xdebug"
# Check specific setting
php -r "echo ini_get('xdebug.mode');"
# Verify extension loaded
php -m | grep xdebug# Simple test
php -r "echo 'Xdebug loaded: ' . extension_loaded('xdebug') ? 'yes' : 'no';"[xdebug]
xdebug.max_nesting_level=512 ; Allow deep recursion
xdebug.var_display_max_depth=10 ; Show more nested data
xdebug.var_display_max_children=500 ; More array elements[xdebug]
xdebug.mode=off ; Disable completely[xdebug]
xdebug.mode=debug
xdebug.trigger_value=debug ; Trigger on GET param
xdebug.trigger=GET ; Triggered via ?debug=1# Show where php.ini is located
php -i | grep "php.ini"
# Show all INI settings
php -i | grep "ini"
# Check specific setting
php -i | grep "xdebug.client_port"# PHP CLI (automatic)
php script.php
# PHP-FPM
sudo systemctl restart php-fpm
# Apache
sudo systemctl restart apache2
# Nginx (with PHP-FPM)
sudo systemctl restart php-fpm| Mistake | Fix |
|---|---|
xdebug.mode=on |
Should be debug, profile, etc. |
Missing zend_extension=xdebug
|
Add to php.ini |
| Wrong port in php.ini and server | Must match |
| Firewall blocking port | Allow port 9003 |
| Socket path not writable | Check permissions |
xdebug.client_port=9003 with socket |
Should be 0
|
xdebug.client_host=/path with TCP |
Should be IP/hostname |
[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9003
xdebug.break_on_first_line=0
xdebug.idekey=xdebug-mcp
xdebug.log=/tmp/xdebug.log
xdebug.log_level=5[xdebug]
zend_extension=xdebug
xdebug.mode=profile,debug
xdebug.client_host=localhost
xdebug.client_port=9003
xdebug.profiler_output_dir=/tmp/xdebug-profile[xdebug]
zend_extension=xdebug
xdebug.mode=coverage,debug
xdebug.client_host=localhost
xdebug.client_port=9003