bevy_debugger_mcp 0.1.8

AI-assisted debugging for Bevy games through Claude Code using Model Context Protocol
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
# Bevy Debugger MCP Server

[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/ladvien/bevy_debugger_mcp)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](LICENSE)
[![Rust](https://img.shields.io/badge/rust-1.70+-orange.svg)](https://www.rust-lang.org)
[![Bevy](https://img.shields.io/badge/bevy-0.14+-purple.svg)](https://bevyengine.org)

A powerful Model Context Protocol (MCP) server that enables AI-assisted debugging of Bevy games through Claude Code. Debug your game state, analyze performance, and test hypotheses with natural language commands.

## ๐ŸŽฏ Quick Start (5 minutes)

```bash
# 1. Install the debugger
cargo install bevy_debugger_mcp

# 2. Add RemotePlugin to your Bevy game
# In your game's main.rs:
# .add_plugins(RemotePlugin::default())

# 3. Configure Claude Code (add to ~/.config/claude/claude_code_config.json)
echo '{
  "mcpServers": {
    "bevy-debugger": {
      "command": "bevy-debugger-mcp",
      "args": []
    }
  }
}' >> ~/.config/claude/claude_code_config.json

# 4. Run your game and start debugging!
cargo run  # In your game directory
# Then open Claude Code and say: "Help me debug my Bevy game"
```

## โœจ Features

- **๐Ÿ” Real-time Observation**: Monitor entities, components, and resources as your game runs
- **๐Ÿงช Smart Experimentation**: Test game behavior changes with automatic rollback
- **๐Ÿ“Š Performance Analysis**: Identify bottlenecks and optimize game performance  
- **๐Ÿšจ Anomaly Detection**: Automatically spot unusual patterns in game behavior
- **๐Ÿ“น Session Recording**: Record and replay debugging sessions for analysis
- **๐Ÿ“ธ Screenshot Capture**: Take window-specific screenshots of your game for visual debugging
- **๐Ÿ›ก๏ธ Error Recovery**: Robust error handling with automatic diagnostics
- **๐Ÿค– ML-Powered Suggestions**: Learn from debugging patterns to provide better recommendations
- **๐Ÿ“ˆ Performance Budgets**: Set and monitor performance targets with automatic alerts
- **๐Ÿ”„ Workflow Automation**: Automate common debugging tasks with safety checkpoints

## ๐Ÿ—๏ธ How It Works

The Bevy Debugger MCP creates a bridge between Claude Code and your Bevy game:

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     MCP Protocol      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     BRP Protocol    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Claude Code โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ bevy-debugger-mcp โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Your Bevy   โ”‚
โ”‚   (AI)      โ”‚    stdio/TCP          โ”‚    (Server)       โ”‚    WebSocket       โ”‚    Game     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚                                         โ”‚                                       โ”‚
     โ”‚ "Find memory leaks"                    โ”‚                                       โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ                   โ”‚                                       โ”‚
                                              โ”‚ Query entities & components           โ”‚
                                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚
                                              โ”‚                                       โ”‚
                                              โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
                                              โ”‚     Entity data & metrics             โ”‚
     โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                   โ”‚                                       โ”‚
     โ”‚ "Found 500 orphaned                    โ”‚                                       โ”‚
     โ”‚  bullet entities"                      โ”‚                                       โ”‚
```

### Architecture Components

1. **Claude Code (AI Agent)**: Natural language interface for debugging commands
2. **MCP Server**: Translates AI requests into game debugging operations
3. **BRP Client**: Communicates with your Bevy game via WebSocket
4. **RemotePlugin**: Bevy plugin that exposes game internals for debugging
5. **Debug Tools**: 11 specialized tools for different debugging tasks

## ๐Ÿš€ Quick Start

### Prerequisites

- Rust 1.70+ and Cargo
- Claude Code CLI
- A Bevy game with [RemotePlugin]https://docs.rs/bevy/latest/bevy/remote/struct.RemotePlugin.html enabled

### Installation

```bash
# Install from crates.io (recommended)
cargo install bevy_debugger_mcp

# Or clone and build from source
git clone https://github.com/ladvien/bevy_debugger_mcp.git
cd bevy_debugger_mcp
cargo build --release

# Install (macOS/Linux)
./scripts/install.sh

# Setup Claude Code integration
./scripts/setup-claude.sh
```

### Server Management with `bevy-debugger-control`

The `bevy-debugger-control` script is automatically installed with the package and provides complete lifecycle management for the MCP server. This solves the common issue of the server hanging when run directly.

#### Basic Commands

```bash
# Start the server in the background
bevy-debugger-control start

# Stop the server gracefully
bevy-debugger-control stop

# Restart the server (useful after configuration changes)
bevy-debugger-control restart

# Check if the server is running and view details
bevy-debugger-control status

# View server logs
bevy-debugger-control logs

# Follow logs in real-time (like tail -f)
bevy-debugger-control logs -f

# Clean up old log files
bevy-debugger-control clean

# Show help and all available commands
bevy-debugger-control help
```

#### Advanced Usage

```bash
# Start server on a different port
BEVY_DEBUGGER_PORT=3002 bevy-debugger-control start

# Start with custom Bevy host/port
BEVY_BRP_HOST=192.168.1.100 BEVY_BRP_PORT=15703 bevy-debugger-control start

# Clean all logs including current
bevy-debugger-control clean --all

# Check server status with process details
bevy-debugger-control status
# Output shows:
# - PID of running process
# - CPU and memory usage
# - Port binding status
# - Recent log entries
```

#### File Locations

The control script manages the following files:
- **Logs**: `~/.bevy-debugger/bevy-debugger.log`
- **PID file**: `~/.bevy-debugger/bevy-debugger.pid`
- **Rotated logs**: `~/.bevy-debugger/bevy-debugger.log.*`

#### Troubleshooting

If the server fails to start:
```bash
# Check the logs for errors
bevy-debugger-control logs

# Ensure no other instance is running
bevy-debugger-control stop
bevy-debugger-control start

# Verify the binary is installed
which bevy-debugger-mcp

# Check if port is already in use
lsof -i :3001  # or your configured port
```

### Setup Your Bevy Game

Add the RemotePlugin to your Bevy app:

```rust
use bevy::prelude::*;
use bevy::remote::{RemotePlugin, BrpResult};
use bevy::render::view::screenshot::{save_to_disk, Screenshot};
use serde_json::Value;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(
            RemotePlugin::default()
                .with_method("bevy_debugger/screenshot", screenshot_handler)
        )
        .run();
}

// Enable screenshot functionality
fn screenshot_handler(
    In(params): In<Option<Value>>, 
    mut commands: Commands,
) -> BrpResult {
    let path = params
        .as_ref()
        .and_then(|p| p.get("path"))
        .and_then(|p| p.as_str())
        .unwrap_or("./screenshot.png")
        .to_string();

    commands
        .spawn(Screenshot::primary_window())
        .observe(save_to_disk(path.clone()));
    
    Ok(serde_json::json!({
        "path": path,
        "success": true
    }))
}
```

```toml
# Cargo.toml
[dependencies]
bevy = { version = "0.16", features = ["default", "bevy_remote"] }
```

### Start Debugging

1. **Run your Bevy game**: `cargo run`
2. **Open Claude Code** in your project directory
3. **Start debugging**: Try commands like:
   - "Show me all entities in the game"
   - "Monitor the player's health component"
   - "Test what happens when I spawn 100 enemies"
   - "Take a screenshot of the current game state"
   - "Record this gameplay session for analysis"

## ๐Ÿค– Claude Code Integration Guide

### Setting Up Claude Code

1. **Install the MCP Server** (v0.1.6 or later):
```bash
cargo install bevy_debugger_mcp
```

2. **Configure Claude Code** - Add to your Claude Code settings:

**macOS/Linux**: `~/.config/claude/claude_code_config.json`
**Windows**: `%APPDATA%\claude\claude_code_config.json`

```json
{
  "mcpServers": {
    "bevy-debugger": {
      "command": "bevy-debugger-mcp",
      "args": ["--stdio"],
      "type": "stdio",
      "env": {
        "BEVY_BRP_HOST": "localhost",
        "BEVY_BRP_PORT": "15702",
        "RUST_LOG": "info"
      }
    }
  }
}
```

3. **Verify Installation**:
```bash
# Check version
bevy-debugger-mcp --help

# Test the MCP server responds correctly
echo '{"jsonrpc": "2.0", "method": "initialize", "params": {"capabilities": {}}, "id": 1}' | bevy-debugger-mcp --stdio
# Should return: {"id":1,"jsonrpc":"2.0","result":{"capabilities":...}}

# Verify tools are available
echo '{"jsonrpc": "2.0", "method": "tools/list", "id": 2}' | bevy-debugger-mcp --stdio
# Should list: observe, experiment, stress, anomaly, replay, hypothesis, screenshot
```

### How Claude Uses the MCP Tools

When you ask Claude to debug your Bevy game, it has access to powerful MCP tools that communicate with your running game:

#### ๐Ÿ” **Observation Tools**
Claude can monitor your game state in real-time:
```markdown
You: "Show me all enemies in the game"
Claude: [Uses observe tool to query entities with Enemy component]
        "I found 5 enemies. Here are their positions and health values..."

You: "Track the player's velocity over time"
Claude: [Uses observe tool with continuous monitoring]
        "The player's velocity spikes to 500 units when jumping, which seems abnormal..."
```

#### ๐Ÿงช **Experimentation Tools**
Claude can test hypotheses by modifying game state:
```markdown
You: "Test what happens if we spawn 100 enemies at once"
Claude: [Uses experiment tool to spawn entities and measure performance]
        "Spawning 100 enemies causes frame rate to drop to 15 FPS. The bottleneck is..."

You: "Try doubling the player's speed and see if collision still works"
Claude: [Uses experiment tool to modify components with automatic rollback]
        "At 2x speed, the player clips through thin walls. The physics system needs..."
```

#### ๐Ÿšจ **Anomaly Detection**
Claude can identify unusual patterns:
```markdown
You: "Something is causing random lag spikes"
Claude: [Uses anomaly tool to monitor performance metrics]
        "I detected memory allocations spike every 5 seconds, coinciding with..."

You: "Find any entities behaving strangely"
Claude: [Uses anomaly tool with pattern matching]
        "Entity #42 is teleporting between positions, likely due to..."
```

#### ๐Ÿ“Š **Performance Analysis**
Claude can profile and optimize:
```markdown
You: "Why is my game running slowly?"
Claude: [Uses stress tool to identify bottlenecks]
        "The render system is taking 45ms per frame. The main issue is..."

You: "Optimize the enemy AI system"
Claude: [Uses performance profiling tools]
        "The pathfinding is recalculating every frame. We can cache results..."
```

### Real-World Debugging Sessions

#### Example 1: Physics Bug
```markdown
Human: My character falls through the floor randomly

Claude: I'll investigate this physics issue. Let me start by observing the player's Transform and Collider components.

[Uses observe tool to monitor player entity]
I'm tracking the player's Y position... I notice it suddenly changes from 0.0 to -100.0 without intermediate values.

[Uses experiment tool to test collision]
Let me test the collision system by spawning a test entity at the player's position...
The collision detection is failing when the player's velocity exceeds 1000 units/frame.

Solution: Add a velocity cap or use continuous collision detection for high-speed entities.
```

#### Example 2: Performance Investigation
```markdown
Human: The game freezes every few seconds

Claude: I'll analyze the performance patterns to identify the cause of these freezes.

[Uses anomaly detection on frame times]
I've detected periodic spikes in frame time every 3.2 seconds, lasting about 200ms.

[Uses observe tool on system metrics]
Monitoring system activity... The "EnemySpawnSystem" is creating 50 entities at once every 3 seconds.

[Uses experiment tool to test optimization]
Let me test spreading the spawning over multiple frames...
Spawning 5 entities per frame over 10 frames eliminates the freezes.

Solution: Implement batched spawning to distribute the load across frames.
```

#### Example 3: Visual Debugging
```markdown
Human: Can you show me what the AI sees?

Claude: I'll visualize the AI's perception system for you.

[Uses visual overlay tools]
I'm enabling debug overlays for:
- AI vision cones (showing field of view)
- Pathfinding waypoints (showing planned routes)  
- Detection ranges (showing awareness zones)

[Takes screenshot]
Here's a screenshot showing the AI's perception. The red cones are vision, blue lines are paths.

The AI at position (100, 50) can't see the player because there's an obstacle blocking line of sight.
```

### Advanced Usage Patterns

#### Continuous Monitoring
```markdown
Human: Monitor the game for any issues while I playtest

Claude: I'll set up continuous monitoring for common issues.

[Sets up multiple observe and anomaly detection tasks]
Monitoring:
- Memory usage (alerting if >2GB)
- Frame time (alerting if >16ms)
- Entity count (alerting if >10000)
- Error patterns in components

[After 5 minutes]
Alert: Memory usage increased by 500MB in the last minute.
Investigating... Found 5000 orphaned bullet entities not being destroyed.
```

#### Automated Testing
```markdown
Human: Test if my save system works correctly

Claude: I'll test the save/load system comprehensively.

[Uses orchestration tool to chain operations]
1. Capturing current game state...
2. Modifying player position, inventory, and score...
3. Triggering save...
4. Resetting game...
5. Triggering load...
6. Comparing states...

Results: Save system works correctly for position and score, but inventory items are duplicated on load.
```

### Troubleshooting Claude Code Connection

If Claude can't connect to your game:

```bash
# 1. Ensure your Bevy game is running with RemotePlugin
# Check if Bevy is listening on the correct port:
lsof -i :15702  # Should show your Bevy game process

# 2. Test the MCP server standalone:
bevy-debugger-mcp --help  # Should show version 0.1.6
bevy-debugger-mcp --stdio  # Should wait for input (Ctrl+C to exit)

# 3. Verify Claude Code configuration:
cat ~/.config/claude/claude_code_config.json
# Should contain the bevy-debugger configuration

# 4. Test manual MCP connection:
echo '{"jsonrpc": "2.0", "method": "tools/list", "id": 2}' | bevy-debugger-mcp --stdio
# Should return list of available tools

# 5. Check direct Bevy connection:
curl -X POST http://localhost:15702/query \
  -H "Content-Type: application/json" \
  -d '{"method": "bevy/list", "params": {}}'
# Should return Bevy data

# 6. Enable debug logging:
RUST_LOG=debug bevy-debugger-mcp --stdio

# 7. Common issues:
# - Port 15702 blocked by firewall
# - Bevy game not compiled with bevy_remote feature
# - Multiple MCP servers running on same port
# - Claude Code needs restart after config changes
```

### Performance Characteristics

The debugger is designed for minimal impact on your game:

| Metric | Target | Actual | Notes |
|--------|--------|--------|-------|
| **Idle Overhead** | <5% | <3% | When connected but not actively debugging |
| **Active Overhead** | <10% | <7% | During active debugging operations |
| **Memory Usage** | <50MB | ~30MB | Includes caching and session data |
| **Startup Time** | <1s | ~500ms | With lazy initialization |
| **Command Latency** | <200ms | <50ms | For simple queries |
| **Complex Query** | <1s | ~200ms | For queries returning 1000+ entities |

### Common Issues and Solutions

| Issue | Solution |
|-------|----------|
| **"Failed to connect to BRP"** | Ensure your Bevy game is running with `RemotePlugin` enabled |
| **"No tools available"** | Update to v0.1.6: `cargo install bevy_debugger_mcp --force` |
| **High CPU usage** | Reduce monitoring frequency or use `--tcp` mode instead of stdio |
| **Screenshot not working** | Add screenshot handler to your Bevy game (see setup example) |
| **Memory leak detection false positives** | Adjust detection thresholds in anomaly tool |
| **Claude not responding** | Restart Claude Code after configuration changes |

## ๐Ÿ› ๏ธ Configuration

The server uses environment variables for configuration:

```bash
export BEVY_BRP_HOST=localhost    # Bevy Remote Protocol host
export BEVY_BRP_PORT=15702        # Bevy Remote Protocol port  
export MCP_PORT=3000              # MCP server port (not used in stdio mode)
export RUST_LOG=info              # Logging level
```

## ๐Ÿ“ Project Structure

```
bevy_debugger_mcp/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs              # Entry point with stdio/TCP transport
โ”‚   โ”œโ”€โ”€ mcp_server.rs        # MCP protocol implementation
โ”‚   โ”œโ”€โ”€ brp_client.rs        # Bevy Remote Protocol client
โ”‚   โ”œโ”€โ”€ tools/               # Debugging tool implementations
โ”‚   โ”‚   โ”œโ”€โ”€ observe.rs       # Entity/component observation
โ”‚   โ”‚   โ”œโ”€โ”€ experiment.rs    # Game state experimentation
โ”‚   โ”‚   โ”œโ”€โ”€ stress.rs        # Performance stress testing
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ scripts/                 # Installation and management scripts
โ”œโ”€โ”€ docs/                    # Documentation
โ”œโ”€โ”€ tests/                   # Integration tests
โ””โ”€โ”€ README.md
```

## ๐Ÿ“š Complete Developer Workflow

### Step 1: Prepare Your Bevy Game

```rust
// In your main.rs or lib.rs
use bevy::prelude::*;
use bevy::remote::RemotePlugin;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(RemotePlugin::default()) // Essential for debugging
        .add_systems(Update, your_game_systems)
        .run();
}
```

### Step 2: Install and Configure

```bash
# Install the debugger
cargo install bevy_debugger_mcp

# Add to Claude Code config (~/.config/claude/claude_code_config.json)
{
  "mcpServers": {
    "bevy-debugger": {
      "command": "bevy-debugger-mcp",
      "args": []
    }
  }
}
```

### Step 3: Start Debugging Session

1. **Run your Bevy game**: `cargo run`
2. **Open Claude Code** in your project
3. **Start debugging** with natural language:
   - "What entities are in my game?"
   - "Why is performance dropping?"
   - "Monitor the player's health"
   - "Test spawning 1000 enemies"

## ๐Ÿงช Complete Debugging Toolkit (v0.1.6)

### Core MCP Tools

| Tool | Description | Example Usage |
|------|-------------|---------------|
| `observe` | Monitor game entities, components, and resources in real-time | "Show me all entities with Health component" |
| `experiment` | Test changes to game state with automatic rollback | "Set player speed to 2x and test collision" |
| `stress` | Performance testing and bottleneck identification | "Stress test the physics system with 500 objects" |
| `anomaly` | Detect unusual patterns in game behavior | "Find any entities with abnormal velocities" |
| `replay` | Record and replay debugging sessions | "Record the next 30 seconds of gameplay" |
| `hypothesis` | Test specific assumptions about game behavior | "Test if framerate drops when spawning > 100 enemies" |
| `screenshot` | Capture game window visuals with timing control | "Take a screenshot after 2 seconds warmup" |

### Internal Debug Commands (11 Integrated Tools)

The debugger provides 11 specialized debugging tools accessible through the MCP protocol:

| Tool | Purpose | Key Features |
|------|---------|--------------|
| **EntityInspector** | Deep entity analysis | โ€ข Component inspection<br>โ€ข Relationship tracking<br>โ€ข Change detection |
| **SystemProfiler** | System performance analysis | โ€ข Microsecond precision<br>โ€ข Dependency tracking<br>โ€ข <3% overhead |
| **VisualDebugOverlay** | In-game debug visualization | โ€ข Entity highlights<br>โ€ข Collider visualization<br>โ€ข Performance metrics |
| **QueryBuilder** | Type-safe ECS queries | โ€ข Natural language queries<br>โ€ข Query validation<br>โ€ข Result caching |
| **MemoryProfiler** | Memory usage tracking | โ€ข Allocation tracking<br>โ€ข Leak detection<br>โ€ข Usage patterns |
| **SessionManager** | Debug session management | โ€ข Session recording<br>โ€ข Checkpoint creation<br>โ€ข State comparison |
| **IssueDetector** | Automated issue detection | โ€ข 17 detection patterns<br>โ€ข Real-time monitoring<br>โ€ข Auto-diagnostics |
| **PerformanceBudgetMonitor** | Performance budget enforcement | โ€ข Frame time budgets<br>โ€ข Memory limits<br>โ€ข Violation tracking |
| **PatternLearningSystem** | ML-based pattern recognition | โ€ข Privacy-preserving (k=5)<br>โ€ข Pattern mining<br>โ€ข Suggestion generation |
| **SuggestionEngine** | Context-aware suggestions | โ€ข Based on learned patterns<br>โ€ข Confidence scoring<br>โ€ข Action recommendations |
| **WorkflowAutomation** | Automated debug workflows | โ€ข Common task automation<br>โ€ข Safety checkpoints<br>โ€ข Rollback support |

## ๐Ÿ–ฅ๏ธ Platform Support

| Platform | Installation | Status |
|----------|--------------|--------|
| **macOS** | `./scripts/install.sh` | โœ… Full support with LaunchAgent service |
| **Linux** | `./scripts/install.sh` | โœ… Full support |
| **Windows** | Manual build | โš ๏ธ Basic support (help wanted) |

### macOS Service Management

On macOS, the debugger can run as a background service:

```bash
# Service management
./scripts/service.sh start      # Start background service
./scripts/service.sh stop       # Stop service
./scripts/service.sh status     # Check status
./scripts/service.sh logs       # View logs
```

## ๐Ÿค Contributing

We welcome contributions! Please see our [contribution guidelines](CONTRIBUTING.md).

```bash
# Development setup
git clone https://github.com/ladvien/bevy_debugger_mcp.git
cd bevy_debugger_mcp
cargo test                      # Run basic tests
cargo test --ignored           # Run full integration tests
cargo test screenshot_integration_wrapper::test_screenshot_ci_suite  # Fast screenshot tests
cargo fmt                       # Format code
cargo clippy                    # Lint code
```

### Running Screenshot Tests

The screenshot functionality has comprehensive test coverage:

```bash
# Fast screenshot tests (suitable for CI/development)
cargo test screenshot_integration_wrapper::test_screenshot_ci_suite

# Full screenshot integration suite  
cargo test screenshot_integration_wrapper::test_screenshot_integration_suite -- --ignored

# Individual test categories
cargo test screenshot_integration_wrapper::test_screenshot_utilities
cargo test screenshot_integration_wrapper::test_screenshot_basic_functionality
cargo test screenshot_integration_wrapper::test_screenshot_parameter_validation
cargo test screenshot_integration_wrapper::test_screenshot_timing_controls

# Performance testing
cargo test screenshot_integration_wrapper::test_screenshot_performance
```

## ๐Ÿ“š Documentation

- **[Usage Guide]docs/USAGE_GUIDE.md** - Detailed feature documentation
- **[Claude Prompts]docs/CLAUDE_SUBAGENT_GUIDE.md** - Effective prompting strategies
- **[macOS Service Setup]docs/MACOS_SERVICE.md** - Background service configuration

## ๐Ÿ”’ Security & Privacy

- All communication happens locally between your game and Claude Code
- No game data is transmitted externally
- Sensitive information is automatically redacted from logs
- Debug recordings are stored locally and encrypted

## ๐Ÿ“ฆ Changelog

### v0.1.6 (Latest) - Production Ready
- โœ… All 11 debugging tools fully integrated and operational
- โœ… Fixed critical async initialization issues
- โœ… Enhanced error handling and sensitive data sanitization
- โœ… Performance optimizations with lazy initialization
- โœ… Comprehensive test coverage (232+ tests)
- โœ… Machine learning pattern recognition with privacy preservation
- โœ… Workflow automation for common debugging tasks
- โœ… Production-ready with <3% performance overhead

### v0.1.5
- Added GPL-3.0 license compliance
- Initial pattern learning system
- Enhanced error context

### v0.1.4
- Improved Claude Code integration
- Added suggestion engine
- Bug fixes

## ๐Ÿ“„ License

This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- Built for the [Bevy Engine]https://bevyengine.org/ community
- Powered by [Anthropic's MCP]https://modelcontextprotocol.io/
- Inspired by the need for better game debugging tools

---

**Questions?** Open an [issue](https://github.com/ladvien/bevy_debugger_mcp/issues) or join the discussion in [Bevy's Discord](https://discord.gg/bevy).