mcp-php-debugbar
Provides tools for inspecting Laravel Debugbar data from Laravel applications, including request health, SQL queries, exceptions, logs, and file/line-specific fix suggestions.
Provides tools for inspecting PHP DebugBar data from running PHP applications, including exceptions, SQL queries, timelines, logs, and source-level debugging context.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-php-debugbar Debug the /users page and show the exact PHP file and line causing the error"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-php-debugbar
AI-powered PHP debugging via Model Context Protocol.
Connects PHP DebugBar and Laravel Debugbar to AI assistants. The AI sees exceptions, SQL queries, timelines and logs from your running app — reads the actual PHP source files and suggests concrete fixes with exact line numbers.
Supported clients: Cursor · VS Code · Claude Desktop · OpenAI Codex
Coming soon: Antigravity
How it works
Your PHP/Laravel app (localhost:8000)
│ phpdebugbar-id header
▼
mcp-php-debugbar (Node.js MCP Server, stdio)
│ 37 tools
▼
AI assistant (Cursor / VS Code / Claude / Codex)
│ reads PHP files, analyzes issues, applies fixes
▼
Developer gets: file:line + code context + ready-to-apply fixOne command:
Debug /users pageThe AI calls debugbar_auto_debug → health score, every issue with the exact PHP file + line number + surrounding code + a concrete fix.
Related MCP server: Laravel AI MCP Server
Requirements
Node.js 18+
PHP 7.4+ with a running dev server
PHP DebugBar v3.5+ or Laravel Debugbar v4.1+
Step 1 — Install PHP DebugBar in your project
Laravel project
composer require fruitcake/laravel-debugbar --devIn your Laravel .env:
APP_DEBUG=true
DEBUGBAR_ENABLED=trueIn config/debugbar.php:
'storage' => [
'enabled' => true,
'open' => true, // enables the /_debugbar/open endpoint
'driver' => 'file',
'path' => storage_path('debugbar'),
],Vanilla PHP project
composer require php-debugbar/php-debugbaruse DebugBar\DebugBar;
use DebugBar\Storage\FileStorage;
$debugbar = new DebugBar();
$debugbar->setStorage(new FileStorage(__DIR__ . '/storage/debugbar'));
$debugbar->sendDataInHeaders(); // sends the phpdebugbar-id headerAdd /debugbar/open.php:
<?php
require __DIR__ . '/../vendor/autoload.php';
// ... initialize debugbar ...
$handler = new DebugBar\OpenHandler($debugbar);
$handler->handle();Auto-detection: if
PROJECT_ROOTpoints to a Laravel project (anartisanfile is present), the server automatically uses/_debugbar/openand sets type tolaravel. For vanilla PHP it uses/debugbar/open.
Step 2 — Install mcp-php-debugbar
git clone https://github.com/movinginfo/mcp-php-debugbar.git
cd mcp-php-debugbar
npm install
npm run buildStep 3 — Connect to your AI client
Cursor
Option A — per project (recommended)
Create or edit .cursor/mcp.json in the root of your PHP project:
{
"mcpServers": {
"php-debugbar": {
"command": "node",
"args": ["/absolute/path/to/mcp-php-debugbar/dist/index.js"],
"env": {
"DEBUGBAR_BASE_URL": "http://localhost:8000",
"DEBUGBAR_TYPE": "auto",
"PROJECT_ROOT": "/absolute/path/to/your/php-project"
}
}
}
}Option B — global (all projects)
File: ~/.cursor/mcp.json
{
"mcpServers": {
"php-debugbar": {
"command": "node",
"args": ["/absolute/path/to/mcp-php-debugbar/dist/index.js"],
"env": {
"DEBUGBAR_BASE_URL": "http://localhost:8000",
"DEBUGBAR_TYPE": "auto",
"PROJECT_ROOT": ""
}
}
}
}In the global setup you can pass
PROJECT_ROOTat connect time:Connect to http://localhost:8000, project root is /var/www/myapp
Verify:
Restart Cursor → Settings → MCP → php-debugbar should appear with status connected.
Windows example:
{
"mcpServers": {
"php-debugbar": {
"command": "node",
"args": ["C:/projects/mcp-php-debugbar/dist/index.js"],
"env": {
"DEBUGBAR_BASE_URL": "http://localhost:8000",
"DEBUGBAR_TYPE": "auto",
"PROJECT_ROOT": "C:/projects/my-laravel-app"
}
}
}
}VS Code
Requires VS Code 1.99+ with the GitHub Copilot Chat extension.
Step 1. Enable MCP support in VS Code settings:
// .vscode/settings.json
{
"chat.mcp.enabled": true,
"chat.agent.enabled": true
}Step 2. Create .vscode/mcp.json in the root of your PHP project:
{
"servers": {
"php-debugbar": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/mcp-php-debugbar/dist/index.js"],
"env": {
"DEBUGBAR_BASE_URL": "http://localhost:8000",
"DEBUGBAR_TYPE": "auto",
"PROJECT_ROOT": "/absolute/path/to/your/php-project"
}
}
}
}If you cloned this repo and open it in VS Code, both .vscode/mcp.json and .vscode/settings.json are already included — ${workspaceFolder} resolves automatically.
Windows example:
{
"servers": {
"php-debugbar": {
"type": "stdio",
"command": "node",
"args": ["C:/projects/mcp-php-debugbar/dist/index.js"],
"env": {
"DEBUGBAR_BASE_URL": "http://localhost:8000",
"DEBUGBAR_TYPE": "auto",
"PROJECT_ROOT": "C:/projects/my-laravel-app"
}
}
}
}Step 3. Restart VS Code → open GitHub Copilot Chat → switch to Agent mode → php-debugbar will appear in the tools list.
Note: VS Code uses the key
"servers"in.vscode/mcp.json, while Cursor and Claude use"mcpServers".
Run the Example project from VS Code:
Ctrl+Shift+P → Tasks: Run Task → select:
Task | What it does |
Start PHP Example Server | Runs |
Run MCP Smoke Test | Runs the full test of all 37 tools |
Run Direct DebugBar Test | Direct test without MCP — outputs data with code and fixes |
Build MCP Server | Recompile TypeScript |
Or press F5 → select a debug configuration:
Debug MCP Server — launches the MCP server with the Node.js debugger
Run Smoke Test
Run Direct DebugBar Test
Claude Desktop
macOS — open or create:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows — open or create:
%APPDATA%\Claude\claude_desktop_config.jsonLinux — open or create:
~/.config/Claude/claude_desktop_config.jsonFile contents:
{
"mcpServers": {
"php-debugbar": {
"command": "node",
"args": ["/absolute/path/to/mcp-php-debugbar/dist/index.js"],
"env": {
"DEBUGBAR_BASE_URL": "http://localhost:8000",
"DEBUGBAR_TYPE": "auto",
"PROJECT_ROOT": "/absolute/path/to/your/php-project"
}
}
}
}If mcpServers already exists in your config, just add the "php-debugbar" block inside it.
Restart Claude Desktop. A 🔌 icon will appear in the bottom-left corner showing the number of connected MCP servers.
Windows example:
{
"mcpServers": {
"php-debugbar": {
"command": "node",
"args": ["C:/projects/mcp-php-debugbar/dist/index.js"],
"env": {
"DEBUGBAR_BASE_URL": "http://localhost:8000",
"DEBUGBAR_TYPE": "auto",
"PROJECT_ROOT": "C:/projects/my-laravel-app"
}
}
}
}Antigravity
🚧 Full native integration is in development. Will be added in the next release.
In the meantime you can use it via the standard stdio transport:
DEBUGBAR_BASE_URL=http://localhost:8000 \
PROJECT_ROOT=/path/to/your/php-project \
node /path/to/mcp-php-debugbar/dist/index.jsStep 4 — Start your server and connect
Laravel
# 1. Start Laravel
php artisan serve
# 2. In the AI chat:
# "Connect debugbar to http://localhost:8000"
# The server auto-detects Laravel via the artisan file
# and uses /_debugbar/openVanilla PHP
# 1. Start PHP dev server
php -S localhost:8000 -t public
# 2. In the AI chat:
# "Connect debugbar to http://localhost:8000"Usage
Basic workflow
1. Start your PHP/Laravel server
2. In the AI chat: "Connect debugbar to http://localhost:8000"
3. Open your browser and visit the page you want to debug
4. Ask: "Debug the last request" or "Debug /users endpoint"Example AI conversation
You: Debug /users page
AI: [calls debugbar_auto_debug(url="/users")]
🐛 DEBUG REPORT: GET /users
Health score: 35/100 [████░░░░░░]
Duration: 245ms | SQL: 12 queries | Exceptions: 0
ISSUE 1/2: 🔴 [N+1] "posts" queried 10×
📍 app/Http/Controllers/UserController.php:34
30 | $users = User::all();
31 | foreach ($users as $user) {
>>> 34 | $posts = Post::where('user_id', $user->id)->get();
35 | }
💡 FIX:
$users = User::with('posts')->get();
You: Apply this fix
AI: [opens UserController.php, edits line 34]
✅ Fixed: replaced N+1 loop with eager loadingQuick command reference
# Connect (run once at the start)
Connect debugbar to http://localhost:8000
# One-shot debug — the main tool
Debug /page-name
Debug the last request
Debug /users and fix all issues
# Specific problems
Show all exceptions
Show N+1 queries
Fix issue #1
Fix issue #2
# Read source files
Read file app/Http/Controllers/UserController.php line 45
# Status
Debugbar status
List captured requests
Performance summary
# Laravel
Show route info
Full Laravel report
Show auth info
Show cache operationsAll 37 MCP tools
Connection
Tool | Description |
| Connect to a PHP/Laravel server |
| Disconnect |
| Connection state and request count |
| List Chrome tabs (CDP) |
| Auto-capture via Chrome DevTools |
Requests
Tool | Description |
| List all captured requests |
| Full details for a specific request |
| Make an HTTP request and capture debug data |
| Pull latest requests from the server |
| Clear the request cache |
Database
Tool | Description |
| SQL queries with duration and bindings |
| N+1 detection — repeated queries |
| Compare query counts between two requests |
Logs & Exceptions
Tool | Description |
| Log messages filtered by level |
| Exceptions with full stack traces |
Performance
Tool | Description |
| Timeline measurements |
| Request table sorted by duration / SQL count |
Laravel-specific
Tool | Description |
| Route URI, action, middleware |
| Blade templates rendered |
| Events fired and their listeners |
| Auth guards and user info |
| Eloquent model instances |
| Cache hit / miss / write / delete |
| Session data |
| Full combined Laravel report |
AI analysis — the key tools
Tool | Description |
| Analyze: N+1, slow queries, exceptions, memory |
| Health report across all captured requests |
| Prioritized fix list for the latest request |
| One-shot: fetch URL → load data → read source files → report with code and fixes |
| Focus on issue #N: source code + exact line + concrete fix |
| Read any PHP file from |
IDE integration
Tool | Description |
| Open Cursor built-in preview |
| Poll for new requests periodically |
| Stop polling |
| Auto-analyze new requests as they arrive |
| Analyze the last N requests |
| Start a webhook listener |
| Show available preview connection modes |
Environment variables (.env)
# PHP/Laravel dev server URL (required)
DEBUGBAR_BASE_URL=http://localhost:8000
# Open handler path
# Laravel: /_debugbar/open
# Vanilla PHP: /debugbar/open
DEBUGBAR_OPEN_HANDLER=/_debugbar/open
# Project type: laravel | php | auto (auto checks for artisan file)
DEBUGBAR_TYPE=auto
# Absolute path to your PHP project (enables source file reading and AI fixes)
# Examples: /var/www/myapp C:/projects/myapp /home/user/laravel-app
PROJECT_ROOT=
# Chrome remote debugging (optional — enables auto-capture on page visit)
CHROME_HOST=localhost
CHROME_PORT=9222
CHROME_AUTO_CONNECT=false
# Other
MAX_REQUESTS=100
REQUEST_TIMEOUT=10000
LOG_LEVEL=infoExample project
The Example/ folder contains a ready-to-use PHP DebugBar demo:
Home page with an intentional N+1 problem and a caught exception
/users.php— standard SQL queries/error.php— 4 different exception types/slow.php— simulated slow page (~850 ms timeline)/api.php— JSON API endpoint
# Start the example server
php -S localhost:8000 -t Example/public Example/public/router.php
# Direct test (no MCP needed)
node test/direct-debugbar.mjs
# Full MCP smoke test (all 37 tools)
node test/smoke-test.mjsDevelopment
npm run dev # run without building (tsx)
npm run build # TypeScript → dist/
npm run watch # watch mode
npm run inspect # MCP Inspector UI in the browserPublish to GitHub
cd mcp-php-debugbar
git init
git add .
git commit -m "feat: initial release"
# GitHub CLI:
gh repo create mcp-php-debugbar --public --push
# or manually:
git remote add origin https://github.com/YOUR_USERNAME/mcp-php-debugbar.git
git branch -M main
git push -u origin main
.envis in.gitignore— your local paths and secrets will not be committed.
Roadmap
PHP DebugBar v3.5
Laravel Debugbar v4.1
Auto-detection of Laravel via
artisanfilePROJECT_ROOT— source file readingdebugbar_auto_debug— one-shot debug with code contextdebugbar_fix_issue— code + fix for a specific issueN+1 detection, slow query analysis, exception analysis
Cursor support
Claude Desktop support
OpenAI Codex support
VS Code — stable support (GitHub Copilot MCP)
Antigravity — native integration
npm publish—npx mcp-php-debugbarAuto-apply fixes (write to file)
EXPLAIN analysis (missing index detection)
Xdebug integration
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Maintenance
Related MCP Connectors
Give AI coding agents access to your Vynix visual feedback, bug reports, and AI diagnosis.
Scan websites and code for security, performance and SEO issues from your AI assistant.
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Live browser debugging for AI assistants — DOM, console, network via MCP.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables AI assistants to debug PHP applications through Xdebug's DBGp protocol, providing full debugging control including breakpoints, variable inspection, stack traces, and advanced features like watch expressions and code coverage.46254 npm29MIT
- AlicenseAqualityDmaintenanceProvides AI assistants with direct access to Laravel documentation, coding rules, and implementation templates stored locally. It enables searching documentation, retrieving design system guides, and accessing domain-specific code examples to streamline Laravel development.8MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to debug code inside VS Code by setting breakpoints, stepping through execution, inspecting variables, and evaluating expressions across multiple languages.583MIT
- AlicenseCqualityDmaintenanceEnables AI assistants to connect to browser DevTools and backend debuggers for full-stack debugging, including frontend console, network, performance, and backend log analysis.1620 npm7MIT