Skip to main content
Glama
Debug MCP Server

Debug MCP Server

by dheerajiiitv
README.md
# Debug MCP Server

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![npm version](https://img.shields.io/npm/v/@debug-mcp/server.svg)](https://www.npmjs.com/package/@debug-mcp/server)
[![PyPI version](https://img.shields.io/pypi/v/debug-mcp.svg)](https://pypi.org/project/debug-mcp/)

Share debugging session variables with AI assistants (Cursor, Claude, etc.) via [Model Context Protocol (MCP)](https://modelcontextprotocol.io/).

## Features

- **Multi-language support**: Python, Node.js/TypeScript (more coming)
- **Easy to use**: Just `share(variable)` in your debug console
- **Extensible**: Add support for any language via the standard API
- **Works everywhere**: Cursor, Claude Desktop, any MCP-compatible client

## Quick Start

### 1. Install the MCP Server

Add to your MCP client configuration:

**Cursor** (`~/.cursor/mcp.json`):
```json
{
  "mcpServers": {
    "debug": {
      "command": "npx",
      "args": ["@debug-mcp/server"]
    }
  }
}
```

**Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
```json
{
  "mcpServers": {
    "debug": {
      "command": "npx",
      "args": ["@debug-mcp/server"]
    }
  }
}
```

### 2. Install the Language Helper

**Python:**
```bash
pip install debug-mcp
```

**Node.js/TypeScript:**
```bash
npm install -D @debug-mcp/helper-node
```

### 3. Share Variables in Debug Session

**Python** (in Debug Console):
```python
from debug_mcp import share
share(my_variable)
share(response.data, "api_response")
```

**Node.js** (in Debug Console):
```javascript
const { share } = require('@debug-mcp/helper-node');
share(myVariable);
share(myObject, 'customName');
```

### 4. Ask the AI

Now in Cursor or Claude, just ask:
- "What's in the `my_variable` debug variable?"
- "Evaluate `len(response.data)` in the Python debug session"
- "Show me all shared variables"

## Architecture

```
┌─────────────────────────────────────────────────────────────────────┐
│                       Your Debug Session                            │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐     │
│  │ Python :9753    │  │ Node.js :9754   │  │ Go :9755        │     │
│  │ share(var)      │  │ share(var)      │  │ share(var)      │     │
│  └────────┬────────┘  └────────┬────────┘  └────────┬────────┘     │
└───────────┼─────────────────────┼─────────────────────┼─────────────┘
            │ HTTP                │ HTTP                │ HTTP
            ▼                     ▼                     ▼
┌─────────────────────────────────────────────────────────────────────┐
│                    MCP Server (@debug-mcp/server)                   │
│  - Discovers language helpers automatically                        │
│  - Provides unified tools: get_variable, evaluate, list_sessions   │
│  - Communicates via MCP protocol (stdio)                           │
└─────────────────────────────────────────────────────────────────────┘
            │ MCP (stdio)
            ▼
┌─────────────────────────────────────────────────────────────────────┐
│                 AI Assistant (Cursor / Claude)                      │
│  "What's in my_variable?"                                           │
│  → Uses debug_get_variable("my_variable") tool                      │
│  → Gets serialized JSON response                                    │
└─────────────────────────────────────────────────────────────────────┘
```

## Available MCP Tools

| Tool | Description |
|------|-------------|
| `debug_list_sessions` | List all active debug sessions |
| `debug_list_variables` | List shared variables from a session |
| `debug_get_variable` | Get value of a specific variable |
| `debug_evaluate` | Evaluate an expression in debug context |
| `debug_get_variable_info` | Get type info and attributes |
| `debug_get_locals` | Get all local variables from debug frame |

## Language Helpers

### Python (`debug-mcp`)

```python
from debug_mcp import share, share_locals, list_shared

# Share a variable
share(my_variable)           # Auto-detect name
share(obj, "custom_name")    # Custom name

# Share all local variables
share_locals()

# List shared variables
list_shared()

# Quick aliases
from debug_mcp import s, sl, ls
s(my_var)   # = share()
sl()        # = share_locals()
ls()        # = list_shared()
```

**Supported types:** dict, list, tuple, set, dataclass, Pydantic models, Protobuf messages, NumPy arrays, Pandas DataFrames, any object with `__dict__`

### Node.js/TypeScript (`@debug-mcp/helper-node`)

```javascript
const { share, shareLocals, listShared } = require('@debug-mcp/helper-node');

// Share a variable
share(myVariable);
share(myObject, 'customName');

// Share local scope
shareLocals({ myVar, otherVar, config });

// List shared variables
listShared();

// Quick aliases
const { s, sl, ls } = require('@debug-mcp/helper-node');
```

**Supported types:** primitives, objects, arrays, Map, Set, Date, RegExp, Error, Buffer, class instances

## Configuration

### Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `DEBUG_MCP_PORT` | `9753` (Python), `9754` (Node) | Port for helper server |
| `DEBUG_MCP_HOST` | `127.0.0.1` | Host for helper server |

## Adding New Language Support

See [docs/ADDING_LANGUAGE.md](docs/ADDING_LANGUAGE.md) for a guide on implementing support for additional languages.

## Development

```bash
# Clone the repo
git clone https://github.com/YOUR_USERNAME/debug-mcp-server.git
cd debug-mcp-server

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run the MCP server locally
node packages/mcp-server/dist/index.js
```

## Contributing

Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

## License

MIT