# xdebug

Hooks the Xdebug debugger into your agent: breakpoints, stepping, variable and stack inspection from the chat. Useful when a PHP script fails for no obvious reason.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 28
- Author: kpanuragh
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/kpanuragh/xdebug-mcp
- Updated: 2026-10-16
- HTML: https://affpapa.org/en/nevibecode/mcp/xdebug

## What it does

The server speaks DBGp to Xdebug. From the agent you can set a line or conditional breakpoint, step in, step over, step out, resume or stop a session. Variables are readable and writable, and PHP expressions get evaluated in the current frame.

Over forty tools ship with it. Beyond basic control there are persistent watches, logpoints that use `{$var}` placeholders, memory and time counters between breakpoints, line coverage, and automatic capture of `$_GET`, `$_POST`, `$_SESSION` and headers. Several sessions can run at once, and step filters keep the walker out of vendor libraries. Docker works too — but set `PATH_MAPPINGS`, otherwise container paths won't line up with your host tree. Port 9003 is the one to mirror in `xdebug.client_port`; inside a container the host goes in as `host.docker.internal`. A Unix socket via `XDEBUG_SOCKET_PATH` is an alternative to TCP and has less overhead on your own machine.

## Requirements
- Needs: Node.js (commands run via npx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add xdebug -- npx -y xdebug-mcp
```

### Codex

**Platform CLI**
```bash
codex mcp add xdebug -- npx -y xdebug-mcp
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "xdebug": {
            "command": "npx",
            "args": [
                "-y",
                "xdebug-mcp"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "xdebug": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "xdebug-mcp"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add xdebug npx -y xdebug-mcp
```

## When to use it
- catch the line where a variable takes a wrong value
- walk the call stack of a failing request
- stop only on the exception you care about
- measure memory and time between two points
- see which lines actually ran

## Example prompts
- Set a breakpoint in `src/Order.php` at line 84 and start debugging
- List every variable in the active xdebug session
- Add a watch on `$total` and break when it changes

## Similar
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16717
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40409
- [OpenWork MCP Gateway](https://affpapa.org/en/nevibecode/mcp/openwork-mcp-gateway.md) — MCP server · ★ 24242
- [Keploy](https://affpapa.org/en/nevibecode/mcp/keploy.md) — MCP server · ★ 18727
- [Nhost](https://affpapa.org/en/nevibecode/mcp/nhost.md) — MCP server · ★ 9366
- [basebalance.cloud — x402 RPC & MCP gateway](https://affpapa.org/en/nevibecode/mcp/basebalancecloud-x402-rpc-mcp-gateway.md) — MCP server · ★ 7506

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
