Skip to content

Commit b8b2e8e

Browse files
authored
Merge pull request #97 from debugmcp/feat/ruby-adapter
feat: Ruby debugging support via rdbg (launch + remote attach)
2 parents 8bc17fb + 316ad55 commit b8b2e8e

67 files changed

Lines changed: 3570 additions & 138 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ jobs:
5959
distribution: 'temurin'
6060
java-version: '21'
6161

62+
- name: Setup Ruby
63+
uses: ruby/setup-ruby@89f90524b88a01fe6e0b732220432cc6142926af # v1.313.0
64+
with:
65+
ruby-version: '3.3'
66+
67+
- name: Verify rdbg (bundled debug gem)
68+
run: rdbg --version
69+
6270
- name: Install Node dependencies
6371
run: pnpm install --frozen-lockfile
6472
env:

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ jobs:
276276
node -e 'console.log("SHARED_VERSION="+require("./packages/shared/package.json").version)' >> $GITHUB_ENV
277277
node -e 'console.log("ADAPTER_MOCK_VERSION="+require("./packages/adapter-mock/package.json").version)' >> $GITHUB_ENV
278278
node -e 'console.log("ADAPTER_PYTHON_VERSION="+require("./packages/adapter-python/package.json").version)' >> $GITHUB_ENV
279+
node -e 'console.log("ADAPTER_RUBY_VERSION="+require("./packages/adapter-ruby/package.json").version)' >> $GITHUB_ENV
279280
node -e 'console.log("CLI_VERSION="+require("./packages/mcp-debugger/package.json").version)' >> $GITHUB_ENV
280281
- name: Set npm dist-tag
281282
run: |
@@ -295,6 +296,7 @@ jobs:
295296
npm pack --dry-run -w @debugmcp/shared
296297
npm pack --dry-run -w @debugmcp/adapter-mock
297298
npm pack --dry-run -w @debugmcp/adapter-python
299+
npm pack --dry-run -w @debugmcp/adapter-ruby
298300
npm pack --dry-run -w @debugmcp/mcp-debugger
299301
300302
- name: Publish to npm (workspaces)
@@ -322,6 +324,12 @@ jobs:
322324
npm publish -w @debugmcp/adapter-python --access public --provenance
323325
fi
324326
327+
if npm view @debugmcp/adapter-ruby@${ADAPTER_RUBY_VERSION} version >/dev/null 2>&1; then
328+
echo "@debugmcp/adapter-ruby@${ADAPTER_RUBY_VERSION} already exists, skipping"
329+
else
330+
npm publish -w @debugmcp/adapter-ruby --access public --provenance
331+
fi
332+
325333
if npm view @debugmcp/mcp-debugger@${CLI_VERSION} version >/dev/null 2>&1; then
326334
echo "@debugmcp/mcp-debugger@${CLI_VERSION} already exists, skipping"
327335
else
@@ -399,6 +407,7 @@ jobs:
399407
**Optional adapters:**
400408
```bash
401409
npm install -g @debugmcp/adapter-python
410+
npm install -g @debugmcp/adapter-ruby
402411
npm install -g @debugmcp/adapter-mock
403412
```
404413

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- **Ruby debugging support** – launch and attach via `rdbg` (debug gem) DAP, including remote attach to containers and Kubernetes pods through port forwarding; conditional breakpoints, locals, repl-context expression evaluation, detach/re-attach (adapted from PR #88, contributed by [@Poyraxx](https://github.com/Poyraxx))
12+
- **Direct-connect attach** – adapter policies can now return a `connect`-mode spawn config to attach straight to an already-listening DAP server without spawning an adapter process; policy selection is driven by the session language via a single shared `getPolicyForLanguage()` mapping instead of adapter-command sniffing
13+
- **Ruby documentation** – `docs/ruby/README.md` user guide with verified launch/attach flows and Docker/Kubernetes remote-attach walkthroughs (`examples/ruby/remote-attach/`)
14+
15+
### Fixed
16+
- Attach sessions no longer apply host-side file existence checks to breakpoint paths — attach targets may run on a remote filesystem (container, pod, other machine)
17+
- `test:unit` now actually runs the per-adapter unit suites on Windows (the `tests/adapters/*/unit` glob never expanded under cmd.exe)
18+
- CLI bundle prepare-pack workspace list updated for new adapter packages
19+
1020
## [0.21.0] - 2026-05-30
1121

1222
### Changed

‎CLAUDE.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mcp-debugger/
1515
├── packages/
1616
│ ├── shared/ # Shared interfaces, types, and utilities
1717
│ ├── adapter-python/ # Python debug adapter using debugpy
18+
│ ├── adapter-ruby/ # Ruby debug adapter using rdbg (debug gem)
1819
│ ├── adapter-javascript/ # JavaScript/Node.js adapter using js-debug
1920
│ ├── adapter-rust/ # Rust debug adapter using CodeLLDB
2021
│ ├── adapter-go/ # Go debug adapter using Delve
@@ -34,6 +35,7 @@ mcp-debugger/
3435

3536
- **@debugmcp/shared**: Core interfaces and types used across all packages
3637
- **@debugmcp/adapter-python**: Python debugging support via debugpy
38+
- **@debugmcp/adapter-ruby**: Ruby debugging support via rdbg (debug gem)
3739
- **@debugmcp/adapter-javascript**: JavaScript/Node.js debugging support via js-debug
3840
- **@debugmcp/adapter-rust**: Rust debugging support via CodeLLDB
3941
- **@debugmcp/adapter-go**: Go debugging support via Delve
@@ -57,7 +59,7 @@ npm run build
5759

5860
# Build specific packages
5961
npm run build:shared
60-
npm run build:adapters # Build mock + python adapters
62+
npm run build:adapters # Build mock + python + ruby adapters
6163
npm run build:adapters:all # Build all adapters including JavaScript
6264
npm run build:packages # Build all packages in correct order via build-packages.cjs
6365

@@ -246,9 +248,10 @@ A dual-state overlay (`SessionLifecycleState` + `ExecutionState`) is derived fro
246248

247249
### Adapter System
248250
- `src/adapters/adapter-registry.ts` - Adapter lifecycle management
249-
- `src/adapters/adapter-loader.ts` - Dynamic adapter loading (7 known adapters)
251+
- `src/adapters/adapter-loader.ts` - Dynamic adapter loading (8 known adapters)
250252
- `packages/shared/` - Shared interfaces and types
251253
- `packages/adapter-python/` - Python debug adapter (debugpy)
254+
- `packages/adapter-ruby/` - Ruby debug adapter (rdbg)
252255
- `packages/adapter-javascript/` - JavaScript/Node.js debug adapter (js-debug)
253256
- `packages/adapter-rust/` - Rust debug adapter (CodeLLDB)
254257
- `packages/adapter-go/` - Go debug adapter (Delve)
@@ -326,6 +329,13 @@ packages/adapter-{language}/
326329
- debugpy must be installed: `pip install debugpy`
327330
- The system will auto-detect Python path or use `PYTHON_PATH` env var
328331

332+
### Ruby
333+
- Ruby 2.7+ must be installed (3.1+ recommended — bundles the debug gem)
334+
- The `debug` gem (rdbg) must be available: `gem install debug`
335+
- Auto-detects ruby/rdbg from PATH and common install locations, or use `RUBY_PATH`/`RDBG_PATH` env vars
336+
- Launch always stops at load (the entry pause is auto-continued for `stopOnEntry=false`); attach connects directly to a running `rdbg --open` DAP socket without spawning an adapter process, including remote targets via port mapping/`kubectl port-forward` (see `docs/ruby/README.md`)
337+
- On Windows, rdbg's `.bat` shim is bypassed by running the sibling rdbg script via the Ruby interpreter (Node cannot spawn `.bat` without a shell)
338+
329339
### JavaScript/Node.js
330340
- Node.js 22+ must be installed
331341
- Uses bundled js-debug adapter (VSCode's debugger)
@@ -478,4 +488,4 @@ Once connected, the following 21 MCP tools become available:
478488
# Should return clean JSON without any log messages
479489
```
480490
- **Verify Python and debugpy are installed**: `python3 -m debugpy --version`
481-
- **Check logs if needed**: Set `DEBUG=debug-mcp:*` environment variable (only for troubleshooting, not for normal operation)
491+
- **Check logs if needed**: Set `DEBUG=debug-mcp:*` environment variable (only for troubleshooting, not for normal operation)

‎README.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<img src="assets/logo.png" alt="MCP Debugger Logo - A stylized circuit board with debug breakpoints" width="400" height="400">
55
</div>
66

7-
**A headless, agentic debugger over MCP — let your AI agents debug running programs in six languages.**
7+
**A headless, agentic debugger over MCP — let your AI agents debug running programs in seven languages.**
88

99
[![CI](https://github.com/debugmcp/mcp-debugger/actions/workflows/ci.yml/badge.svg)](https://github.com/debugmcp/mcp-debugger/actions/workflows/ci.yml)
1010
[![codecov](https://codecov.io/gh/debugmcp/mcp-debugger/branch/main/graph/badge.svg)](https://codecov.io/gh/debugmcp/mcp-debugger)
@@ -15,21 +15,22 @@
1515

1616
## 🎯 Overview
1717

18-
mcp-debugger is a Model Context Protocol (MCP) server that exposes step-through debugging as structured tool calls. It lets AI agents set breakpoints, inspect variables, evaluate expressions, and step through running programs across six languages — driving real language debuggers through the Debug Adapter Protocol (DAP).
18+
mcp-debugger is a Model Context Protocol (MCP) server that exposes step-through debugging as structured tool calls. It lets AI agents set breakpoints, inspect variables, evaluate expressions, and step through running programs across seven languages — driving real language debuggers through the Debug Adapter Protocol (DAP).
1919

2020
> 🆕 **v0.21.0** — the minimum runtime is now **Node.js 22+** (Node 20 reached end-of-life). See the [CHANGELOG](./CHANGELOG.md) for the full release history.
2121
2222
## ✨ Key Features
2323

2424
- 🌐 **Multi-language support** – Clean adapter pattern for any language
2525
- 🐍 **Python debugging via debugpy** – Full DAP protocol support
26+
- 💎 **Ruby debugging via rdbg** – Launch and attach workflows, including remote attach to containers and Kubernetes pods
2627
- 🟨 **JavaScript (Node.js) debugging via js-debug** – VSCode's proven debugger
2728
- 🦀 **Rust debugging via CodeLLDB** – Debug Rust & Cargo projects (Linux/macOS; Windows needs the GNU toolchain — see [Rust on Windows](docs/rust-debugging-windows.md))
2829
- 🐹 **Go debugging via Delve** – Full DAP support for Go programs
2930
- ☕ **Java debugging via JDI bridge** – Launch and attach modes with JDK 21+
3031
- 🔷 **.NET/C# debugging via netcoredbg** – Debug .NET applications with full DAP support
3132
- 🧪 **Mock adapter for testing** – Test without external dependencies
32-
- 🛰️ **Out-of-IDE & remote attach** – Attach over host/port to a process on another machine or inside a container (Python via debugpy, Java via JDWP), with source-path mapping
33+
- 🛰️ **Out-of-IDE & remote attach** – Attach over host/port to a process on another machine or inside a container (Python via debugpy, Ruby via rdbg, Java via JDWP), with source-path mapping
3334
- 🔌 **STDIO and Streamable HTTP transports** – Works with any MCP client (legacy SSE transport is deprecated)
3435
- 📦 **Zero-runtime dependencies** – Self-contained bundles via esbuild + tsup
3536
- ⚡ **npx ready** – Run directly with `npx @debugmcp/mcp-debugger` - no installation needed
@@ -41,7 +42,7 @@ mcp-debugger is a Model Context Protocol (MCP) server that exposes step-through
4142

4243
## 🚀 Quick Start
4344

44-
> **Requirements:** Node.js 22+ for the server. Each language you debug also needs its own toolchain installed (Python + debugpy, Node.js, Go + Delve, JDK 21+, .NET SDK, or the Rust toolchain).
45+
> **Requirements:** Node.js 22+ for the server. Each language you debug also needs its own toolchain installed (Python + debugpy, Ruby + the `debug` gem / `rdbg`, Node.js, Go + Delve, JDK 21+, .NET SDK, or the Rust toolchain).
4546
4647
### For MCP Clients (Claude Desktop, etc.)
4748

@@ -108,7 +109,7 @@ mcp-debugger exposes debugging operations as MCP tools that can be called with s
108109
// Tool: create_debug_session
109110
// Request:
110111
{
111-
"language": "python", // or "javascript", "rust", "go", "java", "dotnet", or "mock" for testing
112+
"language": "python", // or "ruby", "javascript", "rust", "go", "java", "dotnet", or "mock" for testing
112113
"name": "My Debug Session"
113114
}
114115
// Response:
@@ -307,6 +308,7 @@ Then get the local variables:
307308
- 🧩 [Adapter API Reference](./docs/architecture/adapter-api-reference.md) – Adapter, factory, loader, and registry contracts
308309
- 🔄 [Migration Guide](./docs/migration-guide.md) – Upgrading to v0.15.0 (dynamic loading)
309310
- 🐍 [Python Debugging Guide](./docs/python/README.md) – Python-specific features
311+
- 💎 [Ruby Debugging Guide](./docs/ruby/README.md) – Ruby debugging with `rdbg`, including remote attach
310312
- 🟨 [JavaScript Debugging Guide](./docs/javascript/README.md) – JavaScript/TypeScript features
311313
- 🐹 [Go Debugging Guide](./docs/go/README.md) – Go debugging with Delve
312314
- ☕ [Java Debugging Guide](./docs/java/README.md) – Java debugging with JDI bridge
@@ -377,9 +379,9 @@ See [tests/README.md](./tests/README.md) for detailed testing instructions.
377379

378380
## 📊 Project Status
379381

380-
- ✅ **Production Ready**: v0.21.0 with six language adapters and polished multi-language distribution
382+
- ✅ **Production Ready**: v0.21.0 with seven language adapters and polished multi-language distribution
381383
- ✅ **Clean architecture** with a dynamic adapter pattern
382-
- ✅ **Python · JavaScript/TypeScript · Go · Java · .NET/C#**: Full step-through debugging
384+
- ✅ **Python · Ruby · JavaScript/TypeScript · Go · Java · .NET/C#**: Full step-through debugging
383385
- 🦀 **Rust**: Full support on Linux/macOS/Windows (Windows requires the GNU toolchain; MSVC is not supported by CodeLLDB)
384386
- 🟢 **Runtime**: Node.js 22+
385387
- 📈 **Active Development**: Regular updates and improvements
@@ -390,6 +392,7 @@ MIT License - see [LICENSE](./LICENSE) for details.
390392

391393
## 👥 Contributors
392394

395+
- [@Poyraxx](https://github.com/Poyraxx) — Ruby adapter (rdbg)
393396
- [@swinyx](https://github.com/swinyx) — Go adapter (Delve)
394397
- [@roofpig95008](https://github.com/roofpig95008) — Java adapter (JDI bridge)
395398

@@ -399,6 +402,7 @@ Built with:
399402
- [Model Context Protocol](https://github.com/anthropics/model-context-protocol) by Anthropic
400403
- [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/) by Microsoft
401404
- [debugpy](https://github.com/microsoft/debugpy) for Python debugging
405+
- [debug](https://github.com/ruby/debug) for Ruby debugging
402406

403407
---
404408

‎docs/agent-debugging-guide.md‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MCP Debugger Usage Guide for AI Agents
22

3-
This guide explains how to correctly use the MCP Debugger tools when testing debugging functionality across all supported languages (Python, JavaScript, Rust, Go, Java, .NET/C#).
3+
This guide explains how to correctly use the MCP Debugger tools when testing debugging functionality across all supported languages (Python, Ruby, JavaScript, Rust, Go, Java, and .NET/C#).
44

55
## Key Concepts
66

@@ -208,6 +208,25 @@ frame_id = stack["stackFrames"][0]["id"]
208208
get_local_variables(sessionId=session_id)
209209
```
210210

211+
## Ruby Debugging
212+
213+
**Prerequisites**: Ruby 2.7+ installed. `rdbg` must be available through the standard `debug` gem.
214+
215+
**Testing sequence:**
216+
```python
217+
# 1. Create session
218+
session_id = create_debug_session(language="ruby")
219+
220+
# 2. Set breakpoint
221+
set_breakpoint(sessionId=session_id, file="/path/to/app.rb", line=12)
222+
223+
# 3. Start debugging
224+
start_debugging(sessionId=session_id, scriptPath="/path/to/app.rb")
225+
226+
# 4. Inspect variables
227+
get_local_variables(sessionId=session_id)
228+
```
229+
211230
## Go Debugging
212231

213232
**Prerequisites**: Go 1.18+ installed. Delve debugger must be installed: `go install github.com/go-delve/delve/cmd/dlv@latest`.
@@ -284,9 +303,10 @@ get_local_variables(sessionId=session_id)
284303

285304
## Summary
286305

287-
The MCP Debugger is fully functional for Python, JavaScript, Rust, Go, Java, and .NET/C#. The key insights are:
306+
The MCP Debugger is fully functional for Python, Ruby, JavaScript, Rust, Go, Java, and .NET/C#. The key insights are:
288307
- **JavaScript**: Stack trace filtering hides internal frames; may need `continue_execution` if initially stopped at internals
289308
- **Python**: Use variablesReference to expand variable containers
309+
- **Ruby**: Supports launch and attach flows through `rdbg`; use Bundler mode for Rails and RSpec-style entrypoints
290310
- **Rust**: CodeLLDB adapter is vendored; the GNU toolchain is required for reliable debugging -- MSVC-built binaries may produce errors with CodeLLDB. Set `RUST_MSVC_BEHAVIOR` env var to control MSVC handling
291311
- **Go**: Uses Delve's native DAP support
292312
- **Java**: Use FQCN for breakpoints, pass `mainClass`/`classpath` via `dapLaunchArgs`

‎docs/architecture/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Each supported language implements the IDebugAdapter interface:
4949

5050
- **[MockDebugAdapter](../../packages/adapter-mock/)** - Reference implementation for testing
5151
- **[PythonDebugAdapter](../../packages/adapter-python/)** - Python/debugpy support
52+
- **[RubyDebugAdapter](../../packages/adapter-ruby/)** - Ruby/rdbg support
5253
- **[JavascriptDebugAdapter](../../packages/adapter-javascript/)** - JavaScript/Node.js support
5354
- **[RustDebugAdapter](../../packages/adapter-rust/)** - Rust/CodeLLDB support
5455
- **[GoDebugAdapter](../../packages/adapter-go/)** - Go/Delve support
@@ -261,6 +262,7 @@ async endSession(exitCode: number) {
261262

262263
## Version History
263264

265+
- **v0.21.0** - Ruby adapter, 8 adapters total
264266
- **v0.19.0** - .NET/C# adapter, 7 language adapters total
265267
- **v0.18.0** - Go adapter, Java adapter
266268
- **v0.17.0** - Rust adapter

‎docs/architecture/adapter-pattern-design.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
The Debug Adapter Pattern powers mcp-debugger as a multi-language debugging platform supporting 7 languages (Python, JavaScript, Rust, Go, Java, .NET/C#, and Mock). This design uses a **dual-pattern architecture** that combines two complementary adapter patterns:
5+
The Debug Adapter Pattern powers mcp-debugger as a multi-language debugging platform supporting 7 programming languages plus a mock adapter (Python, Ruby, JavaScript, Rust, Go, Java, and .NET/C#). This design uses a **dual-pattern architecture** that combines two complementary adapter patterns:
66

77
1. **IDebugAdapter Interface**: Complete adapter implementations for full language support
88
2. **AdapterPolicy Interface**: Lightweight policies for language-specific session management behaviors
@@ -87,6 +87,7 @@ graph TD
8787
8888
subgraph "Language Adapters"
8989
PA[PythonAdapter]
90+
RBA[RubyAdapter]
9091
NA[JavascriptAdapter]
9192
RA[RustAdapter]
9293
GA[GoAdapter]
@@ -96,6 +97,7 @@ graph TD
9697
end
9798
9899
AR --> PA
100+
AR --> RBA
99101
AR --> NA
100102
AR --> RA
101103
AR --> GA

‎docs/getting-started.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting Started with Debug MCP Server
22

3-
This guide will walk you through testing the Debug MCP Server locally with a simple Python example. The server also supports JavaScript, Rust, Go, Java, and .NET/C# debugging -- see the language-specific guides for details.
3+
This guide will walk you through testing the Debug MCP Server locally with a simple Python example. The server also supports Ruby, JavaScript, Rust, Go, Java, and .NET/C# debugging -- see the language-specific guides for details.
44

55
## Prerequisites
66

0 commit comments

Comments
 (0)