Logo von PHP Xdebug MCP Server

PHP Xdebug MCP Server

Community
koriym

Enable AI to debug PHP with Xdebug

Herausgeberkoriym
Repositoryxdebug-mcp
SprachePHP
Forks
9
Sterne
60
Verfügbare Tools
0
Transporttypstdio
Kategorien
Links
  • Tools mit KI-Workflows verbinden

    PHP Xdebug MCP Server stellt MCP-Funktionen bereit, die kompatible KI-Clients und Agenten nutzen können.

  • 0 verfügbare Tools

    Sehen Sie sich unten die aufrufbaren Aktionen an, einschließlich Namen und Beschreibungen, sofern der Server diese bereitstellt.

  • Konfiguration zum Kopieren

    Nutzen Sie die Installationsbeispiele, um diesen Server in Ihrem bevorzugten MCP-Client zu konfigurieren.

  • Open-Source-Kennzahlen

    60 Sterne und 9 Forks im verlinkten Repository.

Xdebug MCP

Debug PHP with Runtime Data — No var_dump(), No Guesswork

Trace-based debugging for PHP, built on Xdebug. Drive the tools from the CLI, or let an AI assistant run the core tools through plugin, Skill, or MCP integration.

AI Native Runtime Data var_dump


Natural Language Debugging

Just tell your AI assistant what you want:

English:

text
"Debug script.php and find why $user is null at line 42"
"Profile api.php and find the performance bottleneck"
"Trace the authentication flow in login.php"
"Check test coverage for UserService"

日本語:

text
"script.phpをデバッグして、42行目で$userがnullになる原因を調べて"
"api.phpのパフォーマンスボトルネックを見つけて"
"login.phpの認証フローをトレースして"
"UserServiceのテストカバレッジを確認して"

When connected through the plugin, Skill, or an MCP-capable client, the AI can select the appropriate tool, execute it, and analyze the results.

Requirements

  • PHP 8.2+
  • Xdebug 3.x extension (installed, but not enabled by default)
  • Optional: an AI assistant (Claude Code plugin, Codex Skill, or any MCP-capable client)

💡 Performance Tip: Keep Xdebug disabled in php.ini for daily use. This tool loads Xdebug on-demand only when needed.

Quick Start

1. Install

bash
composer global require koriym/xdebug-mcp

2. Verify Xdebug

bash
"$(composer global config bin-dir --absolute --quiet)/check-env"

3. (Optional) Wire up an AI assistant

Two integrations are available. We recommend the Skill: these tools are stateless one-shot CLI commands by design, so letting the agent run them directly — guided by the Skill's usage notes — is the simplest and most accurate path. Choose MCP when your client has no shell access or no Skill support.

Skill (recommended)MCP server
How it worksThe agent reads SKILL.md and runs the CLI tools directlyThe client calls the tools over JSON-RPC (stdio)
SetupPlugin install, or copy one directoryRegister in the client's MCP config
Best forAI coding agents with shell access (Claude Code, Codex, ...)MCP-capable clients without shell/Skill support (e.g. Claude Desktop)

Claude Code — install the plugin (which bundles the Skill):

text
/plugin marketplace add koriym/xdebug-mcp
/plugin install xdebug@xdebug-mcp

Codex CLI — install the Skill:

bash
git clone --depth 1 https://github.com/koriym/xdebug-mcp.git /tmp/xdebug-mcp
mkdir -p ~/.codex/skills
cp -r /tmp/xdebug-mcp/skills/xdebug ~/.codex/skills/

Any MCP-capable client — see MCP Configuration below.

You can skip this step entirely and use the CLI tools directly.

4. Try it

text
# Download demo files
git clone --depth 1 https://github.com/koriym/xdebug-mcp.git /tmp/xdebug-demo

# Ask Claude to debug
"Debug /tmp/xdebug-demo/demo/buggy.php and find the bugs"

Or use the skill directly:

text
/xdebug

Try CLI Tools

Run the demo examples to see each tool in action:

bash
# Debug buggy code with breakpoints (JSON output)
./bin/xstep --break="demo/buggy.php:22" -- php demo/buggy.php

# Trace execution flow
./bin/xtrace --json --context="Debug demo" -- php demo/buggy.php

# Profile performance bottlenecks
./bin/xprofile --json -- php demo/slow.php

# Analyze code coverage (raw mode for plain PHP scripts)
./bin/xcoverage --json --raw -- php demo/coverage.php

# Get stack trace at breakpoint
./bin/xback --break="demo/buggy.php:44" -- php demo/buggy.php

# Compare variable states with different inputs
./bin/xcompare --break="demo/buggy.php:22" --run-a="php demo/buggy.php 10" --run-b="php demo/buggy.php 0"

# Compare current code vs another branch
./bin/xcompare --break="src/calc.php:25" --run="php src/calc.php 10" --compare-with=main

Each command outputs structured JSON that AI can analyze to provide debugging insights. xtrace, xprofile, and xcoverage print text unless --json is given; the other tools print JSON by default.

How It Works

No var_dump(). No code modification. No guesswork.

Available Tools

ToolPurposeExample Prompt
xstepBreakpoint debugging, variable inspection"Stop at line 42 and show me the variables"
xtraceExecution flow analysis"Trace how the request flows through the app"
xprofilePerformance profiling"Find what's making this endpoint slow"
xcoverageCode coverage analysis"Which lines aren't covered by tests?"
xbackCall stack at breakpoint"Show me how we got to this error"
xcompareCompare variable states across two runs"Compare input 10 vs 0" or "Compare with main branch"

All tools in this table are available both as CLI commands and as MCP tools. xrepl (the interactive debugger below) is CLI-only.

CLI Usage

For direct command-line usage without AI:

bash
# Trace execution
xtrace -- php script.php

# Profile performance
xprofile -- php api.php

# Debug with conditional breakpoint
xstep --break='script.php:42:$user==null' -- php script.php

# Pretty-print JSON, truncate long values, limit nesting depth
xstep --break='script.php:42' --pretty --max-value-bytes=200 --max-depth=3 -- php script.php

# Code coverage
xcoverage -- vendor/bin/phpunit

# Stack trace at breakpoint
xback --break='app.php:50' -- php app.php

# Compare variables at breakpoint with different inputs
xcompare --break='calc.php:25' --run-a='php calc.php 10' --run-b='php calc.php 0'

# Compare current code vs main branch
xcompare --break='calc.php:25' --run='php calc.php 10' --compare-with=main

Run --help on any tool for detailed options.

Note on xcompare commands: the --run-a, --run-b, and --run values are executed through the shell so that quoting, redirection, and environment variables behave as users expect. Only pass trusted input to these options.

Note on --steps: xcompare defaults to --steps=1, since the comparison only needs the variable snapshot at the breakpoint. Pass --steps=N explicitly (e.g. --steps=100) if you want to see how execution diverges between the two runs after the break.

Schema-Backed JSON Output

Every tool emits JSON with a schema URL ($schema, or schema for xtrace and xprofile), so the output is machine-verifiable and self-describing — no log-string parsing needed. xstep, xback, and xcompare print JSON by default; xtrace, xprofile, and xcoverage with --json:

json
{
  "$schema": "https://koriym.github.io/xdebug-mcp/schemas/xstep.json",
  "breaks": [
    {
      "stack": [{"function": "calculateSum", "file": "buggy.php", "line": 22}],
      "variables": {"$a": "int: 10", "$b": "int: 5"}
    }
  ],
  "trace": { "...": "..." }
}

Schemas live under docs/schemas/. AI assistants — and humans — can verify exactly what each tool captured.

MCP Configuration

For AI coding agents with shell access, the Skill is the recommended integration. Register the MCP server instead when your client supports MCP but cannot run shell commands or Skills (e.g. Claude Desktop), or when you want a schema-validated tool interface shared across MCP clients.

Add xdebug-mcp to the client's MCP config (e.g. .mcp.json). MCP exposes all one-shot tools: xtrace, xprofile, xstep, xcoverage, xback, and xcompare:

json
{
  "mcpServers": {
    "xdebug": {
      "command": "php",
      "args": ["/ABSOLUTE/PATH/TO/xdebug-mcp"]
    }
  }
}

Find the path with which xdebug-mcp. Restart your client after editing the config.

The server speaks the stateless 2026-07-28 protocol revision (handshake-less, discoverable via server/discover) and keeps the legacy initialize handshake for clients on 2025-11-25 and earlier — both over stdio.

Interactive REPL

For hands-on debugging without AI, use the interactive debugger (xrepl):

bash
xrepl --break="script.php:42" -- php script.php

Commands:

CommandDescription
sStep into function
oStep over line
outStep out of function
cContinue execution
p <var>Print variable (e.g., p $user)
btShow backtrace
lShow current location (stack and variables)
qQuit debugger

Docker Support

All tools work with Docker, Podman, and Kubectl:

bash
xstep --break="/app/script.php:42" -- \
  docker compose run --rm php php /app/script.php

xtrace -- docker compose run --rm php php /app/script.php

The tools automatically detect container runtime and configure Xdebug networking.

See tests/docker/README.md for details.

Debugging Legacy PHP (7.x / 5.x)

While xdebug-mcp itself requires PHP 8.2+, it can debug older PHP versions as long as a compatible Xdebug 3.x release is installed on the target PHP. Simply specify the target PHP binary after --:

bash
# Debug PHP 7.2 code
xtrace -- /opt/homebrew/opt/php@7.2/bin/php legacy_app.php
xprofile -- /opt/homebrew/opt/php@7.2/bin/php legacy_app.php
xstep --break="legacy_app.php:30" -- /opt/homebrew/opt/php@7.2/bin/php legacy_app.php

The tool runs on your modern PHP while the target script executes on the specified PHP binary — provided the specified PHP has a compatible Xdebug 3.x installed. No Docker required. Check the compatibility table below before trying older PHP binaries.

xback and xcoverage also accept --php=PATH to pick the target binary while keeping php in the command:

bash
xback --break="legacy_app.php:30" --php=/path/to/php7.2 -- php legacy_app.php

When the target is named explicitly — an absolute path, a versioned name such as php8.2, or --php= — it is asked about its own Xdebug: if its php.ini already loads Xdebug, nothing is injected; otherwise an Xdebug build matching the target's version is looked up. An extension built for another PHP version is never pushed into it, and when no matching build exists the run fails with a message naming the target version instead of producing a broken session. A bare php is assumed to be the interpreter running the tool, so if your PATH resolves php to a different version than the one running xdebug-mcp, name that interpreter explicitly.

Xdebug 3.x Compatibility

XdebugSupported PHP
3.0-3.1PHP 5.4 - 8.0
3.2PHP 5.6 - 8.3
3.3PHP 7.0 - 8.4
3.4PHP 7.4 - 8.5

See Xdebug compatibility for details.

For Developers

See tests/ai/README.md for tool discoverability testing.

AI Native Design

This tool is designed specifically for AI consumption, not adapted from human interfaces.

Debugger for HumansAI Native (this tool)
Step-by-step interactionOne-shot batch execution
Session management requiredStateless CLI
Multiple tool callsSingle command, complete data
Manual log placementAutomatic full trace

Why it matters:

  • Fewer tokens: One command returns all data vs. many back-and-forth calls
  • No session errors: Stateless design eliminates timeout/connection issues
  • Comprehensive data: xtrace captures everything; AI filters what it needs

See Also

Looking for a different approach? kpanuragh/xdebug-mcp offers 41 MCP tools with session-based interactive debugging — ideal if you prefer step-by-step control.

Why "xdebug-mcp"?

This project started as an MCP (Model Context Protocol) server for AI-powered PHP debugging. MCP is still supported for any MCP-capable client, but the CLI is now the primary interface. The MCP tools (xstep, xtrace, xprofile, xcoverage, xback, xcompare) also work as standalone CLI commands; xrepl is CLI-only.

Resources


Stop debugging blind. Just ask your AI.

Installation

TypingMind
{
  "mcpServers": {
    "xdebug-mcp": {
      "command": "php",
      "args": [
        "/path/to/your/xdebug-mcp/bin/xdebug-mcp"
      ]
    }
  }
}

PHP Xdebug MCP Server MCP mit mehreren KI-Modellen nutzen

TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. Sobald PHP Xdebug MCP Server verbunden ist, können Sie die Integration mit verschiedenen KI-Modellen in TypingMind verwenden, statt sie für jedes Modell separat einzurichten. Diese MCP-Integration läuft lokal über den TypingMind-MCP-Konnektor auf Ihrem Gerät.

Einrichtungsanleitung für den lokalen Konnektor

Nutzen Sie diese Option, wenn der MCP-Server Zugriff auf lokale Dateien, Apps oder private Ressourcen auf Ihrem Computer benötigt.

1

MCP-Einstellungen öffnen

Gehen Sie in TypingMind zu „Einstellungen“, „Erweiterte Einstellungen“ und dann „Model Context Protocol“ und wählen Sie „Konnektor-Setup“.

  1. Öffnen Sie TypingMind in Ihrem Browser.
  2. Klicken Sie auf das Symbol „Optionen“.
  3. Gehen Sie zu „Erweiterte Einstellungen“.
  4. Öffnen Sie den Abschnitt „Model Context Protocol“.
  5. Klicken Sie auf „Konnektor-Setup“ und wählen Sie „Dieses Gerät“.
Einrichtungsbildschirm des TypingMind-MCP-Konnektors mit ausgewählter Option „Dieses Gerät“
2

Konnektor-Befehl ausführen

Wählen Sie „Dieses Gerät“, kopieren Sie den Befehl aus TypingMind und führen Sie ihn im Terminal aus. Lassen Sie den Prozess laufen, solange Sie MCP verwenden.

  1. Kopieren Sie den in TypingMind angezeigten Einrichtungsbefehl.
  2. Öffnen Sie unter macOS Terminal bzw. unter Windows Windows Terminal.
  3. Fügen Sie den Befehl ein und führen Sie ihn aus.
  4. Bestätigen Sie die Paketinstallation, wenn Sie im Terminal zum Fortfahren aufgefordert werden.
  5. Lassen Sie das Terminalfenster geöffnet und den Prozess darin laufen, solange Sie MCP-Tools verwenden.
3

PHP Xdebug MCP Server als Server hinzufügen

Wenn der Konnektorstatus „Bereit“ anzeigt, klicken Sie auf „Server ändern“ und fügen Sie die MCP-Server-Konfiguration ein.

  1. Warten Sie, bis der Konnektorstatus „Bereit“ anzeigt.
  2. Klicken Sie auf „Server ändern“.
  3. Fügen Sie die MCP-Server-Konfiguration für PHP Xdebug MCP Server ein.
  4. Speichern Sie die Serverliste.
  5. Aktualisieren Sie die Ansicht, um bei Bedarf zu prüfen, ob der Konnektor weiterhin bereit ist.
MCP-Einstellungen in TypingMind mit aktivem Server und der Schaltfläche „Server ändern“
{
  "mcpServers": {
    "xdebug-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Verbindung modellübergreifend nutzen

Speichern Sie die Serverliste, öffnen Sie „Plugins“ und aktivieren Sie die MCP-Tools von PHP Xdebug MCP Server. Wählen Sie dann ein beliebiges unterstütztes KI-Modell in TypingMind und verwenden Sie die Tools im Chat oder weisen Sie sie einem KI-Agenten zu.

  1. Öffnen Sie die Seite „Plugins“ in TypingMind.
  2. Aktivieren Sie die MCP-Tools von PHP Xdebug MCP Server.
  3. Starten Sie einen Chat und wählen Sie das KI-Modell, das Sie verwenden möchten.
  4. Nutzen Sie die MCP-Tools im Chat oder weisen Sie sie einem KI-Agenten zu.
  5. Wechseln Sie bei Bedarf zu einem anderen KI-Modell, ohne die MCP-Verbindung erneut herzustellen.
TypingMind-Chat mit aktivierten MCP-Tools und einem ausgewählten KI-Modell
Können Sie mir mit PHP Xdebug MCP Server bei dieser Aufgabe helfen?
PHP Xdebug MCP Server
Gerne. Ich habe es gelesen.
Das habe ich mit PHP Xdebug MCP Server gefunden.

Häufig gestellte Fragen

Wofür wird der MCP-Server PHP Xdebug MCP Server verwendet?

PHP Xdebug MCP Server ist ein MCP-Server, über den kompatible KI-Clients auf externe Tools und Kontext zugreifen können. In TypingMind können Sie diesen MCP-Server einmal hinzufügen und seine Tools in Ihrem KI-Arbeitsbereich verfügbar machen.

Kann ich PHP Xdebug MCP Server MCP mit mehreren KI-Modellen in TypingMind verwenden?

Ja. TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. So können Sie PHP Xdebug MCP Server mit verschiedenen KI-Modellen wie Claude, ChatGPT, Gemini oder anderen in TypingMind konfigurierten Modellen verwenden, ohne den MCP-Server für jedes Modell separat einzurichten.

Warum PHP Xdebug MCP Server MCP mit TypingMind nutzen?

TypingMind ist eine der besten Oberflächen für LLM-Chats, da es mehrere KI-Modelle, Prompts, Plugins, KI-Agenten, API-Schlüssel und MCP-Tools in einem Arbeitsbereich vereint. Sobald PHP Xdebug MCP Server verbunden ist, können Sie die zugehörigen MCP-Tools mit Ihren bevorzugten Modellen nutzen und Ihre Chat-Abläufe in TypingMind übersichtlich organisieren.

Wie verbinde ich PHP Xdebug MCP Server MCP mit TypingMind?

PHP Xdebug MCP Server wird über den lokalen MCP-Konnektor von TypingMind angebunden. Das ist die beste Wahl, wenn der MCP-Server auf lokale Dateien, Desktop-Apps, Befehlszeilentools oder private Ressourcen auf Ihrem Computer zugreifen muss.

Welche Tools stellt PHP Xdebug MCP Server MCP in TypingMind bereit?

PHP Xdebug MCP Server stellt MCP-Funktionen bereit, die Sie auf der Plugins-Seite in TypingMind aktivieren und im Chat verwenden oder KI-Agenten zuweisen können.

Muss ich meine API-Schlüssel mit TypingMind teilen, um PHP Xdebug MCP Server MCP zu verwenden?

Nein. TypingMind arbeitet vorrangig lokal, sodass Sie die Kontrolle über Ihre Modellanbieter, API-Schlüssel, Prompts und MCP-Konfiguration behalten. Falls PHP Xdebug MCP Server eine Authentifizierung erfordert, fügen Sie beim Erstellen der Verbindung die erforderlichen Header, OAuth-Einstellungen oder die lokale Konfiguration für diesen MCP-Server hinzu.

Ähnliche MCP-Server

Alle

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇