-
Notifications
You must be signed in to change notification settings - Fork 7
Getting Started
Welcome! This guide will help you set up the Xdebug MCP Server in just a few minutes.
- Node.js 18.0.0 or higher
- npm or yarn
- PHP 7.0+ with Xdebug extension
- Basic command line knowledge
npm install -g xdebug-mcpOr using yarn:
yarn global add xdebug-mcpxdebug-mcp --versionExpected output:
xdebug-mcp v1.2.1
Using PECL (Recommended):
pecl install xdebugUbuntu/Debian:
sudo apt-get install php-xdebugmacOS (Homebrew):
brew install php-xdebugWindows: Download from xdebug.org/download
Find your php.ini file:
php --iniAdd Xdebug configuration:
[xdebug]
zend_extension=xdebug
; Enable debug mode
xdebug.mode=debug
; Connection settings
xdebug.client_host=localhost
xdebug.client_port=9003
; IDE Key (identifier)
xdebug.idekey=xdebug-mcp
; Logging (optional)
xdebug.log=/tmp/xdebug.log
xdebug.log_level=10php -v | grep XdebugShould output:
with Xdebug X.X.X
xdebug-mcpExpected output:
[INFO] Xdebug MCP Server listening on localhost:9003
[INFO] Server ready for debugging
Save as test.php:
<?php
function greet($name) {
$message = "Hello, " . $name;
return $message;
}
$result = greet("World");
echo $result;php test.phpThe script will pause at breakpoints when you set them via the MCP client.
Once the MCP Server is running, configure your MCP client to connect:
{
"mcpServers": {
"xdebug": {
"command": "xdebug-mcp"
}
}
}Then use Claude with the debugging tools!
Works out of the box on all platforms:
xdebug-mcp
# Listens on localhost:9003For Linux/macOS:
XDEBUG_SOCKET_PATH=/tmp/xdebug.sock xdebug-mcpUpdate php.ini:
xdebug.client_host=/tmp/xdebug.sock
xdebug.client_port=0version: '3'
services:
app:
image: php:8.1-cli
volumes:
- ./app:/app
working_dir: /app
command: php app.php
debugger:
image: node:18
command: npm install -g xdebug-mcp && xdebug-mcp
ports:
- "9003:9003"Run with:
docker-compose upMake sure npm is in your PATH:
npm list -g xdebug-mcpIf not installed, reinstall:
npm install -g xdebug-mcpUse a different port:
XDEBUG_PORT=9004 xdebug-mcpUpdate php.ini:
xdebug.client_port=9004- Check php.ini:
php -i | grep -i xdebug- Check Xdebug log:
tail -f /tmp/xdebug.log- Verify server listening:
lsof -i :9003Configure server behavior with environment variables:
# TCP mode (default)
XDEBUG_HOST=0.0.0.0
XDEBUG_PORT=9003
# Unix socket mode
XDEBUG_SOCKET_PATH=/tmp/xdebug.sock
# Logging
DEBUG=xdebug-mcpAfter installation, you'll have:
~/.npm-global/lib/node_modules/xdebug-mcp/
├── dist/
│ ├── index.js
│ ├── config.js
│ └── ...
├── package.json
└── README.md
- Read Debugging Guide - Learn how to debug PHP code
- Explore Understanding Xdebug - Understand how Xdebug works
- Check Tools & Commands - See what debugging tools are available
- Setup Connection Modes - Choose TCP or Unix socket
- Xdebug Docs: xdebug.org
- GitHub Issues: github.com/kpanuragh/xdebug-mcp/issues
- See Troubleshooting page for common issues
| Component | Requirement |
|---|---|
| Node.js | 18.0.0+ |
| PHP | 7.0+ |
| Xdebug | 2.9+ or 3.0+ |
| OS | Linux, macOS, Windows |
| RAM | 100MB minimum |
| Disk | 50MB |
# Install
npm install -g xdebug-mcp
# Start server
xdebug-mcp
# TCP mode on custom port
XDEBUG_PORT=9004 xdebug-mcp
# Unix socket mode
XDEBUG_SOCKET_PATH=/tmp/xdebug.sock xdebug-mcp
# Debug mode (verbose logging)
DEBUG=xdebug-mcp xdebug-mcp
# Stop server
Ctrl+CYou're all set! 🎉
- Start the server:
xdebug-mcp - Configure PHP with Xdebug
- Create a test script
- Set breakpoints and debug!
Have questions? Check the Troubleshooting page or visit the GitHub repository.