Logo de PHP Xdebug MCP Server

PHP Xdebug MCP Server

Comunidade
koriym

Enable AI to debug PHP with Xdebug

Publicado porkoriym
Repositórioxdebug-mcp
IdiomaPHP
Forks
9
Estrelas
60
Ferramentas disponíveis
0
Tipo de transportestdio
Categorias
Links
  • Conecte ferramentas a fluxos de trabalho de IA

    PHP Xdebug MCP Server disponibiliza recursos MCP que podem ser usados por clientes e agentes de IA compatíveis.

  • 0 ferramentas disponíveis

    Confira abaixo as ações que podem ser chamadas, incluindo nomes e descrições quando fornecidos pelo servidor.

  • Configuração pronta para copiar

    Use os exemplos de instalação para configurar este servidor no seu cliente MCP preferido.

  • Indicadores da comunidade de código aberto

    60 estrelas e 9 forks no repositório vinculado.

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.

Instalação

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

Use o MCP de PHP Xdebug MCP Server com vários modelos de IA

O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho. Assim, após conectar PHP Xdebug MCP Server, é possível usá-lo com diferentes modelos de IA no TypingMind, em vez de configurá-lo separadamente para cada modelo. Este MCP é executado localmente no seu dispositivo por meio do conector MCP do TypingMind.

Guia de configuração para usar o conector local

Use esta opção quando o servidor MCP precisar acessar arquivos locais, aplicativos ou recursos privados no seu computador.

1

Abra as configurações de MCP

No TypingMind, vá até Configurações, Configurações avançadas e depois Model Context Protocol e selecione Configurar conector.

  1. Abra o TypingMind no navegador.
  2. Clique no ícone de Ajustes.
  3. Acesse Configurações avançadas.
  4. Abra a seção Model Context Protocol.
  5. Clique em Configurar conector e selecione Este dispositivo.
Tela de configuração do conector MCP do TypingMind com a opção Este dispositivo selecionada
2

Execute o comando do conector

Selecione Este dispositivo, copie o comando do TypingMind e execute-o no Terminal. Mantenha o processo em execução enquanto usa o MCP.

  1. Copie o comando de configuração exibido pelo TypingMind.
  2. Abra o Terminal no macOS ou o Windows Terminal no Windows.
  3. Cole e execute o comando.
  4. Autorize a instalação do pacote se o Terminal pedir confirmação para continuar.
  5. Mantenha o processo em execução na janela do Terminal enquanto usa as ferramentas MCP.
3

Adicione PHP Xdebug MCP Server como servidor

Quando o status do conector for Pronto, clique em Editar e cole a configuração do servidor MCP.

  1. Aguarde até que o status do conector mostre Pronto.
  2. Clique em Editar.
  3. Cole a configuração do servidor MCP de PHP Xdebug MCP Server.
  4. Salve a lista de servidores.
  5. Atualize para confirmar se o conector ainda está pronto para uso.
Configurações de MCP do TypingMind mostrando um servidor ativo e o botão Editar
{
  "mcpServers": {
    "xdebug-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use a conexão com diferentes modelos

Salve a lista de servidores, abra Plugins, ative as ferramentas MCP de PHP Xdebug MCP Server, selecione qualquer modelo de IA compatível no TypingMind e use as ferramentas no chat ou atribua-as a um agente de IA.

  1. Abra a página Plugins no TypingMind.
  2. Ative as ferramentas MCP de PHP Xdebug MCP Server.
  3. Inicie um chat e escolha o modelo de IA que deseja usar.
  4. Use as ferramentas MCP no chat ou atribua-as a um agente de IA.
  5. Mude para outro modelo de IA sempre que necessário, sem reconectar o MCP.
Chat do TypingMind usando ferramentas MCP ativadas com um modelo de IA selecionado
Pode usar PHP Xdebug MCP Server para me ajudar nesta tarefa?
PHP Xdebug MCP Server
Claro. Já li.
Veja o que encontrei usando PHP Xdebug MCP Server.

Perguntas frequentes

Para que serve o servidor MCP PHP Xdebug MCP Server?

PHP Xdebug MCP Server é um servidor MCP que permite que aplicativos de IA compatíveis se conectem a ferramentas externas e informações de contexto. No TypingMind, basta adicionar esse servidor MCP uma vez para disponibilizar suas ferramentas no seu espaço de trabalho com IA.

Posso usar o MCP PHP Xdebug MCP Server com vários modelos de IA no TypingMind?

Sim. O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho, permitindo usar PHP Xdebug MCP Server com diferentes modelos de IA, como Claude, ChatGPT, Gemini ou outros modelos configurados no TypingMind, sem configurar o servidor MCP separadamente para cada modelo.

Por que usar o MCP PHP Xdebug MCP Server com o TypingMind?

O TypingMind é uma das melhores interfaces de chat com LLMs porque reúne vários modelos de IA, prompts, plugins, agentes de IA, chaves de API e ferramentas MCP em um só espaço de trabalho. Com PHP Xdebug MCP Server conectado, é possível usar suas ferramentas MCP nos seus modelos preferidos e manter seu fluxo de trabalho de chat organizado no TypingMind.

Como conecto o MCP PHP Xdebug MCP Server ao TypingMind?

PHP Xdebug MCP Server funciona por meio do conector MCP local do TypingMind. Essa é a melhor opção quando o servidor MCP precisa acessar arquivos locais, apps de desktop, ferramentas de linha de comando ou recursos privados no seu computador.

Quais ferramentas o MCP PHP Xdebug MCP Server oferece no TypingMind?

PHP Xdebug MCP Server disponibiliza recursos MCP que podem ser ativados na página Plugins do TypingMind e usados no chat ou atribuídos a agentes de IA.

Preciso compartilhar minhas chaves de API com o TypingMind para usar o MCP PHP Xdebug MCP Server?

Não. O TypingMind prioriza o uso local e permite manter seus provedores de modelos, chaves de API, prompts e configuração MCP sob seu controle. Se PHP Xdebug MCP Server exigir autenticação, adicione os cabeçalhos, as configurações OAuth ou a configuração local exigidos por esse servidor MCP ao criar a conexão.

Servidores MCP relacionados

Ver todos

Crie seu próprio espaço de IA agora

Inscreva-se na nossa newsletter para receber novidades sobre recursos e futuros sorteios 👇