Xdebug MCP
X

Xdebug MCP

An MCP server based on the Xdebug DBGp protocol, which provides PHP debugging capabilities for AI assistants and supports complete debugging functions such as breakpoints, variable inspection, and expression evaluation.
2 points
0

什么是Xdebug MCP Server?

Xdebug MCP Server是一个桥梁工具,它允许AI助手(如Claude)通过Model Context Protocol(MCP)与PHP的Xdebug调试器进行通信。简单来说,它让AI能够像专业开发者一样调试PHP代码:设置断点、查看变量、单步执行代码等。

如何使用Xdebug MCP Server?

使用分为三个主要步骤:1) 安装并启动MCP服务器;2) 配置PHP环境启用Xdebug;3) 在AI助手(如Claude)中通过自然语言命令控制调试过程。整个过程无需手动操作IDE,AI会处理所有调试细节。

适用场景

• 快速定位PHP代码中的bug • 理解复杂的代码执行流程 • 检查API请求中的数据状态 • 学习他人代码的执行逻辑 • 自动化测试和调试流程

主要功能

核心调试功能
完整的代码执行控制:继续运行、单步进入、单步跳过、单步跳出、停止调试。支持同时调试多个PHP脚本。
智能断点系统
支持多种断点:行断点、条件断点(当$userId>100时中断)、异常断点、函数调用断点。支持'预置断点',可在脚本运行前设置。
变量检查与修改
查看所有作用域变量、获取特定变量详细信息、修改变量值、实时计算PHP表达式。
监视表达式
设置持久监视表达式(如$user->email),每次暂停时自动计算并显示变化。
日志点(不中断执行)
在代码中插入日志点,输出变量值而不停止执行。支持模板:'用户{$userId}访问了{$endpoint}'。
请求上下文捕获
自动捕获HTTP请求的$_GET、$_POST、$_SESSION、$_COOKIE数据和请求头信息。
Docker容器支持
专门优化支持在Docker容器中运行的PHP应用调试,自动处理路径映射。
代码覆盖率分析
跟踪调试过程中哪些代码行被执行过,生成覆盖率报告。
内存性能分析
监控内存使用情况和执行时间,帮助识别性能瓶颈。
调试配置存档
保存和加载断点配置,快速恢复常用调试环境。
优势
AI驱动调试:用自然语言控制调试,无需学习复杂IDE操作
零配置体验:AI自动处理调试会话管理
多会话支持:同时调试多个PHP应用或请求
预置断点:可在脚本运行前设置断点,特别适合Web应用调试
完整上下文:自动捕获HTTP请求所有相关数据
容器友好:完美支持Docker环境,自动路径映射
局限性
需要Xdebug:PHP环境必须安装并配置Xdebug扩展
网络配置:可能需要调整防火墙或Docker网络设置
学习曲线:需要理解基本调试概念(断点、单步执行等)
性能影响:调试模式会轻微降低PHP执行速度

如何使用

安装MCP服务器
通过npm全局安装xdebug-mcp包,这是连接AI和PHP的桥梁。
配置Claude(或其他AI助手)
在AI助手的MCP设置中添加xdebug-mcp服务器配置。
配置PHP/Xdebug
在PHP配置中启用Xdebug并指向MCP服务器。对于Docker环境需要特殊配置。
开始调试
访问你的PHP应用,Xdebug会自动连接。然后在AI中开始使用调试命令。

使用案例

调试用户登录问题
用户报告登录失败,但错误信息不明确。使用Xdebug MCP跟踪登录流程。
分析API数据流
理解一个复杂API请求的数据处理流程,查看数据在每个阶段的变换。
检查表单提交数据
用户提交的表单数据在服务器端似乎被修改了,需要查看原始数据和处理后的数据。
性能问题调查
某个页面加载很慢,需要找出性能瓶颈。

常见问题

为什么我的PHP脚本没有连接到调试服务器?
断点设置了但没有触发?
Docker环境如何配置路径映射?
可以同时调试多个PHP应用吗?
调试会影响生产环境性能吗?
如何查看之前的调试记录?

相关资源

Xdebug官方文档
Xdebug调试器的完整官方文档,包含所有配置选项和协议细节
Model Context Protocol (MCP)
MCP协议官方规范,了解AI与工具通信的标准
GitHub仓库
xdebug-mcp项目的源代码和问题追踪
npm包页面
查看最新版本、安装统计和版本历史
PHP Docker最佳实践
官方PHP Docker镜像的使用指南和最佳实践

Installation

Copy the following command to your Client for configuration
{
  "mcpServers": {
    "xdebug": {
      "command": "xdebug-mcp",
      "env": {
        "XDEBUG_PORT": "9003",
        "LOG_LEVEL": "info"
      }
    }
  }
}

{
  "mcpServers": {
    "xdebug": {
      "command": "npx",
      "args": ["-y", "xdebug-mcp"],
      "env": {
        "XDEBUG_PORT": "9003",
        "LOG_LEVEL": "info"
      }
    }
  }
}

{
  "mcpServers": {
    "xdebug": {
      "command": "xdebug-mcp",
      "env": {
        "XDEBUG_PORT": "9003",
        "PATH_MAPPINGS": "{\"/var/www/html\": \"/home/user/projects/myapp\"}",
        "LOG_LEVEL": "info"
      }
    }
  }
}
Note: Your key is sensitive information, do not share it with anyone.

Alternatives

R
Rsdoctor
Rsdoctor is a build analysis tool specifically designed for the Rspack ecosystem, fully compatible with webpack. It provides visual build analysis, multi - dimensional performance diagnosis, and intelligent optimization suggestions to help developers improve build efficiency and engineering quality.
TypeScript
6.4K
5 points
N
Next Devtools MCP
The Next.js development tools MCP server provides Next.js development tools and utilities for AI programming assistants such as Claude and Cursor, including runtime diagnostics, development automation, and document access functions.
TypeScript
7.1K
5 points
T
Testkube
Testkube is a test orchestration and execution framework for cloud-native applications, providing a unified platform to define, run, and analyze tests. It supports existing testing tools and Kubernetes infrastructure.
Go
3.8K
5 points
M
MCP Windbg
An MCP server that integrates AI models with WinDbg/CDB for analyzing Windows crash dump files and remote debugging, supporting natural language interaction to execute debugging commands.
Python
6.3K
5 points
R
Runno
Runno is a collection of JavaScript toolkits for securely running code in multiple programming languages in environments such as browsers and Node.js. It achieves sandboxed execution through WebAssembly and WASI, supports languages such as Python, Ruby, JavaScript, SQLite, C/C++, and provides integration methods such as web components and MCP servers.
TypeScript
5.7K
5 points
P
Praisonai
PraisonAI is a production-ready multi-AI agent framework with self-reflection capabilities, designed to create AI agents to automate the solution of various problems from simple tasks to complex challenges. It simplifies the construction and management of multi-agent LLM systems by integrating PraisonAI agents, AG2, and CrewAI into a low-code solution, emphasizing simplicity, customization, and effective human-machine collaboration.
Python
4.2K
5 points
N
Netdata
Netdata is an open-source real-time infrastructure monitoring platform that provides second-level metric collection, visualization, machine learning-driven anomaly detection, and automated alerts. It can achieve full-stack monitoring without complex configuration.
Go
5.3K
5 points
M
MCP Server
The Mapbox MCP Server is a model context protocol server implemented in Node.js, providing AI applications with access to Mapbox geospatial APIs, including functions such as geocoding, point - of - interest search, route planning, isochrone analysis, and static map generation.
TypeScript
5.3K
4 points
M
Markdownify MCP
Markdownify is a multi-functional file conversion service that supports converting multiple formats such as PDFs, images, audio, and web page content into Markdown format.
TypeScript
28.2K
5 points
G
Gitlab MCP Server
Certified
The GitLab MCP server is a project based on the Model Context Protocol that provides a comprehensive toolset for interacting with GitLab accounts, including code review, merge request management, CI/CD configuration, and other functions.
TypeScript
18.9K
4.3 points
N
Notion Api MCP
Certified
A Python-based MCP Server that provides advanced to-do list management and content organization functions through the Notion API, enabling seamless integration between AI models and Notion.
Python
18.4K
4.5 points
D
Duckduckgo MCP Server
Certified
The DuckDuckGo Search MCP Server provides web search and content scraping services for LLMs such as Claude.
Python
58.4K
4.3 points
F
Figma Context MCP
Framelink Figma MCP Server is a server that provides access to Figma design data for AI programming tools (such as Cursor). By simplifying the Figma API response, it helps AI more accurately achieve one - click conversion from design to code.
TypeScript
53.4K
4.5 points
U
Unity
Certified
UnityMCP is a Unity editor plugin that implements the Model Context Protocol (MCP), providing seamless integration between Unity and AI assistants, including real - time state monitoring, remote command execution, and log functions.
C#
24.7K
5 points
G
Gmail MCP Server
A Gmail automatic authentication MCP server designed for Claude Desktop, supporting Gmail management through natural language interaction, including complete functions such as sending emails, label management, and batch operations.
TypeScript
19.4K
4.5 points
M
Minimax MCP Server
The MiniMax Model Context Protocol (MCP) is an official server that supports interaction with powerful text-to-speech, video/image generation APIs, and is suitable for various client tools such as Claude Desktop and Cursor.
Python
38.2K
4.8 points
AIBase
Zhiqi Future, Your AI Solution Think Tank
© 2025AIBase