Logo di PHP Xdebug MCP Server

PHP Xdebug MCP Server

Community
koriym

Enable AI to debug PHP with Xdebug

Autorekoriym
Repositoryxdebug-mcp
LinguaPHP
Fork
9
Stelle
60
Strumenti disponibili
0
Tipo di trasportostdio
Categorie
Link
  • Collega gli strumenti ai flussi di lavoro IA

    PHP Xdebug MCP Server mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    60 stelle e 9 fork nel repository collegato.

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.

Installazione

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

Usa MCP PHP Xdebug MCP Server con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso PHP Xdebug MCP Server, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi PHP Xdebug MCP Server come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di PHP Xdebug MCP Server.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "xdebug-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di PHP Xdebug MCP Server, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di PHP Xdebug MCP Server.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare PHP Xdebug MCP Server per aiutarmi con questa attività?
PHP Xdebug MCP Server
Certo. Ho letto.
Ecco cosa ho trovato con PHP Xdebug MCP Server.

Domande frequenti

A cosa serve il server MCP PHP Xdebug MCP Server?

PHP Xdebug MCP Server è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare PHP Xdebug MCP Server MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare PHP Xdebug MCP Server con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP PHP Xdebug MCP Server con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando PHP Xdebug MCP Server, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego PHP Xdebug MCP Server MCP a TypingMind?

PHP Xdebug MCP Server funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre PHP Xdebug MCP Server MCP in TypingMind?

PHP Xdebug MCP Server mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare PHP Xdebug MCP Server MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se PHP Xdebug MCP Server richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇