smart-xdebug-mcp

smart-xdebug-mcp

Connects AI assistants like Claude to PHP's XDebug debugger for runtime inspection, breakpoint control, and variable tracking, enabling natural language debugging of PHP applications.

Category
访问服务器

README

Smart XDebug MCP Server

npm version npm downloads CI License: Apache-2.0 Node.js 18+

Let AI debug your PHP code.

Smart XDebug MCP connects Claude to your PHP application's debugger, enabling AI-assisted debugging that actually understands your code at runtime.

<!-- TODO: Add demo GIF here Demo

To create the demo GIF:

  1. Install terminalizer: npm install -g terminalizer
  2. Record: terminalizer record demo
  3. Edit demo.yml to customize
  4. Generate: terminalizer render demo -o docs/demo.gif -->

The Problem

Debugging PHP applications traditionally requires:

  • Manually setting breakpoints in an IDE
  • Stepping through code line by line
  • Remembering to check the right variables at the right time
  • Context-switching between your AI assistant and your debugger

When you ask an AI to help debug, it can only see your code statically. It can't see what's actually happening when your code runs—what values variables hold, where execution flows, or why that exception was thrown.

The Solution

Smart XDebug MCP gives Claude direct access to your PHP debugger. Instead of guessing what might be wrong, Claude can:

  • Set breakpoints at suspicious locations
  • Run your code and pause at those breakpoints
  • Inspect variables to see actual runtime values
  • Step through execution to understand the flow
  • Track variable changes over time with built-in history

It's like pair programming with a debugger expert who never gets tired and can analyze complex state instantly.

Why This Matters

For Developers

  • Faster debugging — Describe the bug, let AI investigate
  • Better insights — AI can correlate patterns across variables you might miss
  • Learning tool — Watch how an experienced debugger approaches problems

For AI

  • Runtime context — See actual values, not just code structure
  • Surgical precision — Request only the data needed, preventing context overload
  • Time-travel — Query what variables were at previous breakpoints

How It Works

You: "My /api/orders endpoint returns empty for user 42, but they have orders in the database"

Claude: *Sets breakpoint in OrderController*
        *Triggers the API request*
        *Inspects $user, $query, $results at the breakpoint*

Claude: "Found it. The query filters by user_id but $user->id is null here
         because the auth middleware isn't running on this route."

No manual stepping. No guessing. Just answers.

Quick Start

1. Install

npm install -g smart-xdebug-mcp

2. Configure Claude Code

Add to your MCP settings (~/.config/claude/settings.json or project .mcp.json):

{
  "mcpServers": {
    "xdebug": {
      "command": "npx",
      "args": ["smart-xdebug-mcp"]
    }
  }
}

3. Configure XDebug

Ensure your PHP environment has XDebug configured:

xdebug.mode = debug
xdebug.start_with_request = trigger
xdebug.client_host = host.docker.internal  ; For Docker
xdebug.client_port = 9003

4. Debug

Ask Claude to debug your PHP code:

"Set a breakpoint at app/Services/PaymentService.php line 127,
then run: curl 'http://localhost/api/checkout?XDEBUG_SESSION=mcp'"

Features

Feature What It Does
Natural Language Debugging Tell Claude what to debug in plain English
Smart Variable Inspection AI requests only relevant data, not full dumps
Time-Travel Queries See what variables were at previous steps
Automatic Path Mapping Works with Docker without manual configuration
Exception Detection Auto-pause when errors occur
Session History Review what happened in past debug sessions

Use Cases

  • "Why is this returning null?" — Trace execution to find where values disappear
  • "This loop seems slow" — Set conditional breakpoints to inspect specific iterations
  • "The API works locally but fails in Docker" — Debug the containerized app directly
  • "I inherited this codebase" — Let AI explore and explain runtime behavior

Requirements

  • Node.js 18+
  • PHP with XDebug 3.x configured for remote debugging
  • Claude Code or another MCP-compatible AI assistant

Configuration

Environment variables for advanced configuration:

Variable Default Description
XDEBUG_MCP_PORT 9003 XDebug listener port
XDEBUG_MCP_TIMEOUT 30000 Connection timeout (ms)
XDEBUG_MCP_WATCHDOG_TIMEOUT 300000 Auto-terminate idle sessions (5 min)

Path mappings are auto-detected from .vscode/launch.json or docker-compose.yml.

Architecture

Smart XDebug MCP acts as a bridge:

Claude ←→ MCP Protocol ←→ Smart XDebug MCP ←→ DBGp Protocol ←→ XDebug ←→ PHP

The server translates high-level debugging intent into DBGp commands, handles the complexity of the protocol, and returns clean, AI-friendly responses.

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

Copyright 2026 Tyler Wall

Licensed under the Apache License, Version 2.0. See LICENSE for details.


Keywords: PHP debugging, AI debugging, Claude MCP, XDebug integration, autonomous debugging, Model Context Protocol, PHP development tools, AI-assisted development, remote debugging, Docker PHP debugging

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选